class Cucumberator::Parser

Constants

FULL_BACKTRACE

Attributes

last_input[RW]

Public Class Methods

command_runner_for(command) click to toggle source
# File lib/cucumberator/parser.rb, line 31
def command_runner_for(command)
  full_klass_name = "Cucumberator::Commands::#{klass_name_for(command)}"
  constantize(full_klass_name)
end
constantize(camel_cased_word) click to toggle source

copied from ActiveSupport activesupport/lib/active_support/inflector/methods.rb

# File lib/cucumberator/parser.rb, line 49
def constantize(camel_cased_word)
  names = camel_cased_word.split('::')
  names.shift if names.empty? || names.first.empty?

  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end
execute_cucumber_step(input, world) click to toggle source
# File lib/cucumberator/parser.rb, line 40
def execute_cucumber_step(input, world)
  return if input.to_s.empty?

  self.last_input = input
  world.steps(input)
end
klass_name_for(command) click to toggle source
# File lib/cucumberator/parser.rb, line 36
def klass_name_for(command)
  command.scan(/\w+/).map(&:capitalize).join
end
parse_input(input, scenario, step_line, world, saved_stack) click to toggle source
# File lib/cucumberator/parser.rb, line 11
def parse_input(input, scenario, step_line, world, saved_stack)
  if Cucumberator::Commands::AVAILABLE.include?(input)
    runner = command_runner_for(input)
    runner.perform(scenario, step_line, last_input, saved_stack)
  elsif input == ""
    Cucumberator::Commands::Save.save_empty_line(scenario, step_line, saved_stack)
  else
    try_to_execute(input, scenario, step_line, world, saved_stack)
    false
  end
end
try_to_execute(input, scenario, step_line, world, saved_stack) click to toggle source
# File lib/cucumberator/parser.rb, line 23
def try_to_execute(input, scenario, step_line, world, saved_stack)
  execute_cucumber_step(input, world)
  Cucumberator::Commands::Save.perform(scenario, step_line, last_input, saved_stack)
rescue => e
  puts e.inspect
  puts e.backtrace.join("\n") if FULL_BACKTRACE
end