Class: Cucumber::Cli::Configuration
- Defined in:
- lib/cucumber/cli/configuration.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #build_formatter_broadcaster(step_mother) ⇒ Object
- #diff_enabled? ⇒ Boolean
- #drb? ⇒ Boolean
- #feature_files ⇒ Object
- #files_to_require ⇒ Object
- #formatter_class(format) ⇒ Object
- #guess? ⇒ Boolean
-
#initialize(out_stream = STDOUT, error_stream = STDERR) ⇒ Configuration
constructor
A new instance of Configuration.
- #parse!(args) ⇒ Object
- #strict? ⇒ Boolean
- #verbose? ⇒ Boolean
- #wip? ⇒ Boolean
Constructor Details
#initialize(out_stream = STDOUT, error_stream = STDERR) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 |
# File 'lib/cucumber/cli/configuration.rb', line 12 def initialize(out_stream = STDOUT, error_stream = STDERR) @out_stream = out_stream @error_stream = error_stream @options = Options.new(@out_stream, @error_stream, :default_profile => 'default') end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/cucumber/cli/configuration.rb', line 10 def @options end |
Instance Method Details
#build_formatter_broadcaster(step_mother) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cucumber/cli/configuration.rb', line 53 def build_formatter_broadcaster(step_mother) return Formatter::Pretty.new(step_mother, nil, @options) if @options[:autoformat] formatters = @options[:formats].map do |format_and_out| format = format_and_out[0] out = format_and_out[1] if String === out # file name unless File.directory?(out) out = File.open(out, Cucumber.file_mode('w')) at_exit do out.flush out.close end end end begin formatter_class = formatter_class(format) formatter_class.new(step_mother, out, @options) rescue Exception => e e. << "\nError creating formatter: #{format}" raise e end end broadcaster = Broadcaster.new(formatters) broadcaster. = @options return broadcaster end |
#diff_enabled? ⇒ Boolean
45 46 47 |
# File 'lib/cucumber/cli/configuration.rb', line 45 def diff_enabled? @options[:diff_enabled] end |
#drb? ⇒ Boolean
49 50 51 |
# File 'lib/cucumber/cli/configuration.rb', line 49 def drb? @options[:drb] end |
#feature_files ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/cucumber/cli/configuration.rb', line 105 def feature_files potential_feature_files = paths.map do |path| path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes. path = path.chomp('/') File.directory?(path) ? Dir["#{path}/**/*.feature"] : path end.flatten.uniq remove_excluded_files_from(potential_feature_files) potential_feature_files end |
#files_to_require ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cucumber/cli/configuration.rb', line 90 def files_to_require requires = @options[:require].empty? ? require_dirs : @options[:require] files = requires.map do |path| path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes. path = path.gsub(/\/$/, '') # Strip trailing slash. File.directory?(path) ? Dir["#{path}/**/*.rb"] : path end.flatten.uniq sorted_files = files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }.reject{|f| f =~ /^http/} env_files = sorted_files.select {|f| f =~ %r{/support/env.rb} } files = env_files + sorted_files.reject {|f| f =~ %r{/support/env.rb} } remove_excluded_files_from(files) files.reject! {|f| f =~ %r{/support/env.rb} } if @options[:dry_run] files end |
#formatter_class(format) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/cucumber/cli/configuration.rb', line 82 def formatter_class(format) if(builtin = Options::BUILTIN_FORMATS[format]) constantize(builtin[0]) else constantize(format) end end |
#guess? ⇒ Boolean
41 42 43 |
# File 'lib/cucumber/cli/configuration.rb', line 41 def guess? @options[:guess] end |
#parse!(args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cucumber/cli/configuration.rb', line 18 def parse!(args) @args = args @options.parse!(args) arrange_formats raise("You can't use both --strict and --wip") if strict? && wip? return @args.replace(@options.) if drb? set_environment_variables end |
#strict? ⇒ Boolean
33 34 35 |
# File 'lib/cucumber/cli/configuration.rb', line 33 def strict? @options[:strict] end |
#verbose? ⇒ Boolean
29 30 31 |
# File 'lib/cucumber/cli/configuration.rb', line 29 def verbose? @options[:verbose] end |
#wip? ⇒ Boolean
37 38 39 |
# File 'lib/cucumber/cli/configuration.rb', line 37 def wip? @options[:wip] end |