Class: DependencyRevealer::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile, gemfile_lock, out = $stdout, err = $stderr) ⇒ CLI

Returns a new instance of CLI.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dependency_revealer/cli.rb', line 3

def initialize(gemfile, gemfile_lock, out = $stdout, err = $stderr)
  @out, @err = out, err

  [gemfile, gemfile_lock].map do |file|
    if !File.exists?(file)
      @out.puts self.class.banner
      @out.puts "#{file} not found"
      @out.puts "Quitting..."
      exit 1
    end
  end
  @gemfile, @gemfile_lock = gemfile, gemfile_lock
end

Class Method Details



25
26
27
28
29
30
31
32
33
# File 'lib/dependency_revealer/cli.rb', line 25

def self.banner
  <<-EOBANNER
######################################

Usage: reveal [Gemfile [Gemfile.lock]]

######################################
EOBANNER
end

Instance Method Details

#describe(attributes) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/dependency_revealer/cli.rb', line 17

def describe(attributes)
  attrs = attributes.split(',')
  definition = Bundler::Definition.build(@gemfile, @gemfile_lock, nil)
  definition.specs.map do |spec|
    @out.puts attrs.map { |attr| spec.send(attr) }.join(', ')
  end
end