Class: Gemdiff::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gemdiff/cli.rb

Instance Method Summary collapse

Instance Method Details

#compare(gem_name) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gemdiff/cli.rb', line 26

def compare(gem_name)
  repo = find(gem_name)
  old_version = options[:old]
  new_version = options[:new]
  if old_version.nil? || new_version.nil?
    puts "Checking for outdated gems in your bundle..."
    unless (gem = BundleInspector.new.get(gem_name))
      puts "#{gem_name} is not oudated in your bundle. Specify versions."
      return
    end
    old_version ||= gem.old_version
    new_version ||= gem.new_version
  end
  puts "Comparing #{old_version} to #{new_version}"
  `open #{repo}/compare/v#{old_version}...v#{new_version}`
end

#find(gem_name) ⇒ Object



8
9
10
11
12
13
# File 'lib/gemdiff/cli.rb', line 8

def find(gem_name)
  repo = RepoFinder.github_url(gem_name)
  puts "Could not find github repository for #{gem_name}." unless repo
  puts repo
  repo
end

#open(gem_name) ⇒ Object



16
17
18
19
# File 'lib/gemdiff/cli.rb', line 16

def open(gem_name)
  repo = find(gem_name)
  `open #{repo}` if repo
end

#outdatedObject



44
45
46
47
48
49
50
51
# File 'lib/gemdiff/cli.rb', line 44

def outdated
  puts "Checking for outdated gems in your bundle..."
  inspector = BundleInspector.new
  inspector.list.each do |gem|
    # todo
    puts gem.name
  end
end