Class: Pelusa::Cli
- Inherits:
-
Object
- Object
- Pelusa::Cli
- Defined in:
- lib/pelusa/cli.rb
Overview
The cli is a class responsible of handling all the command line interface logic.
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(args = ARGV) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(args = ARGV) ⇒ Cli
Returns a new instance of Cli.
6 7 8 |
# File 'lib/pelusa/cli.rb', line 6 def initialize(args=ARGV) @args = args end |
Instance Method Details
#files ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/pelusa/cli.rb', line 29 def files if glob = @args.detect { |arg| arg =~ /\*/ } return Dir[glob] end _files = @args.select { |arg| arg =~ /\.rb/ } _files = Dir[Pelusa.configuration.sources] if _files.empty? _files end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pelusa/cli.rb', line 10 def run _files = files if _files.empty? warn "\n No files specified -- PROCESS ALL THE FILES!\n" _files = Dir["**/*.rb"] end reporters = Pelusa.run(_files) reporters.first.class. unless reporters.empty? exit_code = 0 reporters.each do |reporter| reporter.report exit_code = 1 unless reporter.successful? end exit_code end |