Module: Concordion::Utility

Includes:
Constants, StringUtility
Included in:
Binder, InternalTestMethods, Invoker, ParseResult, Parser, Processor, State, Verifier
Defined in:
lib/concordion/utility.rb

Instance Method Summary collapse

Methods included from StringUtility

#assignment, #attr_writer_method?, #concordion_assignment, #concordion_method_name, #ends_in_empty_parens?, #escape_single_quotes, #has_arguments?, #has_assignment?, #is_direct_method_call?

Methods included from PluralToSingularUtility

#singular

Methods included from SnakeCaseUtility

#snake_case, #snake_cased_goldmaster_name, #snake_cased_test_name

Methods included from Constants

#concordion_command_attributes, #supported?

Instance Method Details

#concordion_arguments(name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/concordion/utility.rb', line 14

def concordion_arguments(name)
  return [] unless has_arguments?(name)
  arg_string = nil
  if name =~ /\(/
    name_no_end_paren = name.gsub(")", '')
    arg_string = name_no_end_paren.split("(")[1]
  else
  
    base = name.strip
    if base =~ /=/
      arg_string = nil
      base = base.split("=")[1].strip
    end
    tokens = base.split(" ").compact
    arg_string = tokens.slice(1, tokens.size - 1).join(" ")
  end

  arg_string.split(",").collect { |arg| arg.strip }
end

#concordion_cmd_attr_exists?(elem) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/concordion/utility.rb', line 56

def concordion_cmd_attr_exists?(elem)
  !concordion_cmd_attr_for(elem).nil?
end

#concordion_cmd_attr_for(elem) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/concordion/utility.rb', line 60

def concordion_cmd_attr_for(elem)
  concordion_command_attributes.each {|attr| 
    instrumented_value = elem.get_attribute(attr)
    if !instrumented_value.nil?
      return attr
    end
  }

  nil
end

#concordion_property_reference(conc_call) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/concordion/utility.rb', line 46

def concordion_property_reference(conc_call)
  if !has_property_reference?(conc_call)
    return conc_call
  end
  idx = conc_call.index(".")
  conc_call.slice(idx + 1, conc_call.length - idx).strip
end

#concordion_variable_name(conc_call) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/concordion/utility.rb', line 34

def concordion_variable_name(conc_call)
  if has_property_reference?(conc_call)
    return conc_call.split(".")[0].strip
  end

  conc_call.strip
end

#has_property_reference?(conc_call) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/concordion/utility.rb', line 42

def has_property_reference?(conc_call)
  conc_call =~ /\./
end

#instrumentation(attr) ⇒ Object



10
11
12
# File 'lib/concordion/utility.rb', line 10

def instrumentation(attr)
  attr.split(":")[1]
end