class GemCheckUpdates::Message

Public Class Methods

gems_version_diff(gemfile) click to toggle source
# File lib/gem_check_updates/message.rb, line 38
def self.gems_version_diff(gemfile)
  updatable_gems = gemfile.gems.select(&:update_available?)

  if updatable_gems.empty?
    'There are no updates.'.green
  else
    updatable_gems.map do |gem|
      name = gem.name
      current = "#{gem.version_range} #{gem.current_version}"
      latest = "#{gem.version_range} #{gem.highlighted_latest_version}"

      "    #{name.ljust(30)} #{current.ljust(15)} #{'→'.ljust(7)} #{latest}"
    end.join("\n")
  end
end
out(str) click to toggle source
# File lib/gem_check_updates/message.rb, line 5
def self.out(str)
  return if ENV['RACK_ENV'] == 'test'

  print str
end
updatable_gems(gemfile) click to toggle source
# File lib/gem_check_updates/message.rb, line 11
    def self.updatable_gems(gemfile)
      out <<~MSG
        Checking #{gemfile.option.update_scope.green} updates are completed.

        You can update following newer gems.
        If you want to apply these updates, run command with option #{'--apply'.green}.

        #{'Running with --apply option will overwrite your Gemfile.'.red}

        #{gems_version_diff(gemfile)}


      MSG
    end
update_completed(gemfile) click to toggle source
# File lib/gem_check_updates/message.rb, line 26
    def self.update_completed(gemfile)
      out <<~MSG
        Checking #{gemfile.option.update_scope.green} updates are completed.

        Following gems have been updated!

        #{gems_version_diff(gemfile)}


      MSG
    end