nice_hash 1.15.4 → 1.15.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/nice/hash/generate.rb +12 -3
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3605a43d942a85cf7db1fc4443d1c012433f0954dc5ea7362860ca377820b25d
|
4
|
+
data.tar.gz: 15383b286336f04f2164de0a0cdc3c992ea320fcf22d7937e60835b5ade60b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd607adebe21e61767640a6b6435ca8dce9123864940e88b65e7430047229b2bc4fab86a7210863127cacffe0028ab692f565c668f1ff65fb6ae0a5a1a3dc61
|
7
|
+
data.tar.gz: 3742a730f12dd29afc640d1276ea95f1803770feedef83e79127f4e3fb669e35de3f54dfdd12226689c285c2bda1d9615335cc54fabe24c7904ad2474f0451e9
|
data/README.md
CHANGED
@@ -38,6 +38,8 @@ To use nice_hash on Http connections take a look at nice_http gem: https://githu
|
|
38
38
|
+ [Deep copy of a hash](#deep-copy-of-a-hash)
|
39
39
|
+ [Nested deletion](#nested-deletion)
|
40
40
|
+ [Boolean class](#boolean-class)
|
41
|
+
* [Other tools integration](#other-tools-integration)
|
42
|
+
+ [Tabulo](#tabulo)
|
41
43
|
- [Contributing](#contributing)
|
42
44
|
- [License](#license)
|
43
45
|
|
@@ -882,6 +884,35 @@ text = 'true'
|
|
882
884
|
value.is_a?(Boolean) #> true
|
883
885
|
text.is_a?(Boolean) #> false
|
884
886
|
|
887
|
+
```
|
888
|
+
### Other tools integration
|
889
|
+
|
890
|
+
#### Tabulo
|
891
|
+
|
892
|
+
You can use tabulo (https://github.com/matt-harvey/tabulo) and nice_hash together:
|
893
|
+
|
894
|
+
```ruby
|
895
|
+
require 'nice_hash'
|
896
|
+
require 'tabulo'
|
897
|
+
|
898
|
+
my_data = [
|
899
|
+
{id:'1', name: 'Peter', city: 'London', account: '112124', client: true },
|
900
|
+
{id:'2', name: 'Ann', city: 'Madrid', account: '4454656', client: true },
|
901
|
+
{id:'3', name: 'John', city: 'New York', account: '5645666', client: false }
|
902
|
+
]
|
903
|
+
|
904
|
+
puts Tabulo::Table.new(my_data, :id, :name, :city, :client, border: :modern).pack
|
905
|
+
```
|
906
|
+
|
907
|
+
It will generate:
|
908
|
+
```
|
909
|
+
┌────┬───────┬──────────┬────────┐
|
910
|
+
│ id │ name │ city │ client │
|
911
|
+
├────┼───────┼──────────┼────────┤
|
912
|
+
│ 1 │ Peter │ London │ true │
|
913
|
+
│ 2 │ Ann │ Madrid │ true │
|
914
|
+
│ 3 │ John │ New York │ false │
|
915
|
+
└────┴───────┴──────────┴────────┘
|
885
916
|
```
|
886
917
|
|
887
918
|
## Contributing
|
data/lib/nice/hash/generate.rb
CHANGED
@@ -134,16 +134,25 @@ class NiceHash
|
|
134
134
|
end
|
135
135
|
elsif value.kind_of?(Range)
|
136
136
|
if expected_errors.empty?
|
137
|
+
if value.size == Float::INFINITY
|
138
|
+
value = (value.min..2**64)
|
139
|
+
end
|
137
140
|
hashv[key] = rand(value)
|
138
141
|
else
|
139
|
-
|
142
|
+
if value.size == Float::INFINITY
|
143
|
+
infinite = true
|
144
|
+
value = (value.min..2**64)
|
145
|
+
else
|
146
|
+
infinite = false
|
147
|
+
hashv[key] = rand(value)
|
148
|
+
end
|
140
149
|
expected_errors.each do |er|
|
141
150
|
if er == :min_length
|
142
151
|
hashv[key] = rand((value.first - value.last)..value.first - 1)
|
143
|
-
elsif er == :max_length
|
152
|
+
elsif er == :max_length and !infinite
|
144
153
|
hashv[key] = rand((value.last + 1)..(value.last * 2))
|
145
154
|
elsif er == :length
|
146
|
-
if rand.round == 1
|
155
|
+
if rand.round == 1 or infinite
|
147
156
|
hashv[key] = rand((value.first - value.last)..value.first - 1)
|
148
157
|
else
|
149
158
|
hashv[key] = rand((value.last + 1)..(value.last * 2))
|
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.15.
|
4
|
+
version: 1.15.5
|
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: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string_pattern
|
@@ -34,22 +34,22 @@ dependencies:
|
|
34
34
|
name: rspec
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.8'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: 3.8.0
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.8'
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.8'
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: 3.8.0
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.8'
|
53
53
|
description: 'NiceHash creates hashes following certain patterns so your testing will
|
54
54
|
be much easier. Parse and filter JSON. You can easily generate all the hashes you
|
55
55
|
want following the criteria you specify. Many other features coming to Hash class
|
@@ -101,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.7.6
|
104
|
+
rubygems_version: 3.0.3
|
106
105
|
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: NiceHash creates hashes following certain patterns so your testing will be
|