nice_hash 1.12.10 → 1.12.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/nice/hash/add_to_ruby.rb +5 -0
- data/lib/nice_hash.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c48d69517e60d0888a04cec6b9fe10d26b95b78f7645f5e3213a7d7dfb90e9f
|
4
|
+
data.tar.gz: 278966b1d3941031e4083cccb1fde61fe77f51cdaff5c60ee7dcf88b960d0279
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4043f4f7473788c17c9d54a025d4003c92a913bad3a5e78374f40582e4d636c9a3b64b51125f3529274c787493cdfd307b2532599cfcddc5869e51dc6f611e93
|
7
|
+
data.tar.gz: e7e542a1ebf41d7801c687ee87cba15c294de46a610548e859e85e7d1c98aaac7d48fb1e242a1a2acf7a898fb8299d40d07587da190051903de9dbb13e7468a8
|
data/README.md
CHANGED
@@ -56,6 +56,7 @@ my_hash={
|
|
56
56
|
age: 18..120,
|
57
57
|
euros: 0.0..3000.0,
|
58
58
|
created: DateTime,
|
59
|
+
customer: Boolean,
|
59
60
|
draws: [
|
60
61
|
{
|
61
62
|
drawId: :"5:N",
|
@@ -98,6 +99,7 @@ Explanations of the different fields:
|
|
98
99
|
age: number from 18 to 120
|
99
100
|
euros: float number from 0.0 to 3000.0
|
100
101
|
created: Time stamp format, 2019-06-20T11:40:34.547Z
|
102
|
+
customer: Boolean, (true or false)
|
101
103
|
drawId: 5 numbers
|
102
104
|
drawName: 10 letters and/or numbers
|
103
105
|
type: 'Weekely' or 'Daily'
|
@@ -245,6 +247,7 @@ On this example new_hash will contain:
|
|
245
247
|
age: 18..120,
|
246
248
|
euros: 0.0..3000.0,
|
247
249
|
created: DateTime,
|
250
|
+
customer: Boolean,
|
248
251
|
draws: [
|
249
252
|
{
|
250
253
|
drawId: :"5:N",
|
@@ -306,6 +309,7 @@ In case of filtering by :correct new_hash would have a value like this for examp
|
|
306
309
|
:age=> 19,
|
307
310
|
:euros=> 2133.34,
|
308
311
|
:created=> "2019-06-20T11:40:34.547Z",
|
312
|
+
:customer=> true,
|
309
313
|
:draws=>
|
310
314
|
[{:drawId=>"54591",
|
311
315
|
:drawName=>"cr5Q7pq4G8",
|
@@ -366,6 +370,7 @@ On this example wrong_min_length will contain something like:
|
|
366
370
|
:age=> 5,
|
367
371
|
:euros=> -452.311,
|
368
372
|
:created=> "2019-06-20T11:40:34.547",
|
373
|
+
:customer=> true,
|
369
374
|
:draws=>
|
370
375
|
[{:drawId=>"", :drawName=>"P03AgdMqV", :type=>"Dail", :owner=>"dYzLRMCnVc"},
|
371
376
|
{:drawId=>"", :drawName=>"qw", :type=>"Dail", :owner=>"zkHhTEzM"}],
|
@@ -503,6 +508,7 @@ After using the bury method default_values will contain:
|
|
503
508
|
:age=> 20,
|
504
509
|
:euros=> 155.11,
|
505
510
|
:created=>"2019-06-20T11:40:34.547Z",
|
511
|
+
:customer=> false,
|
506
512
|
:draws=>
|
507
513
|
[{:drawId=>"12318",
|
508
514
|
:drawName=>"FirstDraw",
|
@@ -540,6 +546,7 @@ values = {
|
|
540
546
|
:age=> 20,
|
541
547
|
:euros=> 155.11,
|
542
548
|
:created=>"2019-06-20T11:40:34.547Z",
|
549
|
+
:customer=> false,
|
543
550
|
:draws=>
|
544
551
|
[{:drawId=>"54a43",
|
545
552
|
:drawName=>"h3F24yjMWp",
|
@@ -789,6 +796,17 @@ If you want to delete a key on a nested hash you can use `delete_nested` and sup
|
|
789
796
|
|
790
797
|
```
|
791
798
|
|
799
|
+
We added the possibility to check if a value is boolean or not since in Ruby doesn't exist, just TrueClass and FalseClass
|
800
|
+
|
801
|
+
```ruby
|
802
|
+
value = true
|
803
|
+
text = 'true'
|
804
|
+
|
805
|
+
value.is_a?(Boolean) #> true
|
806
|
+
text.is_a?(Boolean) #> false
|
807
|
+
|
808
|
+
```
|
809
|
+
|
792
810
|
## Contributing
|
793
811
|
|
794
812
|
Bug reports and pull requests are welcome on GitHub at https://github.com/marioruiz/nice_hash.
|
data/lib/nice_hash.rb
CHANGED
@@ -455,6 +455,17 @@ class NiceHash
|
|
455
455
|
end
|
456
456
|
end
|
457
457
|
end
|
458
|
+
elsif value.kind_of?(Module) and value == Boolean
|
459
|
+
if expected_errors.empty?
|
460
|
+
hashv[key] = (rand.round == 0)
|
461
|
+
else
|
462
|
+
hashv[key] = (rand.round == 0)
|
463
|
+
expected_errors.each do |er|
|
464
|
+
if er == :value
|
465
|
+
hashv[key] = '1-10:L'.gen
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
458
469
|
elsif value.kind_of?(Proc)
|
459
470
|
hashv[key] = value.call
|
460
471
|
elsif value.kind_of?(Regexp)
|
@@ -575,6 +586,8 @@ class NiceHash
|
|
575
586
|
else
|
576
587
|
results[key] = false
|
577
588
|
end
|
589
|
+
elsif value.kind_of?(Module) and value == Boolean
|
590
|
+
results[key] = false unless values[key].is_a?(Boolean)
|
578
591
|
elsif value.kind_of?(Regexp)
|
579
592
|
rex = Regexp.new("^#{value}$")
|
580
593
|
unless values[key].match?(rex)
|