reality-naming 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reality/naming.rb +6 -5
- data/reality-naming.gemspec +1 -1
- data/test/test_naming.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 936976f72382f6122e947cfd1819c28c33333e90
|
4
|
+
data.tar.gz: 7ece37c44e828651779dfaf0aed98f6355d73d98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd3abb629d56a226cb936c9c463839ec59fae8f35ec7e040f21808e08659d4429f253d658b646d55d844e9d7e0dc7413b29af0c746ce2095cef74e85a74ac0a
|
7
|
+
data.tar.gz: c765750808bb317c5d62508567813e96b84d66e390050ff924b3de2bdf55552a80188cb6788f7295adc67af428ebf20908201ff1e785f72cb33a0d3739d404ce
|
data/lib/reality/naming.rb
CHANGED
@@ -21,8 +21,10 @@ module Reality
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def camelize(input_word)
|
24
|
-
word_parts = split_into_words(input_word
|
25
|
-
|
24
|
+
word_parts = split_into_words(input_word).collect { |part| part[0...1].upcase + part[1..-1] }
|
25
|
+
if word_parts.size > 0 && word_parts[0] == word_parts[0].upcase
|
26
|
+
word_parts[0] = word_parts[0].downcase
|
27
|
+
end
|
26
28
|
word = word_parts.join('')
|
27
29
|
word[0...1].downcase + word[1..-1]
|
28
30
|
end
|
@@ -104,13 +106,12 @@ module Reality
|
|
104
106
|
pluralization_rules.clear
|
105
107
|
end
|
106
108
|
|
107
|
-
def split_into_words(word
|
109
|
+
def split_into_words(word)
|
108
110
|
word = word.to_s.dup
|
109
111
|
word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
110
112
|
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
111
113
|
word.tr!('-', '_')
|
112
|
-
|
113
|
-
downcase_all_upcased_words ? result.collect{|w| w.upcase == w ? w.downcase : w } : result
|
114
|
+
word.split('_')
|
114
115
|
end
|
115
116
|
|
116
117
|
private
|
data/reality-naming.gemspec
CHANGED
data/test/test_naming.rb
CHANGED
@@ -79,7 +79,6 @@ class TestNaming < Reality::Naming::TestCase
|
|
79
79
|
assert_equal %w(my support library), Reality::Naming.split_into_words('my-support-library')
|
80
80
|
assert_equal %w(my support library), Reality::Naming.split_into_words('my_support_library')
|
81
81
|
assert_equal %w(MY SUPPORT LIBRARY), Reality::Naming.split_into_words('MY_SUPPORT_LIBRARY')
|
82
|
-
assert_equal %w(my support library), Reality::Naming.split_into_words('MY_SUPPORT_LIBRARY', true)
|
83
82
|
|
84
83
|
# ID is specially handled
|
85
84
|
assert_equal %w(Find By ID), Reality::Naming.split_into_words('FindByID')
|