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.
17
18
19
20
21
|
# File 'lib/cucumber/cli/configuration.rb', line 17
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
#out_stream ⇒ Object
Returns the value of attribute out_stream.
15
16
17
|
# File 'lib/cucumber/cli/configuration.rb', line 15
def out_stream
@out_stream
end
|
Instance Method Details
#all_files_to_load ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/cucumber/cli/configuration.rb', line 87
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.sort
end
|
#build_tree_walker(runtime) ⇒ Object
75
76
77
|
# File 'lib/cucumber/cli/configuration.rb', line 75
def build_tree_walker(runtime)
Ast::TreeWalker.new(runtime, formatters(runtime), self)
end
|
#dotcucumber ⇒ Object
67
68
69
|
# File 'lib/cucumber/cli/configuration.rb', line 67
def dotcucumber
@options[:dotcucumber]
end
|
#drb? ⇒ Boolean
51
52
53
|
# File 'lib/cucumber/cli/configuration.rb', line 51
def drb?
@options[:drb]
end
|
55
56
57
|
# File 'lib/cucumber/cli/configuration.rb', line 55
def drb_port
@options[:drb_port].to_i if @options[:drb_port]
end
|
#dry_run? ⇒ Boolean
59
60
61
|
# File 'lib/cucumber/cli/configuration.rb', line 59
def dry_run?
@options[:dry_run]
end
|
#expand? ⇒ Boolean
63
64
65
|
# File 'lib/cucumber/cli/configuration.rb', line 63
def expand?
@options[:expand]
end
|
#feature_dirs ⇒ Object
129
130
131
132
133
|
# File 'lib/cucumber/cli/configuration.rb', line 129
def feature_dirs
dirs = paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
dirs.delete('.') unless paths.include?('.')
with_default_features_path(dirs)
end
|
#feature_files ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/cucumber/cli/configuration.rb', line 112
def feature_files
potential_feature_files = with_default_features_path(paths).map do |path|
path = path.gsub(/\\/, '/') path = path.chomp('/')
if File.directory?(path)
Dir["#{path}/**/*.feature"].sort
elsif path[0..0] == '@' and File.file?(path[1..-1]) IO.read(path[1..-1]).split(/(.*?\.feature.*?) /).collect(&:strip).reject(&:empty?)
else
path
end
end.flatten.uniq
remove_excluded_files_from(potential_feature_files)
potential_feature_files
end
|
147
148
149
|
# File 'lib/cucumber/cli/configuration.rb', line 147
def filters
@options.filters
end
|
151
152
153
|
# File 'lib/cucumber/cli/configuration.rb', line 151
def formats
@options[:formats]
end
|
79
80
81
82
83
84
85
|
# File 'lib/cucumber/cli/configuration.rb', line 79
def formatter_class(format)
if(builtin = Options::BUILTIN_FORMATS[format])
constantize(builtin[0])
else
constantize(format)
end
end
|
#guess? ⇒ Boolean
47
48
49
|
# File 'lib/cucumber/cli/configuration.rb', line 47
def guess?
@options[:guess]
end
|
135
136
137
138
139
140
141
|
# File 'lib/cucumber/cli/configuration.rb', line 135
def log
logger = Logger.new(@out_stream)
logger.formatter = LogFormatter.new
logger.level = Logger::INFO
logger.level = Logger::DEBUG if self.verbose?
logger
end
|
155
156
157
158
|
# File 'lib/cucumber/cli/configuration.rb', line 155
def options
warn("Deprecated: Configuration#options will be removed from the next release of Cucumber. Please use the configuration object directly instead.")
@options
end
|
#parse!(args) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/cucumber/cli/configuration.rb', line 23
def parse!(args)
@args = args
@options.parse!(args)
arrange_formats
raise("You can't use both --strict and --wip") if strict? && wip?
@options[:tag_expression] = Gherkin::TagExpression.new(@options[:tag_expressions])
return @args.replace(@options.expanded_args_without_drb) if drb?
set_environment_variables
end
|
160
161
162
|
# File 'lib/cucumber/cli/configuration.rb', line 160
def paths
@options[:paths]
end
|
#snippet_type ⇒ Object
71
72
73
|
# File 'lib/cucumber/cli/configuration.rb', line 71
def snippet_type
@options[:snippet_type] || :regexp
end
|
#step_defs_to_load ⇒ Object
101
102
103
|
# File 'lib/cucumber/cli/configuration.rb', line 101
def step_defs_to_load
all_files_to_load.reject {|f| f =~ %r{/support/} }
end
|
#strict? ⇒ Boolean
39
40
41
|
# File 'lib/cucumber/cli/configuration.rb', line 39
def strict?
@options[:strict]
end
|
#support_to_load ⇒ Object
105
106
107
108
109
110
|
# File 'lib/cucumber/cli/configuration.rb', line 105
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
|
#tag_expression ⇒ Object
143
144
145
|
# File 'lib/cucumber/cli/configuration.rb', line 143
def tag_expression
Gherkin::TagExpression.new(@options[:tag_expressions])
end
|
#verbose? ⇒ Boolean
35
36
37
|
# File 'lib/cucumber/cli/configuration.rb', line 35
def verbose?
@options[:verbose]
end
|
#wip? ⇒ Boolean
43
44
45
|
# File 'lib/cucumber/cli/configuration.rb', line 43
def wip?
@options[:wip]
end
|