nice_hash 1.18.5 → 1.18.6

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
  SHA256:
3
- metadata.gz: 74ec96ab903c315b1a48cdbfb58c9cd57f6b83536fafa1178a653b0e12bcfe17
4
- data.tar.gz: 9188fe64ca3b3cf495fe0dad0c9160e68c32759fe13fb97e9643c8ef015b87db
3
+ metadata.gz: 31eff5dcaddcefea5b8a0f4d8ba07abe0d2cfaab20faaad062f959a1deaf2534
4
+ data.tar.gz: '06121691bf7510bbd52705a7a46ce7a1fd9796a7cbfac15094099453926fa4f9'
5
5
  SHA512:
6
- metadata.gz: 74361aa48d0a49c43e20b9881d0f0ba3d1c4eaeb1796b32c89576709548d9a7ecd55ae640bdfbe213efd979bd2e83070da1ada70dab3f00e989639dca8a28750
7
- data.tar.gz: fc7a6974c61cb31a805f943b7c5bdfa50928c369b2bcd0e3e1eb81a00b774c4cfd792aba57a32011151e710245a0633c6db0eae5b1501bc2cad047091b5070a4
6
+ metadata.gz: 2a87e32e7b1f0a0d7bc89add846c9d57b85678d0857433a64194242a6eb5db8667948b53b7aad133bd5090f7a337da331e26f7cf4264a9c0aa41be7ea1a5ab9f
7
+ data.tar.gz: b29dfe60081b383e5408f7f2022d077e55254226b8e619fb758e8fa82b761c960e08831c46e4fcafea38ae905d7929d2b697d82ce597e33f674c820040eda781
@@ -1,18 +1,20 @@
1
1
  class String
2
- ###########################################################################
3
- # When comparing an string and an integer, float or nil, it will be automatically converted to string:
4
- # "300" == 300 #will return true
5
- # 200.1=="200.1" #will return true
6
- # ""==nil #will return true
7
- ###########################################################################
8
- def ==(par)
9
- if par.is_a?(Integer) || par.nil? || par.is_a?(Float)
10
- super(par.to_s)
11
- else
12
- super(par)
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 = true if !defined?(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.5
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: 2023-08-10 00:00:00.000000000 Z
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.3
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