utilise 1.0.0 → 1.1.0.pre.71
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/utilise/augment/hash.rb +10 -0
- data/lib/utilise/version.rb +2 -2
- data/lib/utilise.rb +1 -1
- data/spec/utilise/hash_spec.rb +86 -0
- data/spec/utilise/time_spec.rb +1 -1
- data/spec/utilise/version_spec.rb +1 -1
- metadata +11 -12
- /data/lib/utilise/{fixnum.rb → integer.rb} +0 -0
- /data/spec/utilise/{fixnum_spec.rb → integer_spec.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 468438b1880e8210fb093e734adbc1e17945cd86
|
4
|
+
data.tar.gz: 545bfad4a87fff4138f7fed3c68339197a9ea8b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5227bf3eab4f9ee0aae61a7d63dcc1954b8bd226fbed2e92ac2dfff7ac46a73a5423e37896046ad82bf8433dfaccea150c7ec5acf8159d9d6f5d919ba942dc1f
|
7
|
+
data.tar.gz: a1fa473917aa9f57e9ffa53b0d10222bd18be07c07a42febcf35989727b7b585cbdeb6c0e53c05fb95581a28c43a87fe0d0f3101bfb7820a935f3ac0af9e0559
|
data/lib/utilise/augment/hash.rb
CHANGED
@@ -19,6 +19,16 @@ module Utilise
|
|
19
19
|
utilise_deep_transform_keys(self) { |key| key.space }
|
20
20
|
end
|
21
21
|
|
22
|
+
# Transforms all keys to a string
|
23
|
+
def string_keys
|
24
|
+
utilise_deep_transform_keys(self) { |key| key.to_s }
|
25
|
+
end
|
26
|
+
|
27
|
+
# Transforms all keys to a symbol
|
28
|
+
def symbol_keys
|
29
|
+
utilise_deep_transform_keys(self) { |key| key.to_sym }
|
30
|
+
end
|
31
|
+
|
22
32
|
private
|
23
33
|
|
24
34
|
# Deep transform keys in object
|
data/lib/utilise/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Utilise
|
2
2
|
module Utilise
|
3
3
|
# The current gem version
|
4
|
-
VERSION = '1.
|
4
|
+
VERSION = '1.1.0'.freeze
|
5
5
|
# The version update date
|
6
|
-
DATE = '
|
6
|
+
DATE = '2017-02-07'.freeze
|
7
7
|
# Debug output message
|
8
8
|
MSG = 'Version %s %s (running on %s-%s)'.freeze
|
9
9
|
|
data/lib/utilise.rb
CHANGED
data/spec/utilise/hash_spec.rb
CHANGED
@@ -198,4 +198,90 @@ describe Hash do
|
|
198
198
|
expect(old_hash['red key'][:blueKey]).to eql('testing 123')
|
199
199
|
end
|
200
200
|
end
|
201
|
+
|
202
|
+
describe '#string_keys' do
|
203
|
+
let(:hash) { { oneKey: 'aString', two_key: ['a_string'], redKey: { blue_key: 'testing 123' } } }
|
204
|
+
|
205
|
+
it 'converts all keys to a string' do
|
206
|
+
new_hash = hash.string_keys
|
207
|
+
expect(new_hash.key?('oneKey')).to be_truthy
|
208
|
+
expect(new_hash.key?('two_key')).to be_truthy
|
209
|
+
expect(new_hash.key?('redKey')).to be_truthy
|
210
|
+
expect(new_hash['redKey'].key?('blue_key')).to be_truthy
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'does not keep the old keys' do
|
214
|
+
new_hash = hash.string_keys
|
215
|
+
expect(new_hash.key?(:oneKey)).to be_falsey
|
216
|
+
expect(new_hash.key?(:two_key)).to be_falsey
|
217
|
+
expect(new_hash.key?(:redKey)).to be_falsey
|
218
|
+
expect(new_hash['redKey'].key?(:blue_key)).to be_falsey
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'does not convert the values' do
|
222
|
+
new_hash = hash.string_keys
|
223
|
+
|
224
|
+
expect(new_hash['oneKey']).to eql(hash[:oneKey])
|
225
|
+
expect(new_hash['two_key']).to eql(hash[:two_key])
|
226
|
+
expect(new_hash['redKey']['blue_key']).to eql(hash[:redKey][:blue_key])
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'does not modify the original hash' do
|
230
|
+
new_hash = hash
|
231
|
+
new_hash.string_keys
|
232
|
+
|
233
|
+
expect(new_hash.key?(:oneKey)).to be_truthy
|
234
|
+
expect(new_hash.key?(:two_key)).to be_truthy
|
235
|
+
expect(new_hash.key?(:redKey)).to be_truthy
|
236
|
+
expect(new_hash[:redKey].key?(:blue_key)).to be_truthy
|
237
|
+
|
238
|
+
expect(new_hash[:oneKey]).to be(hash[:oneKey])
|
239
|
+
expect(new_hash[:two_key]).to be(hash[:two_key])
|
240
|
+
expect(new_hash[:redKey]).to be(hash[:redKey])
|
241
|
+
expect(new_hash[:redKey][:blue_key]).to be(hash[:redKey][:blue_key])
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe '#symbol_keys' do
|
246
|
+
let(:hash) { { 'oneKey' => 'aString', 'two_key' => ['a_string'], 'redKey' => { 'blue_key' => 'testing 123' } } }
|
247
|
+
|
248
|
+
it 'converts all keys to a symbol' do
|
249
|
+
new_hash = hash.symbol_keys
|
250
|
+
expect(new_hash.key?(:oneKey)).to be_truthy
|
251
|
+
expect(new_hash.key?(:two_key)).to be_truthy
|
252
|
+
expect(new_hash.key?(:redKey)).to be_truthy
|
253
|
+
expect(new_hash[:redKey].key?(:blue_key)).to be_truthy
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'does not keep the old keys' do
|
257
|
+
new_hash = hash.symbol_keys
|
258
|
+
expect(new_hash.key?('oneKey')).to be_falsey
|
259
|
+
expect(new_hash.key?('two_key')).to be_falsey
|
260
|
+
expect(new_hash.key?('redKey')).to be_falsey
|
261
|
+
expect(new_hash[:redKey].key?('blue_key')).to be_falsey
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'does not convert the values' do
|
265
|
+
new_hash = hash.symbol_keys
|
266
|
+
|
267
|
+
expect(new_hash[:oneKey]).to eql(hash['oneKey'])
|
268
|
+
expect(new_hash[:two_key]).to eql(hash['two_key'])
|
269
|
+
expect(new_hash[:redKey][:blue_key]).to eql(hash['redKey']['blue_key'])
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'does not modify the original hash' do
|
273
|
+
new_hash = hash
|
274
|
+
new_hash.symbol_keys
|
275
|
+
|
276
|
+
expect(new_hash.key?('oneKey')).to be_truthy
|
277
|
+
expect(new_hash.key?('two_key')).to be_truthy
|
278
|
+
expect(new_hash.key?('redKey')).to be_truthy
|
279
|
+
expect(new_hash['redKey'].key?('blue_key')).to be_truthy
|
280
|
+
|
281
|
+
expect(new_hash['oneKey']).to be(hash['oneKey'])
|
282
|
+
expect(new_hash['two_key']).to be(hash['two_key'])
|
283
|
+
expect(new_hash['redKey']).to be(hash['redKey'])
|
284
|
+
expect(new_hash['redKey']['blue_key']).to be(hash['redKey']['blue_key'])
|
285
|
+
end
|
286
|
+
end
|
201
287
|
end
|
data/spec/utilise/time_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Utilise do
|
4
4
|
describe '.version' do
|
5
5
|
it 'should return the current gem version' do
|
6
|
-
expect(Utilise.version).to eq('1.
|
6
|
+
expect(Utilise.version).to eq('1.1.0')
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should return the current gem version with debug information' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utilise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre.71
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Slaughter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -124,9 +124,9 @@ files:
|
|
124
124
|
- lib/utilise/augment/matchers.rb
|
125
125
|
- lib/utilise/augment/modify.rb
|
126
126
|
- lib/utilise/augment/time.rb
|
127
|
-
- lib/utilise/fixnum.rb
|
128
127
|
- lib/utilise/hash.rb
|
129
128
|
- lib/utilise/hashie.rb
|
129
|
+
- lib/utilise/integer.rb
|
130
130
|
- lib/utilise/object.rb
|
131
131
|
- lib/utilise/string.rb
|
132
132
|
- lib/utilise/symbol.rb
|
@@ -134,9 +134,9 @@ files:
|
|
134
134
|
- lib/utilise/version.rb
|
135
135
|
- spec/spec_helper.rb
|
136
136
|
- spec/utilise/array_spec.rb
|
137
|
-
- spec/utilise/fixnum_spec.rb
|
138
137
|
- spec/utilise/hash_spec.rb
|
139
138
|
- spec/utilise/hashie_spec.rb
|
139
|
+
- spec/utilise/integer_spec.rb
|
140
140
|
- spec/utilise/object_spec.rb
|
141
141
|
- spec/utilise/string_spec.rb
|
142
142
|
- spec/utilise/symbol_spec.rb
|
@@ -157,24 +157,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
|
-
- - "
|
160
|
+
- - ">"
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
162
|
+
version: 1.3.1
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.6.8
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Utilises a few extra methods
|
169
169
|
test_files:
|
170
170
|
- spec/spec_helper.rb
|
171
171
|
- spec/utilise/array_spec.rb
|
172
|
-
- spec/utilise/fixnum_spec.rb
|
173
|
-
- spec/utilise/hash_spec.rb
|
174
|
-
- spec/utilise/hashie_spec.rb
|
175
172
|
- spec/utilise/object_spec.rb
|
176
173
|
- spec/utilise/string_spec.rb
|
174
|
+
- spec/utilise/version_spec.rb
|
175
|
+
- spec/utilise/hashie_spec.rb
|
177
176
|
- spec/utilise/symbol_spec.rb
|
177
|
+
- spec/utilise/integer_spec.rb
|
178
178
|
- spec/utilise/time_spec.rb
|
179
|
-
- spec/utilise/
|
180
|
-
has_rdoc:
|
179
|
+
- spec/utilise/hash_spec.rb
|
File without changes
|
File without changes
|