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.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/spinach/cli.rb', line 50 def feature_files files_to_run = [] @args.each do |arg| if arg.match(/\.feature/) if File.exists? 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')) else 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.
38 39 40 |
# File 'lib/spinach/cli.rb', line 38 def @options ||= end |