Class: BundleOutdated::Searcher
- Inherits:
-
Object
- Object
- BundleOutdated::Searcher
- Defined in:
- lib/bundle_outdated/searcher.rb
Defined Under Namespace
Classes: GemfileNotFound
Instance Method Summary collapse
- #all_gems ⇒ Object
- #gemfile ⇒ Object
- #handwaving_gems ⇒ Object
- #outdated_gems ⇒ Object
- #search! ⇒ Object
Instance Method Details
#all_gems ⇒ Object
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 |
#gemfile ⇒ Object
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_gems ⇒ Object
34 35 36 |
# File 'lib/bundle_outdated/searcher.rb', line 34 def handwaving_gems @handwaving_gems ||= all_gems.find_all(&:handwaving?) end |
#outdated_gems ⇒ Object
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 |