Class: BundleOutdated::Searcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_outdated/searcher.rb

Defined Under Namespace

Classes: GemfileNotFound

Instance Method Summary collapse

Instance Method Details

#all_gemsObject



46
47
48
49
50
# File 'lib/bundle_outdated/searcher.rb', line 46

def all_gems
  @all_gems ||= gemfile.grep(/^\s*gem\b/).collect do |gem|
    GemDependency.new gem
  end
end

#gemfileObject



38
39
40
41
42
43
44
# File 'lib/bundle_outdated/searcher.rb', line 38

def gemfile
  unless File.exists?('Gemfile')
    raise GemfileNotFound, 'Gemfile not found! Please re-run in your Ruby project directory.'
  end

  @gemfile ||= File.read('Gemfile').split(/\n/)
end

#handwaving_gemsObject



34
35
36
# File 'lib/bundle_outdated/searcher.rb', line 34

def handwaving_gems
  @handwaving_gems ||= all_gems.find_all(&:handwaving?)
end

#outdated_gemsObject



30
31
32
# File 'lib/bundle_outdated/searcher.rb', line 30

def outdated_gems
  @outdated_gems ||= all_gems.find_all(&:outdated?)
end

#search!Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bundle_outdated/searcher.rb', line 5

def search!
  puts "Finding outdated gems.."

  unless outdated_gems.empty?
    puts "\nNewer versions found for:"
    outdated_gems.each do |gem|
      puts "  #{gem.name} (#{gem.latest_version} > #{gem.version})"
    end

    puts "\nLock bundle to these versions by putting the following in your Gemfile:"
    outdated_gems.each do |gem|
      puts "  gem '#{gem.name}', '#{gem.latest_version}'"
    end
  end

  unless handwaving_gems.empty?
    puts "\nYou may try to update non-specific dependencies via:"
    puts "  $ bundle update #{handwaving_gems.collect(&:name).join(' ')}"
    puts "\nHandwaving specifications:"
    handwaving_gems.collect do |g|
      puts "  #{g.name}: #{ [ g.handwaving, g.version ].join(' ') }"
     end
  end
end