nice_hash 1.12.9 → 1.12.10
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/README.md +7 -0
- data/lib/nice_hash.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07a708f0a852586b991d2f4cb4c5df58c6695559d18fb33e06a2d9febbb8adaa
|
|
4
|
+
data.tar.gz: 1576c4dfc64b13dc78af24f86642bf94ae31f36000d2550b0195f10f42994702
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4bcd16d8c8ea6c0e7e84908cb1929e1e5723173ef336997672f52f326199e6ec84d2f9a1433407304d1bfd5834f87e8dc48d5f249e757db3b4e6b078167c52aa
|
|
7
|
+
data.tar.gz: a0625d160fa6a859abdebbf5809ea6cb5526fe1c4b767fd5c47b59e528f4e8500ba9569b3a4de3c1610564d29bc9a8f0b26bda5c7a188fd1121bb2df5f40599b
|
data/README.md
CHANGED
|
@@ -55,6 +55,7 @@ my_hash={
|
|
|
55
55
|
name: :"10-20:T_/x/",
|
|
56
56
|
age: 18..120,
|
|
57
57
|
euros: 0.0..3000.0,
|
|
58
|
+
created: DateTime,
|
|
58
59
|
draws: [
|
|
59
60
|
{
|
|
60
61
|
drawId: :"5:N",
|
|
@@ -96,6 +97,7 @@ Explanations of the different fields:
|
|
|
96
97
|
name: from 10 to 20 chars. Optional national characters and space, necessary lower letters.
|
|
97
98
|
age: number from 18 to 120
|
|
98
99
|
euros: float number from 0.0 to 3000.0
|
|
100
|
+
created: Time stamp format, 2019-06-20T11:40:34.547Z
|
|
99
101
|
drawId: 5 numbers
|
|
100
102
|
drawName: 10 letters and/or numbers
|
|
101
103
|
type: 'Weekely' or 'Daily'
|
|
@@ -242,6 +244,7 @@ On this example new_hash will contain:
|
|
|
242
244
|
name: :"10-20:T_/x/",
|
|
243
245
|
age: 18..120,
|
|
244
246
|
euros: 0.0..3000.0,
|
|
247
|
+
created: DateTime,
|
|
245
248
|
draws: [
|
|
246
249
|
{
|
|
247
250
|
drawId: :"5:N",
|
|
@@ -302,6 +305,7 @@ In case of filtering by :correct new_hash would have a value like this for examp
|
|
|
302
305
|
:name=>"OyTQNfEyPOzVYMxPym",
|
|
303
306
|
:age=> 19,
|
|
304
307
|
:euros=> 2133.34,
|
|
308
|
+
:created=> "2019-06-20T11:40:34.547Z",
|
|
305
309
|
:draws=>
|
|
306
310
|
[{:drawId=>"54591",
|
|
307
311
|
:drawName=>"cr5Q7pq4G8",
|
|
@@ -361,6 +365,7 @@ On this example wrong_min_length will contain something like:
|
|
|
361
365
|
:name=>"bU",
|
|
362
366
|
:age=> 5,
|
|
363
367
|
:euros=> -452.311,
|
|
368
|
+
:created=> "2019-06-20T11:40:34.547",
|
|
364
369
|
:draws=>
|
|
365
370
|
[{:drawId=>"", :drawName=>"P03AgdMqV", :type=>"Dail", :owner=>"dYzLRMCnVc"},
|
|
366
371
|
{:drawId=>"", :drawName=>"qw", :type=>"Dail", :owner=>"zkHhTEzM"}],
|
|
@@ -497,6 +502,7 @@ After using the bury method default_values will contain:
|
|
|
497
502
|
:name=>"HdmsjLxlEgYIFY",
|
|
498
503
|
:age=> 20,
|
|
499
504
|
:euros=> 155.11,
|
|
505
|
+
:created=>"2019-06-20T11:40:34.547Z",
|
|
500
506
|
:draws=>
|
|
501
507
|
[{:drawId=>"12318",
|
|
502
508
|
:drawName=>"FirstDraw",
|
|
@@ -533,6 +539,7 @@ values = {
|
|
|
533
539
|
:name=>"LTqVKxxFCTqpkdjFkxU",
|
|
534
540
|
:age=> 20,
|
|
535
541
|
:euros=> 155.11,
|
|
542
|
+
:created=>"2019-06-20T11:40:34.547Z",
|
|
536
543
|
:draws=>
|
|
537
544
|
[{:drawId=>"54a43",
|
|
538
545
|
:drawName=>"h3F24yjMWp",
|
data/lib/nice_hash.rb
CHANGED
|
@@ -434,6 +434,27 @@ class NiceHash
|
|
|
434
434
|
end
|
|
435
435
|
end
|
|
436
436
|
end
|
|
437
|
+
elsif value.kind_of?(Class) and value == DateTime
|
|
438
|
+
if expected_errors.empty?
|
|
439
|
+
hashv[key] = Time.now.stamp
|
|
440
|
+
else
|
|
441
|
+
hashv[key] = Time.now.stamp
|
|
442
|
+
expected_errors.each do |er|
|
|
443
|
+
if er == :min_length
|
|
444
|
+
hashv[key] = hashv[key].chop
|
|
445
|
+
elsif er == :max_length
|
|
446
|
+
hashv[key] = hashv[key] + "Z"
|
|
447
|
+
elsif er == :length
|
|
448
|
+
if rand.round==1
|
|
449
|
+
hashv[key] = hashv[key].chop
|
|
450
|
+
else
|
|
451
|
+
hashv[key] = hashv[key] + "Z"
|
|
452
|
+
end
|
|
453
|
+
elsif er == :value
|
|
454
|
+
hashv[key][rand(hashv[key].size-1)] = '1:L'.gen
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
end
|
|
437
458
|
elsif value.kind_of?(Proc)
|
|
438
459
|
hashv[key] = value.call
|
|
439
460
|
elsif value.kind_of?(Regexp)
|
|
@@ -548,6 +569,12 @@ class NiceHash
|
|
|
548
569
|
elsif values[key] < value.first or values[key] > value.last
|
|
549
570
|
results[key] = false
|
|
550
571
|
end
|
|
572
|
+
elsif value.kind_of?(Class) and value == DateTime
|
|
573
|
+
if values[key].size == 24
|
|
574
|
+
d = Date.strptime(values[key], '%Y-%m-%dT%H:%M:%S.%LZ') rescue results[key] = false
|
|
575
|
+
else
|
|
576
|
+
results[key] = false
|
|
577
|
+
end
|
|
551
578
|
elsif value.kind_of?(Regexp)
|
|
552
579
|
rex = Regexp.new("^#{value}$")
|
|
553
580
|
unless values[key].match?(rex)
|
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.12.
|
|
4
|
+
version: 1.12.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mario Ruiz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-06-
|
|
11
|
+
date: 2019-06-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: string_pattern
|