module FlavoredGherkin
Flavored Gherkin
Public Class Methods
Build Flavored Gherkin
Examples:
FlavoredGherkin.build FlavoredGherkin.build 'muFolder/features' FlavoredGherkin.build feature_path: 'muFolder/features', title: 'My Features'
# File lib/flavored_gherkin.rb, line 123 def self.build(options = {}) @options ||= {} if options.is_a? String @options[:input_path] = options elsif options.is_a? Hash @options.merge! options end const_get(flavour + 'Flavour').new.build title, feature_files, output_path end
Configure Flavored Gherkin
Example:
FlavoredGherkin.configure do |config| config.title = 'My Features' config.feature_path = 'myFolder/features' config.output_path = 'myFolder/my_features' end
# File lib/flavored_gherkin.rb, line 20 def self.configure options = OpenStruct.new yield options if block_given? @options ||= {} @options.merge! options.marshal_dump end
Returns List of Feature Files
@return [Array] List of Feature Files
# 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
Set Feature Files Path
@param [String] feature_path feature files path
Example:
FlavoredGherkin.feature_path = 'muFolder/features'
# File lib/flavored_gherkin.rb, line 79 def self.feature_path=(feature_path) @options ||= {} @options[:feature_path] = feature_path end
Returns Favour of Flavored Gherkin
@return [String] Favour
# File lib/flavored_gherkin.rb, line 138 def self.flavour @options ||= {} %w[Html Pdf].include?(@options[:flavour]) ? @options[:flavour] : 'Html' end
Set Feature Files Path
@param [String] input_path feature files path
Example:
FlavoredGherkin.input_path = 'muFolder/features'
# File lib/flavored_gherkin.rb, line 93 def self.input_path=(input_path) @options ||= {} @options[:input_path] = input_path end
Returns Flavored Gherkin Output Path
@return [String] Output Path with file name without extension
# 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
Set Flavored Gherkin Output Path
@param [String] output_path
Flavored Gherkin Output Path
Example:
FlavoredGherkin.output_path = 'myFolder/my_features'
# File lib/flavored_gherkin.rb, line 107 def self.output_path=(output_path) @options ||= {} @options[:output_path] = output_path end
Set Flavored Gherkin Options
@param [String] option @param [String] value
Example:
FlavoredGherkin.set('title', 'My Features')
# File lib/flavored_gherkin.rb, line 37 def self.set(option, value) @options ||= {} @options[option.to_sym] = value end
Returns Title of Flavored Gherkin
@return [String] Title
# 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
Set Flavored Gherkin Title
@param [String] title Flavored Gherkin Title
Example:
FlavoredGherkin.title = 'My Features'
# File lib/flavored_gherkin.rb, line 65 def self.title=(title) @options ||= {} @options[:title] = title end