awrence 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +15 -12
  4. data/Rakefile +2 -0
  5. data/VERSION +1 -1
  6. data/lib/awrence/methods.rb +21 -26
  7. metadata +89 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5ed1bafd204d0f5d584f47dbb0ef8f4c211031eda888920078104141823dfbd
4
- data.tar.gz: d29a22a0c9f9f5e18a6b78de602b50ef4ac24a86b20c3512accc56ec55b6ab9d
3
+ metadata.gz: 6121082bf25dc2a5050b21f38404fb6d300838c68c6df2b5d67c3d9956622d21
4
+ data.tar.gz: 3caa8b1d101475002f9d17d0e2c2b0418d8a8a39f1693f526cc04ab6d1cd6206
5
5
  SHA512:
6
- metadata.gz: 4ca478ed67cf46ca895af7f75e41ce4639e945bea155a330730586625df465cced767d995dcdcedd223021ddd049f031b94b1c412c6c9b4de7a3f1e69c792f2a
7
- data.tar.gz: 566e6cbf587fee37134913359821856021d1254a07e258594d25cac63885fcb9d458850bd7701e430ec6a04df54ea96948305939556d1a49a965ed34aef0a945
6
+ metadata.gz: 2a7e48f2382dfc3f863f09f2b3d54293b02661734a7b5e344d6e8241de5e8563769fc23b1da5d83d10e48b6bf961c85287d46b201be602fb5334cbe86ac1fa4a
7
+ data.tar.gz: 64e04089c788665af85de7e0a296b6160962524bfb5a0abcac0fed6b619fa6746c6a320c88d54b05cedd7a4e273304fe0cb0febe6e952798e5838876b1a5b0f3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2021 Technical Panda Ltd
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,13 +1,18 @@
1
1
  # Awrence
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/awrence.svg)](https://badge.fury.io/rb/awrence)
4
+ ![CI](https://github.com/technicalpanda/awrence/workflows/CI/badge.svg)
4
5
 
5
- Have you ever needed to automatically convert Rubyish `snake_case` to JSON-style `camelBack` or `CamelCase` hash keys?
6
+ Have you ever needed to automatically convert Rubyish `snake_case` to JSON-style `camelBack` or `CamelCase` hash keys?
6
7
 
7
- Awrence to the rescue.
8
+ Awrence to the rescue!
8
9
 
9
10
  This gem recursively converts all snake_case keys in a hash structure to camelBack or CamelCase.
10
11
 
12
+ ## Requirements
13
+
14
+ * Ruby >= 2.7
15
+
11
16
  ## Installation
12
17
 
13
18
  Add this to your Gemfile:
@@ -74,16 +79,14 @@ camel_hash = my_hash.to_camelback_keys
74
79
  If you've already got `CamelCase` and need to `snake_case` it, you are encouraged to try
75
80
  the [Plissken](http://github.com/futurechimp/plissken) gem.
76
81
 
77
- ## Contributing to awrence
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at https://github.com/technicalpanda/awrence. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
85
+
86
+ ## License
78
87
 
79
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
80
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
81
- * Fork the project.
82
- * Start a feature/bugfix branch.
83
- * Commit and push until you are happy with your contribution.
84
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
85
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
88
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
86
89
 
87
- # Copyright
90
+ ## Code of Conduct
88
91
 
89
- Copyright (c) 2017 Dave Hrycyszyn. See LICENSE.txt for further details.
92
+ Everyone interacting with this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/technicalpanda/awrence/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require "bundler/setup"
3
5
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 2.0.0
@@ -6,48 +6,34 @@ module Awrence
6
6
  # hash keys suitable for use with a JSON API.
7
7
  #
8
8
  def to_camelback_keys(value = self)
9
- case value
10
- when Array
11
- value.map { |v| to_camelback_keys(v) }
12
- when Hash
13
- Hash[value.map { |k, v| [camelize_key(k, false), to_camelback_keys(v)] }]
14
- else
15
- value
16
- end
9
+ process_value(:to_camelback_keys, value, first_upper: false)
17
10
  end
18
11
 
19
12
  # Recursively converts Rubyish snake_case hash keys to CamelCase JSON-style
20
13
  # hash keys suitable for use with a JSON API.
21
14
  #
22
15
  def to_camel_keys(value = self)
23
- case value
24
- when Array
25
- value.map { |v| to_camel_keys(v) }
26
- when Hash
27
- Hash[value.map { |k, v| [camelize_key(k), to_camel_keys(v)] }]
28
- else
29
- value
30
- end
16
+ process_value(:to_camel_keys, value, first_upper: true)
31
17
  end
32
18
 
33
19
  private
34
20
 
35
- def camelize_key(key, first_upper = true)
36
- if key.is_a? Symbol
37
- camelize(key.to_s, first_upper).to_sym
38
- elsif key.is_a? String
39
- camelize(key, first_upper)
21
+ def camelize_key(key, first_upper: true)
22
+ case key
23
+ when Symbol
24
+ camelize(key.to_s, first_upper: first_upper).to_sym
25
+ when String
26
+ camelize(key, first_upper: first_upper)
40
27
  else
41
28
  key # Awrence can't camelize anything except strings and symbols
42
29
  end
43
30
  end
44
31
 
45
- def camelize(snake_word, first_upper = true)
32
+ def camelize(snake_word, first_upper: true)
46
33
  if first_upper
47
34
  str = snake_word.to_s
48
35
  str = gsubbed(str, /(?:^|_)([^_\s]+)/)
49
- str = gsubbed(str, %r{/([^/]*)}, "::")
50
- str
36
+ gsubbed(str, %r{/([^/]*)}, "::")
51
37
  else
52
38
  parts = snake_word.split("_", 2)
53
39
  parts[0] << camelize(parts[1]) if parts.size > 1
@@ -56,11 +42,20 @@ module Awrence
56
42
  end
57
43
 
58
44
  def gsubbed(str, pattern, extra = "")
59
- str = str.gsub(pattern) do
45
+ str.gsub(pattern) do
60
46
  extra + (Awrence.acronyms[Regexp.last_match(1)] || Regexp.last_match(1).capitalize)
61
47
  end
48
+ end
62
49
 
63
- str
50
+ def process_value(method, value, first_upper: true)
51
+ case value
52
+ when Array
53
+ value.map { |v| send(method, v) }
54
+ when Hash
55
+ value.to_h { |k, v| [camelize_key(k, first_upper: first_upper), send(method, v)] }
56
+ else
57
+ value
58
+ end
64
59
  end
65
60
  end
66
61
  end
metadata CHANGED
@@ -1,30 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awrence
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Hrycyszyn
8
8
  - Stuart Chinery
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-14 00:00:00.000000000 Z
12
+ date: 2022-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: byebug
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '11.1'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '11.1'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: minitest
16
30
  requirement: !ruby/object:Gem::Requirement
17
31
  requirements:
18
32
  - - "~>"
19
33
  - !ruby/object:Gem::Version
20
- version: '5.0'
34
+ version: '5.14'
21
35
  type: :development
22
36
  prerelease: false
23
37
  version_requirements: !ruby/object:Gem::Requirement
24
38
  requirements:
25
39
  - - "~>"
26
40
  - !ruby/object:Gem::Version
27
- version: '5.0'
41
+ version: '5.14'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: minitest-fail-fast
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -39,34 +53,90 @@ dependencies:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
55
  version: '0.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest-macos-notification
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.3'
42
70
  - !ruby/object:Gem::Dependency
43
71
  name: minitest-reporters
44
72
  requirement: !ruby/object:Gem::Requirement
45
73
  requirements:
46
74
  - - "~>"
47
75
  - !ruby/object:Gem::Version
48
- version: '1.3'
76
+ version: '1.4'
49
77
  type: :development
50
78
  prerelease: false
51
79
  version_requirements: !ruby/object:Gem::Requirement
52
80
  requirements:
53
81
  - - "~>"
54
82
  - !ruby/object:Gem::Version
55
- version: '1.3'
83
+ version: '1.4'
56
84
  - !ruby/object:Gem::Dependency
57
85
  name: rake
58
86
  requirement: !ruby/object:Gem::Requirement
59
87
  requirements:
60
88
  - - "~>"
61
89
  - !ruby/object:Gem::Version
62
- version: '12.0'
90
+ version: '13.0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '13.0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.7'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.7'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-minitest
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '0.10'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.10'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop-rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0.5'
63
133
  type: :development
64
134
  prerelease: false
65
135
  version_requirements: !ruby/object:Gem::Requirement
66
136
  requirements:
67
137
  - - "~>"
68
138
  - !ruby/object:Gem::Version
69
- version: '12.0'
139
+ version: '0.5'
70
140
  description: |-
71
141
  Have you ever needed to automatically convert Ruby-style snake_case to CamelCase or camelBack hash keys?
72
142
 
@@ -74,11 +144,13 @@ description: |-
74
144
 
75
145
  This gem recursively converts all snake_case keys in a hash structure to camelBack.
76
146
  email:
77
- - dhrycyszyn@zonedigital.com
147
+ - dave@constructiveproof.com
148
+ - code@technicalpanda.co.uk
78
149
  executables: []
79
150
  extensions: []
80
151
  extra_rdoc_files: []
81
152
  files:
153
+ - MIT-LICENSE
82
154
  - README.md
83
155
  - Rakefile
84
156
  - VERSION
@@ -87,11 +159,12 @@ files:
87
159
  - lib/awrence/ext/hash/to_camel_keys.rb
88
160
  - lib/awrence/methods.rb
89
161
  - lib/awrence/version.rb
90
- homepage: https://github.com/futurechimp/awrence
162
+ homepage: https://github.com/technicalpanda/awrence
91
163
  licenses:
92
164
  - MIT
93
- metadata: {}
94
- post_install_message:
165
+ metadata:
166
+ rubygems_mfa_required: 'true'
167
+ post_install_message:
95
168
  rdoc_options: []
96
169
  require_paths:
97
170
  - lib
@@ -99,15 +172,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
172
  requirements:
100
173
  - - ">="
101
174
  - !ruby/object:Gem::Version
102
- version: '0'
175
+ version: '2.7'
103
176
  required_rubygems_version: !ruby/object:Gem::Requirement
104
177
  requirements:
105
178
  - - ">="
106
179
  - !ruby/object:Gem::Version
107
180
  version: '0'
108
181
  requirements: []
109
- rubygems_version: 3.0.1
110
- signing_key:
182
+ rubygems_version: 3.2.33
183
+ signing_key:
111
184
  specification_version: 4
112
185
  summary: Camelize your snake keys when working with JSON APIs
113
186
  test_files: []