Module: ConcordionUtility

Instance Method Summary collapse

Methods included from ConcordionConvenience

#methods_for

Methods included from ConcordionStringUtility

#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 ConcordionConstants

#concordion_command_attributes, #supported?

Instance Method Details

#concordion_arguments(name) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/concordion_utility.rb', line 26

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)


67
68
69
# File 'lib/concordion_utility.rb', line 67

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

#concordion_cmd_attr_for(elem) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/concordion_utility.rb', line 71

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



57
58
59
60
61
62
63
# File 'lib/concordion_utility.rb', line 57

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



45
46
47
48
49
50
51
# File 'lib/concordion_utility.rb', line 45

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)


53
54
55
# File 'lib/concordion_utility.rb', line 53

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

#instrumentation(attr) ⇒ Object



17
18
19
# File 'lib/concordion_utility.rb', line 17

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

#supported_and_instrumented?(key) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/concordion_utility.rb', line 22

def supported_and_instrumented?(key)
  supported?(key) and instrumented?(key)
end