class Gemdiff::CLI

Constants

CHECKING_FOR_OUTDATED
NOTHING_TO_UPDATE
WORKING_DIRECTORY_IS_NOT_CLEAN

Public Instance Methods

compare(gem_name, old_version = nil, new_version = nil) click to toggle source
# File lib/gemdiff/cli.rb, line 47
def compare(gem_name, old_version = nil, new_version = nil)
  outdated_gem = find(gem_name)
  return unless outdated_gem.repo?
  outdated_gem.set_versions old_version, new_version
  if outdated_gem.missing_versions?
    puts CHECKING_FOR_OUTDATED
    unless outdated_gem.load_bundle_versions
      puts "#{gem_name} is not outdated in your bundle. Specify versions."
      return
    end
  end
  puts outdated_gem.compare_message
  outdated_gem.compare
end
each() click to toggle source
# File lib/gemdiff/cli.rb, line 63
def each
  puts CHECKING_FOR_OUTDATED
  inspector = BundleInspector.new
  puts inspector.outdated
  open_all = false
  inspector.list.each do |outdated_gem|
    puts outdated_gem.compare_message
    response = open_all || ask("Open? (y to open, x to exit, A to open all, s to show all to stdout, else skip)")
    open_all = response if %w[s A].include?(response)
    outdated_gem.compare if %w[y A].include?(response)
    puts outdated_gem.compare_url if response == "s"
    break if response == "x"
  end
end
find(gem_name) click to toggle source
# File lib/gemdiff/cli.rb, line 17
def find(gem_name)
  outdated_gem = OutdatedGem.new(gem_name)
  if outdated_gem.repo?
    puts outdated_gem.repo
  else
    puts "Could not find github repository for #{gem_name}."
  end
  outdated_gem
end
list() click to toggle source
# File lib/gemdiff/cli.rb, line 80
def list
  puts CHECKING_FOR_OUTDATED
  inspector = BundleInspector.new
  puts inspector.outdated
  puts "\n"
  inspector.list.each do |outdated_gem|
    puts outdated_gem.compare_message
    puts outdated_gem.compare_url
    puts "\n"
  end
end
main(gem_name) click to toggle source
# File lib/gemdiff/cli.rb, line 38
def main(gem_name)
  find(gem_name).main
end
open(gem_name) click to toggle source
# File lib/gemdiff/cli.rb, line 28
def open(gem_name)
  find(gem_name).open
end
releases(gem_name) click to toggle source
# File lib/gemdiff/cli.rb, line 33
def releases(gem_name)
  find(gem_name).releases
end
update(name) click to toggle source
# File lib/gemdiff/cli.rb, line 93
def update(name)
  gem_updater = GemUpdater.new(name)
  puts WORKING_DIRECTORY_IS_NOT_CLEAN unless gem_updater.clean?
  puts "Updating #{name}..."
  gem_updater.update
  diff_output = colorize_git_output(gem_updater.diff)
  puts diff_output
  if diff_output.empty?
    puts NOTHING_TO_UPDATE
    return
  end
  response = ask("\nCommit? (c to commit, r to reset, else do nothing)")
  case response
  when "c"
    gem_updater.commit
    puts "\n#{colorize_git_output(gem_updater.show)}"
  when "r"
    puts gem_updater.reset
  end
end