nice_hash 1.18.5 → 1.18.6
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/nice/hash/add_to_ruby.rb +20 -18
- data/lib/nice_hash.rb +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31eff5dcaddcefea5b8a0f4d8ba07abe0d2cfaab20faaad062f959a1deaf2534
|
|
4
|
+
data.tar.gz: '06121691bf7510bbd52705a7a46ce7a1fd9796a7cbfac15094099453926fa4f9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a87e32e7b1f0a0d7bc89add846c9d57b85678d0857433a64194242a6eb5db8667948b53b7aad133bd5090f7a337da331e26f7cf4264a9c0aa41be7ea1a5ab9f
|
|
7
|
+
data.tar.gz: b29dfe60081b383e5408f7f2022d077e55254226b8e619fb758e8fa82b761c960e08831c46e4fcafea38ae905d7929d2b697d82ce597e33f674c820040eda781
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
class String
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
|
|
3
|
+
if SP_COMPARE_NUMBERS_AS_STRINGS
|
|
4
|
+
###########################################################################
|
|
5
|
+
# When comparing an string and an integer, float or nil, it will be automatically converted to string:
|
|
6
|
+
# "300" == 300 #will return true
|
|
7
|
+
# 200.1=="200.1" #will return true
|
|
8
|
+
# ""==nil #will return true
|
|
9
|
+
###########################################################################
|
|
10
|
+
def ==(par)
|
|
11
|
+
if par.is_a?(Integer) || par.nil? || par.is_a?(Float)
|
|
12
|
+
super(par.to_s)
|
|
13
|
+
else
|
|
14
|
+
super(par)
|
|
15
|
+
end
|
|
13
16
|
end
|
|
14
17
|
end
|
|
15
|
-
|
|
16
18
|
###########################################################################
|
|
17
19
|
# In case the string is a json it will return the keys specified. the keys need to be provided as symbols.
|
|
18
20
|
# In case the string is not a json then it will notify the error and return empty Hash
|
|
@@ -114,8 +116,8 @@ class Array
|
|
|
114
116
|
###########################################################################
|
|
115
117
|
def deep_copy
|
|
116
118
|
NiceHash.deep_clone(self)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
+
end
|
|
120
|
+
|
|
119
121
|
alias nice_copy deep_copy
|
|
120
122
|
end
|
|
121
123
|
|
|
@@ -207,7 +209,7 @@ class Hash
|
|
|
207
209
|
###########################################################################
|
|
208
210
|
def deep_copy
|
|
209
211
|
NiceHash.deep_clone(self)
|
|
210
|
-
end
|
|
212
|
+
end
|
|
211
213
|
|
|
212
214
|
###########################################################################
|
|
213
215
|
# It will filter the hash by the key specified on select_hash_key.
|
|
@@ -280,7 +282,7 @@ class Hash
|
|
|
280
282
|
|
|
281
283
|
###########################################################################
|
|
282
284
|
# Search if the hash contains the supplied key
|
|
283
|
-
# search can be a string, symbol or regexp.
|
|
285
|
+
# search can be a string, symbol or regexp.
|
|
284
286
|
# In case of string or symbol it will return true even if only part of the key fits the 'search'
|
|
285
287
|
###########################################################################
|
|
286
288
|
def has_rkey?(search)
|
|
@@ -345,14 +347,14 @@ class Object
|
|
|
345
347
|
end
|
|
346
348
|
self
|
|
347
349
|
end
|
|
348
|
-
|
|
350
|
+
|
|
349
351
|
###########################################################################
|
|
350
352
|
# include? but the opposite. Check if the object is included on the array
|
|
351
353
|
###########################################################################
|
|
352
354
|
def in?(array)
|
|
353
355
|
array.include?(self)
|
|
354
356
|
end
|
|
355
|
-
|
|
357
|
+
|
|
356
358
|
end
|
|
357
359
|
|
|
358
360
|
class Array
|
data/lib/nice_hash.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
SP_ADD_TO_RUBY
|
|
1
|
+
SP_ADD_TO_RUBY ||= true
|
|
2
|
+
if defined?(RSpec)
|
|
3
|
+
SP_COMPARE_NUMBERS_AS_STRINGS ||= true
|
|
4
|
+
else
|
|
5
|
+
SP_COMPARE_NUMBERS_AS_STRINGS ||= false
|
|
6
|
+
end
|
|
2
7
|
#todo: consider adding SP_USE_NESTED_KEYS = true
|
|
3
8
|
|
|
4
9
|
require_relative "nice/hash/add_to_ruby" if SP_ADD_TO_RUBY
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nice_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.18.
|
|
4
|
+
version: 1.18.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mario Ruiz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: string_pattern
|
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
requirements: []
|
|
105
|
-
rubygems_version: 3.4.
|
|
105
|
+
rubygems_version: 3.4.19
|
|
106
106
|
signing_key:
|
|
107
107
|
specification_version: 4
|
|
108
108
|
summary: NiceHash creates hashes following certain patterns so your testing will be
|