reality-naming 1.8.0 → 1.9.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 +4 -4
- data/lib/reality/naming.rb +10 -1
- data/reality-naming.gemspec +1 -1
- data/test/test_naming.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2140f2769b939419f3d774e4892f03703a212d61
|
4
|
+
data.tar.gz: ff53a16d8ef385f343cc3472b75955bd3eb17b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44251234a0c7560d8bf19a63b895f9a9be5a1e19282c936bcd8a019a591479271076f934df3c85b34a8b93055353a71d5c8d2e5d037ecb7146dc0d014c57b3f1
|
7
|
+
data.tar.gz: 0a653b93185684f4abfe24fe36499bc0e545afb8a1e033bb4cc867b313e1be8b3cf803c8e4d32d3f6e75ed1d9ae419e33d7b2400fb0b8ffe206c20623b1e3cc8
|
data/lib/reality/naming.rb
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
|
15
15
|
module Reality
|
16
16
|
module Naming
|
17
|
-
|
18
17
|
class << self
|
19
18
|
def camelize?(word)
|
20
19
|
camelize(word) == word.to_s
|
@@ -39,6 +38,16 @@ module Reality
|
|
39
38
|
word_parts.join('')
|
40
39
|
end
|
41
40
|
|
41
|
+
def humanize?(word)
|
42
|
+
humanize(word) == word.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
def humanize(word)
|
46
|
+
word_parts = split_into_words(word).collect { |part| part[0...1].upcase + part[1..-1] }
|
47
|
+
return word_parts[0] if (word_parts.size == 1 && word_parts[0] == word_parts[0].upcase)
|
48
|
+
word_parts.join(' ')
|
49
|
+
end
|
50
|
+
|
42
51
|
def underscore?(word)
|
43
52
|
underscore(word) == word.to_s
|
44
53
|
end
|
data/reality-naming.gemspec
CHANGED
data/test/test_naming.rb
CHANGED
@@ -63,6 +63,18 @@ class TestNaming < Reality::Naming::TestCase
|
|
63
63
|
assert_equal Reality::Naming.pascal_case?('findByID'), false
|
64
64
|
assert_equal Reality::Naming.pascal_case?(:FindByID), true
|
65
65
|
|
66
|
+
assert_equal Reality::Naming.humanize('thisIsCamelCased'), 'This Is Camel Cased'
|
67
|
+
assert_equal Reality::Naming.humanize('ThisIsCamelCased'), 'This Is Camel Cased'
|
68
|
+
assert_equal Reality::Naming.humanize('this_Is_Camel_Cased'), 'This Is Camel Cased'
|
69
|
+
assert_equal Reality::Naming.humanize('this_Is_camel_cased'), 'This Is Camel Cased'
|
70
|
+
assert_equal Reality::Naming.humanize('EJB'), 'EJB'
|
71
|
+
assert_equal Reality::Naming.humanize('EJBContainer'), 'EJB Container'
|
72
|
+
assert_equal Reality::Naming.humanize('_someField'), 'Some Field'
|
73
|
+
|
74
|
+
assert_equal Reality::Naming.humanize?('Find By ID'), true
|
75
|
+
assert_equal Reality::Naming.humanize?('find By ID'), false
|
76
|
+
assert_equal Reality::Naming.humanize?(:'Find By ID'), true
|
77
|
+
|
66
78
|
assert_equal Reality::Naming.underscore('thisIsCamelCased'), 'this_is_camel_cased'
|
67
79
|
assert_equal Reality::Naming.underscore('ThisIsCamelCased'), 'this_is_camel_cased'
|
68
80
|
assert_equal Reality::Naming.underscore('this_Is_Camel_Cased'), 'this_is_camel_cased'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reality-naming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Donald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|