Class: BrewDG::CLI
- Inherits:
-
Object
- Object
- BrewDG::CLI
- Defined in:
- lib/brew_dg/cli.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(argv, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(argv, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/brew_dg/cli.rb', line 7 def initialize(argv, stdout = STDOUT, stderr = STDERR, kernel = Kernel) @argv = argv @stdout = stdout @stderr = stderr @kernel = kernel @configuration = OptionParser.new.parse(@argv). if @argv.any? @packages = @argv end end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
19 20 21 |
# File 'lib/brew_dg/cli.rb', line 19 def configuration @configuration end |
Instance Method Details
#execute! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/brew_dg/cli.rb', line 21 def execute! = {} if configuration[:types] .update(relevant_dependency_types: configuration[:types]) end if @packages .update(packages: @packages) end library = Library.new() if configuration[:destination] graph = library.graph if configuration[:inverted] visualization = graph.reversal.visualization else visualization = graph.visualization end visualization.output(png: configuration[:destination]) else @stdout.puts library.installation_order.join(' ') end end |