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)
-
- (Array) feature_files
Uses given args to list the feature files to run.
-
- (Cli) initialize(args = ARGV)
constructor
A new instance of Cli.
-
- (Hash) options
A hash of options separated by its type.
-
- (true, false) run
Runs all the features.
Constructor Details
- (Cli) initialize(args = ARGV)
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
- (Array) feature_files
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 |
- (Hash) options
A hash of options separated by its type.
38 39 40 |
# File 'lib/spinach/cli.rb', line 38 def @options ||= end |
- (true, false) run
Runs all the features.
22 23 24 25 26 27 28 |
# File 'lib/spinach/cli.rb', line 22 def run return true if Spinach.config.generate Spinach::Runner.new(feature_files).run end |