Class: BundleInfo::CommandLine

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

Class Method Summary collapse

Class Method Details

.invoke(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bundle_info.rb', line 9

def self.invoke(args)
  if Dir.glob('*.gemspec').any?
    gemspec_path = Dir.glob('*.gemspec').first
    gemspec = File.open(gemspec_path).read
    gems = Gemnasium::Parser::Gemspec.new(gemspec)
  elsif File.exist?('Gemfile')
    gemfile = File.open('Gemfile').read
    gems = Gemnasium::Parser::Gemfile.new(gemfile)
  else
    puts "No Gemfile or .gemspec found in current directory"
    exit
  end
  gems.dependencies.map do |dep|
    info = Gems.info dep.name
    output = "#{dep.name}:".green
    if info && info['info']
      desc = info['info'].gsub(/\n/, ' ')
      output += " #{desc.truncate(80)}"
    end
    puts output
  end
end