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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28b37072c218f88d81b3cced702bc125a0ef19d4
4
- data.tar.gz: 573c6d79ddcb999f0e6e2fff96926976ab39c808
3
+ metadata.gz: 2140f2769b939419f3d774e4892f03703a212d61
4
+ data.tar.gz: ff53a16d8ef385f343cc3472b75955bd3eb17b39
5
5
  SHA512:
6
- metadata.gz: 11451662ac4eca11860bb52eafc06eeb2d0f08b4aa686caf94bae28a66ac1a3be572ae5847559f1a5fed725f465bed6a47c0c21f48a004250cbdbee4f63820f9
7
- data.tar.gz: 265a5e20e0f367496793df834ff31a8fe9134f29568dccd3a082d60d790891e2516a1ec5421a2b9117e58b99a7ac5ee498ac86f71e5e19bbe362640cc8add8ee
6
+ metadata.gz: 44251234a0c7560d8bf19a63b895f9a9be5a1e19282c936bcd8a019a591479271076f934df3c85b34a8b93055353a71d5c8d2e5d037ecb7146dc0d014c57b3f1
7
+ data.tar.gz: 0a653b93185684f4abfe24fe36499bc0e545afb8a1e033bb4cc867b313e1be8b3cf803c8e4d32d3f6e75ed1d9ae419e33d7b2400fb0b8ffe206c20623b1e3cc8
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reality-naming}
5
- s.version = '1.8.0'
5
+ s.version = '1.9.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -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.8.0
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-01-01 00:00:00.000000000 Z
11
+ date: 2017-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest