Class: Hellgrid::CLI
- Inherits:
-
Object
- Object
- Hellgrid::CLI
- Defined in:
- lib/hellgrid/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ CLI
Returns a new instance of CLI.
9 10 11 |
# File 'lib/hellgrid/cli.rb', line 9 def initialize(argv = ARGV) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
13 14 15 |
# File 'lib/hellgrid/cli.rb', line 13 def argv @argv end |
Class Method Details
.start(argv = ARGV) ⇒ Object
5 6 7 |
# File 'lib/hellgrid/cli.rb', line 5 def self.start(argv = ARGV) new(argv).start end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hellgrid/cli.rb', line 15 def start recursive_search = !argv.delete('-r').nil? transpose = !argv.delete('-t').nil? folders = argv.empty? ? [Dir.pwd] : argv folders.each do |folder| matrix = Hellgrid::Matrix.new Find.find(folder) do |path| if File.directory?(path) && File.exist?(File.join(path, 'Gemfile.lock')) matrix.add_project(Hellgrid::Project.new(folder, path)) Find.prune unless recursive_search end end data = matrix.sorted_by_most_used data = data.transpose if transpose view = Hellgrid::Views::Console.new(data) view.render end end |