Module: FlavoredGherkin
- Defined in:
- lib/flavored_gherkin.rb,
lib/flavored_gherkin/flavour.rb,
lib/flavored_gherkin/pdf_flavour.rb,
lib/flavored_gherkin/html_flavour.rb
Overview
Flavored Gherkin
Defined Under Namespace
Classes: Flavour, HtmlFlavour, PdfFlavour
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'
123 124 125 126 127 128 129 130 131 |
# File 'lib/flavored_gherkin.rb', line 123 def self.build( = {}) @options ||= {} if .is_a? String @options[:input_path] = elsif .is_a? Hash @options.merge! end const_get(flavour + '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
20 21 22 23 24 25 |
# File 'lib/flavored_gherkin.rb', line 20 def self.configure = OpenStruct.new yield if block_given? @options ||= {} @options.merge! .marshal_dump end |
.feature_files ⇒ Array
Returns List of Feature Files
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/flavored_gherkin.rb', line 158 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
79 80 81 82 |
# File 'lib/flavored_gherkin.rb', line 79 def self.feature_path=(feature_path) @options ||= {} @options[:feature_path] = feature_path end |
.flavour ⇒ String
Returns Favour of Flavored Gherkin
138 139 140 141 |
# File 'lib/flavored_gherkin.rb', line 138 def self.flavour @options ||= {} %w[Html Pdf].include?(@options[:flavour]) ? @options[:flavour] : 'Html' end |
.flavour=(flavour) ⇒ Object
51 52 53 54 |
# File 'lib/flavored_gherkin.rb', line 51 def self.flavour=(flavour) @options ||= {} @options[:flavour] = flavour.capitalize end |
.input_path=(input_path) ⇒ Object
93 94 95 96 |
# File 'lib/flavored_gherkin.rb', line 93 def self.input_path=(input_path) @options ||= {} @options[:input_path] = input_path end |
.output_path ⇒ String
Returns Flavored Gherkin Output Path
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/flavored_gherkin.rb', line 175 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
107 108 109 110 |
# File 'lib/flavored_gherkin.rb', line 107 def self.output_path=(output_path) @options ||= {} @options[:output_path] = output_path end |
.set(option, value) ⇒ Object
37 38 39 40 |
# File 'lib/flavored_gherkin.rb', line 37 def self.set(option, value) @options ||= {} @options[option.to_sym] = value end |
.title ⇒ String
Returns Title of Flavored Gherkin
148 149 150 151 |
# File 'lib/flavored_gherkin.rb', line 148 def self.title @options ||= {} @options[:title] || (@options[:feature_path] || @options[:input_path] || 'Gherkin/Flavored').split('/').reverse[0..5].join(' ').delete('.') end |
.title=(title) ⇒ Object
65 66 67 68 |
# File 'lib/flavored_gherkin.rb', line 65 def self.title=(title) @options ||= {} @options[:title] = title end |