reality-naming 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98022429208fe3e56df3aa63e04d05bc9d0404de
4
- data.tar.gz: 30739b8f989d62c9cd7c41e12033233d3d4c349c
3
+ metadata.gz: 936976f72382f6122e947cfd1819c28c33333e90
4
+ data.tar.gz: 7ece37c44e828651779dfaf0aed98f6355d73d98
5
5
  SHA512:
6
- metadata.gz: fc453495f12e4286e2c401c1726b9cceecd88d0a0f0b761d3ac831d50e40cf26e28cda001271b6db764c10e950dc184f99cc9734a160e51f890a28b69cc728a8
7
- data.tar.gz: 4f8b8af968cfaabb11aba3eafdbcc034c0e9748a84732306f10d18b76ea13f27bd310621d12cc9c68aa703adb32a8d58fa55eb46a8ba7a32dd01298f10abfc6c
6
+ metadata.gz: fbd3abb629d56a226cb936c9c463839ec59fae8f35ec7e040f21808e08659d4429f253d658b646d55d844e9d7e0dc7413b29af0c746ce2095cef74e85a74ac0a
7
+ data.tar.gz: c765750808bb317c5d62508567813e96b84d66e390050ff924b3de2bdf55552a80188cb6788f7295adc67af428ebf20908201ff1e785f72cb33a0d3739d404ce
@@ -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, true).collect { |part| part[0...1].upcase + part[1..-1] }
25
- return word_parts[0].downcase if (word_parts.size == 1 && word_parts[0] == word_parts[0].upcase)
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, downcase_all_upcased_words = false)
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
- result = word.split('_')
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reality-naming}
5
- s.version = '1.3.0'
5
+ s.version = '1.4.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reality-naming
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald