module FlavoredGherkin

Flavored Gherkin

Public Class Methods

build(options = {}) click to toggle source

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() { |options| ... } click to toggle source

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
feature_files() click to toggle source

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
feature_path=(feature_path) click to toggle source

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
flavour() click to toggle source

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
flavour=(flavour) click to toggle source

Set Flavored Gherkin Flavour

@param [String] flavour Flavored Gherkin Flavour

Example:

FlavoredGherkin.flavour = 'HtmlFlavour'
# File lib/flavored_gherkin.rb, line 51
def self.flavour=(flavour)
  @options ||= {}
  @options[:flavour] = flavour.capitalize
end
input_path=(input_path) click to toggle source

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
output_path() click to toggle source

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
output_path=(output_path) click to toggle source

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(option, value) click to toggle source

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
title() click to toggle source

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
title=(title) click to toggle source

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