Class: Cucumber::Cli::Configuration
Defined Under Namespace
Classes: LogFormatter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#constantize, #underscore
Constructor Details
#initialize(out_stream = STDOUT, error_stream = STDERR) ⇒ Configuration
Returns a new instance of Configuration.
16
17
18
19
20
|
# File 'lib/cucumber/cli/configuration.rb', line 16
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
Returns the value of attribute options.
14
15
16
|
# File 'lib/cucumber/cli/configuration.rb', line 14
def options
@options
end
|
#out_stream ⇒ Object
Returns the value of attribute out_stream.
14
15
16
|
# File 'lib/cucumber/cli/configuration.rb', line 14
def out_stream
@out_stream
end
|
Instance Method Details
#all_files_to_load ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/cucumber/cli/configuration.rb', line 98
def all_files_to_load
requires = @options[:require].empty? ? require_dirs : @options[:require]
files = requires.map do |path|
path = path.gsub(/\\/, '/') path = path.gsub(/\/$/, '') File.directory?(path) ? Dir["#{path}/**/*"] : path
end.flatten.uniq
remove_excluded_files_from(files)
files.reject! {|f| !File.file?(f)}
files.reject! {|f| File.extname(f) == '.feature' }
files.reject! {|f| f =~ /^http/}
files
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/cucumber/cli/configuration.rb', line 61
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 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.message << "\nError creating formatter: #{format}"
raise e
end
end
broadcaster = Broadcaster.new(formatters)
broadcaster.options = @options
return broadcaster
end
|
#diff_enabled? ⇒ Boolean
49
50
51
|
# File 'lib/cucumber/cli/configuration.rb', line 49
def diff_enabled?
@options[:diff_enabled]
end
|
#drb? ⇒ Boolean
53
54
55
|
# File 'lib/cucumber/cli/configuration.rb', line 53
def drb?
@options[:drb]
end
|
57
58
59
|
# File 'lib/cucumber/cli/configuration.rb', line 57
def drb_port
@options[:drb_port].to_i if @options[:drb_port]
end
|
#feature_dirs ⇒ Object
140
141
142
|
# File 'lib/cucumber/cli/configuration.rb', line 140
def feature_dirs
paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
end
|
#feature_files ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/cucumber/cli/configuration.rb', line 123
def feature_files
potential_feature_files = paths.map do |path|
path = path.gsub(/\\/, '/') path = path.chomp('/')
if File.directory?(path)
Dir["#{path}/**/*.feature"]
elsif path[0..0] == '@' and File.file?(path[1..-1]) IO.read(path[1..-1]).split
else
path
end
end.flatten.uniq
remove_excluded_files_from(potential_feature_files)
potential_feature_files
end
|
90
91
92
93
94
95
96
|
# File 'lib/cucumber/cli/configuration.rb', line 90
def formatter_class(format)
if(builtin = Options::BUILTIN_FORMATS[format])
constantize(builtin[0])
else
constantize(format)
end
end
|
#guess? ⇒ Boolean
45
46
47
|
# File 'lib/cucumber/cli/configuration.rb', line 45
def guess?
@options[:guess]
end
|
144
145
146
147
148
149
150
|
# File 'lib/cucumber/cli/configuration.rb', line 144
def log
logger = Logger.new(@out_stream)
logger.formatter = LogFormatter.new
logger.level = Logger::INFO
logger.level = Logger::DEBUG if self.verbose?
logger
end
|
#parse!(args) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/cucumber/cli/configuration.rb', line 22
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.expanded_args_without_drb) if drb?
set_environment_variables
end
|
#step_defs_to_load ⇒ Object
112
113
114
|
# File 'lib/cucumber/cli/configuration.rb', line 112
def step_defs_to_load
all_files_to_load.reject {|f| f =~ %r{/support/} }
end
|
#strict? ⇒ Boolean
37
38
39
|
# File 'lib/cucumber/cli/configuration.rb', line 37
def strict?
@options[:strict]
end
|
#support_to_load ⇒ Object
116
117
118
119
120
121
|
# File 'lib/cucumber/cli/configuration.rb', line 116
def support_to_load
support_files = all_files_to_load.select {|f| f =~ %r{/support/} }
env_files = support_files.select {|f| f =~ %r{/support/env\..*} }
other_files = support_files - env_files
@options[:dry_run] ? other_files : env_files + other_files
end
|
#verbose? ⇒ Boolean
33
34
35
|
# File 'lib/cucumber/cli/configuration.rb', line 33
def verbose?
@options[:verbose]
end
|
#wip? ⇒ Boolean
41
42
43
|
# File 'lib/cucumber/cli/configuration.rb', line 41
def wip?
@options[:wip]
end
|