class AutomationObject::StepDefinitions::Parse

Class to parse arguments passed through step definitions

Public Class Methods

new(args) click to toggle source

@param args [Array] input args from step definition

# File lib/automation_object/step_definitions/support/parse.rb, line 9
def initialize(args)
  @args = args
end

Public Instance Methods

get() click to toggle source
# File lib/automation_object/step_definitions/support/parse.rb, line 13
def get
  parsed_args = []
  @args.each do |arg|
    parsed_args.push(parse(arg))
  end

  parsed_args
end

Private Instance Methods

parse(string) click to toggle source

Used to parse any embedded variables @param string [String, nil] index of arg @return [String] parsed string

# File lib/automation_object/step_definitions/support/parse.rb, line 27
def parse(string)
  return string if string.nil?

  string.scan(/%\{[\w]+\}/) do |cache_key|
    unwrapped_cache_key = cache_key.gsub(/[%\{\}]/, '')

    cached_value = AutomationObject::StepDefinitions::Cache.get(unwrapped_cache_key)
    return cached_value if cached_value
  end

  string
end