Updated

features/support / pickle_extensions.rb

A
52 lines of codes
4 methods
9.5 complexity/method
1 churn
38.19 complexity
0 duplications
require File.expand_path(File.join(File.dirname(__FILE__), 'pickle')) module Pickle class Parser
  1. Pickle::Parser has no descriptive comment
@@rb_language = nil
  1. Pickle::Parser declares the class variable '@@rb_language' Locations: 0 1 2 3 4
def set_rb_language
  1. Pickle::Parser#set_rb_language doesn't depend on instance state (maybe move it to another class?)
return if @@rb_language
  1. Pickle::Parser declares the class variable '@@rb_language' Locations: 0 1 2 3 4
@@rb_language = Cucumber::RbSupport::RbDsl.instance_variable_get('@rb_language') ||
  1. Pickle::Parser declares the class variable '@@rb_language' Locations: 0 1 2 3 4
:undefined end def execute_transforms(arg) set_rb_language if @@rb_language == :undefined
  1. Pickle::Parser declares the class variable '@@rb_language' Locations: 0 1 2 3 4
arg else @@rb_language.execute_transforms([arg]).first
  1. Pickle::Parser declares the class variable '@@rb_language' Locations: 0 1 2 3 4
end end # given a string like 'foo: expr' returns {key => value} def parse_field_without_model(field) if field =~ /^#{capture_key_and_value_in_field}$/ value = eval($2) if value.respond_to?(:match)
  1. Pickle::Parser#parse_field_without_model manually dispatches method call
value = execute_transforms(value) end { $1 => value } else raise ArgumentError, "The field argument is not in the correct format.\n\n'#{field}' did not match: #{match_field}" end end end end Pickle::Session::Parser.module_eval do def parse_hash(hash) hash.inject({}) do |parsed, (key, val)| if session && val =~ /^#{capture_model}$/ parsed.merge(key => session.model($1)) else if val.respond_to?(:match)
  1. parse_hash manually dispatches method call
parsed.merge(key => execute_transforms(val)) else parsed.merge(key => val) end end end end end