Module: ConcordionStringUtility
Instance Method Summary
collapse
#singular
#snake_case, #snake_cased_goldmaster_name, #snake_cased_test_name
Instance Method Details
#assignment(base) ⇒ Object
89
90
91
|
# File 'lib/concordion_string_utility.rb', line 89
def assignment(base)
base.split("=")[1].strip
end
|
#attr_writer_method?(name) ⇒ Boolean
56
57
58
|
# File 'lib/concordion_string_utility.rb', line 56
def attr_writer_method?(name)
name =~ /=$/
end
|
#concordion_assignment(name) ⇒ Object
48
49
50
|
# File 'lib/concordion_string_utility.rb', line 48
def concordion_assignment(name)
name.split("=")[0].strip
end
|
#concordion_method_name(name) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/concordion_string_utility.rb', line 60
def concordion_method_name(name)
if name =~ /\(/
base = name.split("(")[0].strip
else
base = name.strip
if base =~ /\s/
if base =~ /=/ && base =~ /^#/
base = base.split("=")[1].strip
end
elements = base.split(/\s/)
base = elements[0]
end
end
if !has_assignment?(base)
return base
end
if attr_writer_method?(base)
return base if base.count("=") == 1
return assignment(base) + "="
end
assignment(base)
end
|
#ends_in_empty_parens?(name) ⇒ Boolean
44
45
46
|
# File 'lib/concordion_string_utility.rb', line 44
def ends_in_empty_parens?(name)
name =~ /\(\)$/
end
|
#escape_single_quotes(s) ⇒ Object
93
94
95
|
# File 'lib/concordion_string_utility.rb', line 93
def escape_single_quotes(s)
s.gsub(/[']/, '\\\\\\\\\'')
end
|
#has_arguments?(name) ⇒ Boolean
36
37
38
|
# File 'lib/concordion_string_utility.rb', line 36
def has_arguments?(name)
!(ends_in_empty_parens?(name) || is_direct_method_call?(name))
end
|
#has_assignment?(name) ⇒ Boolean
52
53
54
|
# File 'lib/concordion_string_utility.rb', line 52
def has_assignment?(name)
name =~ /=/
end
|
#is_direct_method_call?(name) ⇒ Boolean
40
41
42
|
# File 'lib/concordion_string_utility.rb', line 40
def is_direct_method_call?(name)
name =~ /^[\w]+$/
end
|