reality-naming 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9396e1de974493ab043925298d8445f73f588931
4
- data.tar.gz: 184b19dafca01e19e2dad153fe54a3c7e5795f78
3
+ metadata.gz: 5545ec22fb5ca407d63e5dfecb41c89d4dab2356
4
+ data.tar.gz: df18b1417044cf9d4ce646d553109352f3ded0f7
5
5
  SHA512:
6
- metadata.gz: 71a6d7206db5bdf20cf23d6ab71af718fb325b914ca0db6f705506e0e07c472d3bf2b93e8da1affbe8edca70557ba2aebb296d9006b43d545860764b69f71e56
7
- data.tar.gz: 7388465b802b0b0aa5965d983296e37ebf78f4396b9a8f51f7b6a4c7fd22cc50198e47f3bd00ff88f529ef026c589ea1b131f0691cffa1d88ea515b63dc17a6c
6
+ metadata.gz: ec800ccab5d228d38f6780a8bda0f1a750e66f680c925b42cd2a0b1250c34d3c17102e432423059ce42c9e83404e4bc7132691badc812fdc5cc3f30ef4f66721
7
+ data.tar.gz: 9aaaba3b1ad965341fdcd14601db5f28fb358797f43d0e03d75756f7f947415061ae2dfef125efc92a87bf505ea690f2582a5350282ea6f11a46b4ea25f55039
data/Gemfile CHANGED
@@ -3,5 +3,3 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'rake', '= 0.9.2.2'
6
- gem 'minitest', '= 5.9.1'
7
- gem 'test-unit', '= 3.1.5'
@@ -109,7 +109,7 @@ module Reality
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('_')
112
+ word.split('_').collect{|w| w.upcase == w ? w.downcase : w }
113
113
  end
114
114
 
115
115
  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.0.0'
5
+ s.version = '1.1.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -20,4 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.has_rdoc = false
22
22
  s.rdoc_options = %w(--line-numbers --inline-source --title reality-naming)
23
+
24
+ s.add_development_dependency(%q<minitest>, ['= 5.9.1'])
25
+ s.add_development_dependency(%q<test-unit>, ['= 3.1.5'])
23
26
  end
data/test/test_naming.rb CHANGED
@@ -27,12 +27,56 @@ class TestNaming < Reality::Naming::TestCase
27
27
  assert_equal 'cats', Reality::Naming.pluralize('cat')
28
28
  end
29
29
 
30
+ def test_basics
31
+ assert_equal Reality::Naming.camelize('thisIsCamelCased'), 'thisIsCamelCased'
32
+ assert_equal Reality::Naming.camelize('ThisIsCamelCased'), 'thisIsCamelCased'
33
+ assert_equal Reality::Naming.camelize('this_Is_Camel_Cased'), 'thisIsCamelCased'
34
+ assert_equal Reality::Naming.camelize('this_Is_camel_cased'), 'thisIsCamelCased'
35
+ assert_equal Reality::Naming.camelize('EJB'), 'ejb'
36
+ assert_equal Reality::Naming.camelize('EJBContainer'), 'ejbContainer'
37
+
38
+ assert_equal Reality::Naming.pascal_case('thisIsCamelCased'), 'ThisIsCamelCased'
39
+ assert_equal Reality::Naming.pascal_case('ThisIsCamelCased'), 'ThisIsCamelCased'
40
+ assert_equal Reality::Naming.pascal_case('this_Is_Camel_Cased'), 'ThisIsCamelCased'
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'
44
+
45
+ assert_equal Reality::Naming.underscore('thisIsCamelCased'), 'this_is_camel_cased'
46
+ assert_equal Reality::Naming.underscore('ThisIsCamelCased'), 'this_is_camel_cased'
47
+ assert_equal Reality::Naming.underscore('this_Is_Camel_Cased'), 'this_is_camel_cased'
48
+ assert_equal Reality::Naming.underscore('this_Is_camel_cased'), 'this_is_camel_cased'
49
+ assert_equal Reality::Naming.underscore('EJB'), 'ejb'
50
+ assert_equal Reality::Naming.underscore('EJBContainer'), 'ejb_container'
51
+
52
+ assert_equal Reality::Naming.uppercase_constantize('thisIsCamelCased'), 'THIS_IS_CAMEL_CASED'
53
+ assert_equal Reality::Naming.uppercase_constantize('ThisIsCamelCased'), 'THIS_IS_CAMEL_CASED'
54
+ assert_equal Reality::Naming.uppercase_constantize('this_Is_Camel_Cased'), 'THIS_IS_CAMEL_CASED'
55
+ assert_equal Reality::Naming.uppercase_constantize('this_Is_camel_cased'), 'THIS_IS_CAMEL_CASED'
56
+ assert_equal Reality::Naming.uppercase_constantize('EJB'), 'EJB'
57
+ assert_equal Reality::Naming.uppercase_constantize('EJBContainer'), 'EJB_CONTAINER'
58
+
59
+ assert_equal Reality::Naming.xmlize('thisIsCamelCased'), 'this-is-camel-cased'
60
+ assert_equal Reality::Naming.xmlize('ThisIsCamelCased'), 'this-is-camel-cased'
61
+ assert_equal Reality::Naming.xmlize('this_Is_Camel_Cased'), 'this-is-camel-cased'
62
+ assert_equal Reality::Naming.xmlize('this_Is_camel_cased'), 'this-is-camel-cased'
63
+ assert_equal Reality::Naming.xmlize('EJB'), 'ejb'
64
+ assert_equal Reality::Naming.xmlize('EJBContainer'), 'ejb-container'
65
+
66
+ assert_equal Reality::Naming.jsonize('thisIsCamelCased'), 'thisIsCamelCased'
67
+ assert_equal Reality::Naming.jsonize('ThisIsCamelCased'), 'thisIsCamelCased'
68
+ assert_equal Reality::Naming.jsonize('this_Is_Camel_Cased'), 'thisIsCamelCased'
69
+ assert_equal Reality::Naming.jsonize('this_Is_camel_cased'), 'thisIsCamelCased'
70
+ assert_equal Reality::Naming.jsonize('EJB'), 'ejb'
71
+ assert_equal Reality::Naming.jsonize('EJBContainer'), 'ejbContainer'
72
+ end
73
+
30
74
  def test_split_into_words
31
75
  assert_equal %w(my Support Library), Reality::Naming.split_into_words('mySupportLibrary')
32
76
  assert_equal %w(My Support Library), Reality::Naming.split_into_words('MySupportLibrary')
33
77
  assert_equal %w(my support library), Reality::Naming.split_into_words('my-support-library')
34
78
  assert_equal %w(my support library), Reality::Naming.split_into_words('my_support_library')
35
- assert_equal %w(MY SUPPORT LIBRARY), Reality::Naming.split_into_words('MY_SUPPORT_LIBRARY')
79
+ assert_equal %w(my support library), Reality::Naming.split_into_words('MY_SUPPORT_LIBRARY')
36
80
  end
37
81
 
38
82
  def test_conversions
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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald
@@ -9,7 +9,35 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-11-30 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 5.9.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 5.9.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.5
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.5
13
41
  description: A library to convert names between different naming conventions.
14
42
  email: peter@realityforge.org
15
43
  executables: []