Module: FlavoredGherkin
- Defined in:
- lib/flavored_gherkin.rb,
lib/flavored_gherkin/flavour.rb,
lib/flavored_gherkin/html_flavour.rb
Overview
Flavored Gherkin
Defined Under Namespace
Classes: Flavour, HtmlFlavour
Class Method Summary collapse
-
.build(options = {}) ⇒ Object
Build Flavored Gherkin.
-
.configure {|options| ... } ⇒ Object
Configure Flavored Gherkin.
-
.feature_files ⇒ Array
Returns List of Feature Files.
-
.feature_path=(feature_path) ⇒ Object
Set Feature Files Path.
-
.flavour ⇒ String
Returns Favour of Flavored Gherkin.
-
.flavour=(flavour) ⇒ Object
Set Flavored Gherkin Flavour.
-
.input_path=(input_path) ⇒ Object
Set Feature Files Path.
-
.output_path ⇒ String
Returns Flavored Gherkin Output Path.
-
.output_path=(output_path) ⇒ Object
Set Flavored Gherkin Output Path.
-
.set(option, value) ⇒ Object
Set Flavored Gherkin Options.
-
.title ⇒ String
Returns Title of Flavored Gherkin.
-
.title=(title) ⇒ Object
Set Flavored Gherkin Title.
Class Method Details
.build(options = {}) ⇒ Object
Build Flavored Gherkin
Examples:
FlavoredGherkin.build
FlavoredGherkin.build 'muFolder/features'
FlavoredGherkin.build feature_path: 'muFolder/features', title: 'My Features'
122 123 124 125 126 127 128 129 130 |
# File 'lib/flavored_gherkin.rb', line 122 def self.build( = {}) @options ||= {} if .is_a? String @options[:input_path] = elsif .is_a? Hash @options.merge! end const_get(flavour).new.build title, feature_files, output_path end |
.configure {|options| ... } ⇒ Object
Configure Flavored Gherkin
Example:
FlavoredGherkin.configure do |config|
config.title = 'My Features'
config.feature_path = 'myFolder/features'
config.output_path = 'myFolder/my_features'
end
19 20 21 22 23 24 |
# File 'lib/flavored_gherkin.rb', line 19 def self.configure = OpenStruct.new yield if block_given? @options ||= {} @options.merge! .marshal_dump end |
.feature_files ⇒ Array
Returns List of Feature Files
157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/flavored_gherkin.rb', line 157 def self.feature_files @options ||= {} feature_path = @options[:feature_path] || @options[:input_path] || Dir.pwd if Pathname.new(feature_path).directory? Dir.glob("#{feature_path}/**/*.feature") elsif Pathname.new(feature_path).file? [feature_path] else [] end end |
.feature_path=(feature_path) ⇒ Object
78 79 80 81 |
# File 'lib/flavored_gherkin.rb', line 78 def self.feature_path=(feature_path) @options ||= {} @options[:feature_path] = feature_path end |
.flavour ⇒ String
Returns Favour of Flavored Gherkin
137 138 139 140 |
# File 'lib/flavored_gherkin.rb', line 137 def self.flavour @options ||= {} ['HtmlFlavour'].include?(@options[:flavour]) ? @options[:flavour] : 'HtmlFlavour' end |
.flavour=(flavour) ⇒ Object
50 51 52 53 |
# File 'lib/flavored_gherkin.rb', line 50 def self.flavour=(flavour) @options ||= {} @options[:flavour] = flavour end |
.input_path=(input_path) ⇒ Object
92 93 94 95 |
# File 'lib/flavored_gherkin.rb', line 92 def self.input_path=(input_path) @options ||= {} @options[:input_path] = input_path end |
.output_path ⇒ String
Returns Flavored Gherkin Output Path
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/flavored_gherkin.rb', line 174 def self.output_path @options ||= {} output_path = @options[:output_path] ||= Dir.pwd + '/' if output_path =~ /.*[\/\\]$/ unless Pathname(output_path).exist? FileUtils.mkpath output_path end output_path += title.strip.gsub(' ', '_') end output_path end |
.output_path=(output_path) ⇒ Object
106 107 108 109 |
# File 'lib/flavored_gherkin.rb', line 106 def self.output_path=(output_path) @options ||= {} @options[:output_path] = output_path end |
.set(option, value) ⇒ Object
36 37 38 39 |
# File 'lib/flavored_gherkin.rb', line 36 def self.set(option, value) @options ||= {} @options[option.to_sym] = value end |
.title ⇒ String
Returns Title of Flavored Gherkin
147 148 149 150 |
# File 'lib/flavored_gherkin.rb', line 147 def self.title @options ||= {} @options[:title] || (@options[:feature_path] || @options[:input_path] || 'Gherkin/Flavored').split('/').reverse[0..5].join(' ').gsub('.', '') end |
.title=(title) ⇒ Object
64 65 66 67 |
# File 'lib/flavored_gherkin.rb', line 64 def self.title=(title) @options ||= {} @options[:title] = title end |