# File lib/cucumber/cli/configuration.rb, line 17
17: def initialize(out_stream = STDOUT, error_stream = STDERR)
18: @out_stream = out_stream
19: @error_stream = error_stream
20: @options = Options.new(@out_stream, @error_stream, :default_profile => 'default')
21: end
# File lib/cucumber/cli/configuration.rb, line 71
71: def all_files_to_load
72: requires = @options[:require].empty? ? require_dirs : @options[:require]
73: files = requires.map do |path|
74: path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
75: path = path.gsub(/\/$/, '') # Strip trailing slash.
76: File.directory?(path) ? Dir["#{path}/**/*"] : path
77: end.flatten.uniq
78: remove_excluded_files_from(files)
79: files.reject! {|f| !File.file?(f)}
80: files.reject! {|f| File.extname(f) == '.feature' }
81: files.reject! {|f| f =~ /^http/}
82: files.sort
83: end
# File lib/cucumber/cli/configuration.rb, line 59
59: def build_runner(step_mother, io)
60: Ast::TreeWalker.new(step_mother, formatters(step_mother), @options, io)
61: end
# File lib/cucumber/cli/configuration.rb, line 51
51: def drb?
52: @options[:drb]
53: end
# File lib/cucumber/cli/configuration.rb, line 55
55: def drb_port
56: @options[:drb_port].to_i if @options[:drb_port]
57: end
# File lib/cucumber/cli/configuration.rb, line 113
113: def feature_dirs
114: paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
115: end
# File lib/cucumber/cli/configuration.rb, line 96
96: def feature_files
97: potential_feature_files = paths.map do |path|
98: path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
99: path = path.chomp('/')
100: if File.directory?(path)
101: Dir["#{path}/**/*.feature"]
102: elsif path[0..0] == '@' and # @listfile.txt
103: File.file?(path[1..1]) # listfile.txt is a file
104: IO.read(path[1..1]).split
105: else
106: path
107: end
108: end.flatten.uniq
109: remove_excluded_files_from(potential_feature_files)
110: potential_feature_files
111: end
# File lib/cucumber/cli/configuration.rb, line 63
63: def formatter_class(format)
64: if(builtin = Options::BUILTIN_FORMATS[format])
65: constantize(builtin[0])
66: else
67: constantize(format)
68: end
69: end
# File lib/cucumber/cli/configuration.rb, line 47
47: def guess?
48: @options[:guess]
49: end
# File lib/cucumber/cli/configuration.rb, line 117
117: def log
118: logger = Logger.new(@out_stream)
119: logger.formatter = LogFormatter.new
120: logger.level = Logger::INFO
121: logger.level = Logger::DEBUG if self.verbose?
122: logger
123: end
# File lib/cucumber/cli/configuration.rb, line 23
23: def parse!(args)
24: @args = args
25: @options.parse!(args)
26: arrange_formats
27: raise("You can't use both --strict and --wip") if strict? && wip?
28:
29: @options[:tag_expression] = Gherkin::TagExpression.new(@options[:tag_expressions])
30: return @args.replace(@options.expanded_args_without_drb) if drb?
31:
32: set_environment_variables
33: end
# File lib/cucumber/cli/configuration.rb, line 85
85: def step_defs_to_load
86: all_files_to_load.reject {|f| f =~ %{/support/} }
87: end
# File lib/cucumber/cli/configuration.rb, line 39
39: def strict?
40: @options[:strict]
41: end
# File lib/cucumber/cli/configuration.rb, line 89
89: def support_to_load
90: support_files = all_files_to_load.select {|f| f =~ %{/support/} }
91: env_files = support_files.select {|f| f =~ %{/support/env\..*} }
92: other_files = support_files - env_files
93: @options[:dry_run] ? other_files : env_files + other_files
94: end
# File lib/cucumber/cli/configuration.rb, line 164
164: def arrange_formats
165: @options[:formats] << ['pretty', @out_stream] if @options[:formats].empty?
166: @options[:formats] = @options[:formats].sort_by{|f| f[1] == @out_stream ? 1 : 1}
167: streams = @options[:formats].map { |(_, stream)| stream }
168: if streams != streams.uniq
169: raise "All but one formatter must use --out, only one can print to each stream (or STDOUT)"
170: end
171: end
# File lib/cucumber/cli/configuration.rb, line 127
127: def formatters(step_mother)
128: # TODO: We should remove the autoformat functionality. That
129: # can be done with the gherkin CLI.
130: if @options[:autoformat]
131: require 'cucumber/formatter/pretty'
132: return [Formatter::Pretty.new(step_mother, nil, @options)]
133: end
134:
135: @options[:formats].map do |format_and_out|
136: format = format_and_out[0]
137: path_or_io = format_and_out[1]
138: begin
139: formatter_class = formatter_class(format)
140: formatter_class.new(step_mother, path_or_io, @options)
141: rescue Exception => e
142: e.message << "\nError creating formatter: #{format}"
143: raise e
144: end
145: end
146: end
# File lib/cucumber/cli/configuration.rb, line 154
154: def paths
155: @options[:paths].empty? ? ['features'] : @options[:paths]
156: end
# File lib/cucumber/cli/configuration.rb, line 173
173: def remove_excluded_files_from(files)
174: files.reject! {|path| @options[:excludes].detect {|pattern| path =~ pattern } }
175: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.