reality-naming 1.2.0 → 1.3.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: cfe916408ebc1e478e4c776c2d65f163a558503f
4
- data.tar.gz: 8088e2043ab77f983b86d5944e8181bb6bc74f2a
3
+ metadata.gz: 98022429208fe3e56df3aa63e04d05bc9d0404de
4
+ data.tar.gz: 30739b8f989d62c9cd7c41e12033233d3d4c349c
5
5
  SHA512:
6
- metadata.gz: 18091b60bb70bcd67ff0fb85b6b69caad4f35e38d554a7f40ded04fec561a2d21d788eaa1c547fcd720da08e8f55374622c3d5ecc8d8aa9d4c7bde1bc6bcf210
7
- data.tar.gz: 19f6047526676622c94a95ed0af09ca50e650bfdf0d0b0b144a02548d4c43873fb1b3ae5d8ff2b886f57886353d7570fd935a34577f6cd80adc020f20d8eae5e
6
+ metadata.gz: fc453495f12e4286e2c401c1726b9cceecd88d0a0f0b761d3ac831d50e40cf26e28cda001271b6db764c10e950dc184f99cc9734a160e51f890a28b69cc728a8
7
+ data.tar.gz: 4f8b8af968cfaabb11aba3eafdbcc034c0e9748a84732306f10d18b76ea13f27bd310621d12cc9c68aa703adb32a8d58fa55eb46a8ba7a32dd01298f10abfc6c
@@ -21,7 +21,7 @@ module Reality
21
21
  end
22
22
 
23
23
  def camelize(input_word)
24
- word_parts = split_into_words(input_word).collect { |part| part[0...1].upcase + part[1..-1] }
24
+ word_parts = split_into_words(input_word, true).collect { |part| part[0...1].upcase + part[1..-1] }
25
25
  return word_parts[0].downcase if (word_parts.size == 1 && word_parts[0] == word_parts[0].upcase)
26
26
  word = word_parts.join('')
27
27
  word[0...1].downcase + word[1..-1]
@@ -104,12 +104,13 @@ module Reality
104
104
  pluralization_rules.clear
105
105
  end
106
106
 
107
- def split_into_words(word)
107
+ def split_into_words(word, downcase_all_upcased_words = false)
108
108
  word = word.to_s.dup
109
109
  word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
110
110
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
111
111
  word.tr!('-', '_')
112
- word.split('_').collect{|w| w.upcase == w && w != 'ID' ? w.downcase : w }
112
+ result = word.split('_')
113
+ downcase_all_upcased_words ? result.collect{|w| w.upcase == w ? w.downcase : w } : result
113
114
  end
114
115
 
115
116
  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.2.0'
5
+ s.version = '1.3.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
data/test/test_naming.rb CHANGED
@@ -39,8 +39,8 @@ class TestNaming < Reality::Naming::TestCase
39
39
  assert_equal Reality::Naming.pascal_case('ThisIsCamelCased'), 'ThisIsCamelCased'
40
40
  assert_equal Reality::Naming.pascal_case('this_Is_Camel_Cased'), 'ThisIsCamelCased'
41
41
  assert_equal Reality::Naming.pascal_case('this_Is_camel_cased'), 'ThisIsCamelCased'
42
- assert_equal Reality::Naming.pascal_case('EJB'), 'Ejb'
43
- assert_equal Reality::Naming.pascal_case('EJBContainer'), 'EjbContainer'
42
+ assert_equal Reality::Naming.pascal_case('EJB'), 'EJB'
43
+ assert_equal Reality::Naming.pascal_case('EJBContainer'), 'EJBContainer'
44
44
 
45
45
  assert_equal Reality::Naming.pascal_case?('FindByID'), true
46
46
 
@@ -78,7 +78,8 @@ class TestNaming < Reality::Naming::TestCase
78
78
  assert_equal %w(My Support Library), Reality::Naming.split_into_words('MySupportLibrary')
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
- assert_equal %w(my support library), Reality::Naming.split_into_words('MY_SUPPORT_LIBRARY')
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)
82
83
 
83
84
  # ID is specially handled
84
85
  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.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald