Class: Spinach::Cli
- Inherits:
-
Object
- Object
- Spinach::Cli
- Defined in:
- lib/spinach/cli.rb
Overview
The cli is a class responsible of handling all the command line interface logic.
Instance Method Summary collapse
-
#feature_files ⇒ Array
Uses given args to list the feature files to run.
-
#initialize(args = ARGV) ⇒ Cli
constructor
A new instance of Cli.
-
#options ⇒ Hash
A hash of options separated by its type.
-
#run ⇒ true, false
Runs all the features.
Constructor Details
#initialize(args = ARGV) ⇒ Cli
Returns a new instance of Cli.
12 13 14 |
# File 'lib/spinach/cli.rb', line 12 def initialize(args = ARGV) @args = args end |
Instance Method Details
#feature_files ⇒ Array
Uses given args to list the feature files to run. It will find a single feature, features in a folder and subfolders or every feature file in the feature path.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/spinach/cli.rb', line 54 def feature_files files_to_run = [] @args.each do |arg| if arg.match(/\.feature/) if File.exist? arg.gsub(/:\d*/, '') files_to_run << arg else fail! "#{arg} could not be found" end elsif File.directory?(arg) files_to_run << Dir.glob(File.join(arg, '**', '*.feature')) elsif arg != "{}" fail! "invalid argument - #{arg}" end end if !files_to_run.empty? files_to_run.flatten else Dir.glob(File.join(Spinach.config[:features_path], '**', '*.feature')) end end |
#options ⇒ Hash
Returns A hash of options separated by its type.
42 43 44 |
# File 'lib/spinach/cli.rb', line 42 def @options ||= end |
#run ⇒ true, false
Runs all the features.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spinach/cli.rb', line 22 def run if Spinach.config.generate Spinach::Generators.run(feature_files) elsif Spinach.config.audit Spinach::Auditor.new(feature_files).run else Spinach::Runner.new(feature_files).run end end |