genny 0.2.1 → 0.2.2
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 +8 -8
- data/VERSION +1 -1
- data/lib/genny/array.rb +2 -2
- data/lib/genny/json_schema.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODA4NWZiM2YxMjk1OTE1ZjIzNDg4N2U3MmY1YTBjYjllZjk2ODg1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGYzMDZkNzQyMzE1Y2I3OGZiZDFiNDgyZDk4YWUwNDU1MDQ1Yzg2NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGQ3OGVlOTA0ZTM4NzRhOTAyNTU5ZTRhZTMxZTZmNTc2ZThjY2Q1YWIzYzVk
|
10
|
+
MDE3M2QxMGEwOTQ1YzdhMzdkYjNmZWI3NTM2YWRlYWM2MDBkMDU5NzRkYzYx
|
11
|
+
NmFjMDFiMDNjMDYzZWY4Mjc3ZjNiZjM2OGFlYTBhN2EyYzUzZDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Nzk5OGNmMDdhYjIzMWI4MzYzMjljNjdjMWQ3NmZjNWExN2M0Yjc1Yjg0MDNm
|
14
|
+
ZjFmM2RmNWY5MTU4NjBmZThiOGJlNDQwMTA2YjZiYmI1MzdmYmRjOTMxNjYy
|
15
|
+
ZjY0YTg4YzU0ZjEwYWZmNzdjNDJmZTMyOWI3NDg4OTdjZjJkMmQ=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/genny/array.rb
CHANGED
@@ -21,7 +21,7 @@ module Genny
|
|
21
21
|
# @return [Array]
|
22
22
|
def self.genny(opts = {})
|
23
23
|
opts = Genny.symbolize(opts)
|
24
|
-
opts[:items] = opts[:items].is_a?(Array) ? opts[:items] : [opts[:items]].compact
|
24
|
+
opts[:items] = opts[:items].is_a?(::Array) ? opts[:items] : [opts[:items]].compact
|
25
25
|
raise ArgumentError, "classes must be an array" unless opts[:items].respond_to?(:select)
|
26
26
|
items = opts[:items].select { |item| item.respond_to?(:genny) }
|
27
27
|
if items.empty?
|
@@ -29,7 +29,7 @@ module Genny
|
|
29
29
|
return []
|
30
30
|
end
|
31
31
|
min_count = opts[:minItems] || 1
|
32
|
-
max_count = opts[:maxItems] || [
|
32
|
+
max_count = opts[:maxItems] || [min_count, 5].max
|
33
33
|
raise "maxItems is lower than minItems" if max_count < min_count
|
34
34
|
count = Random.rand(max_count - min_count + 1) + min_count
|
35
35
|
return count.times.map { items.sample.genny }
|
data/lib/genny/json_schema.rb
CHANGED
@@ -31,6 +31,10 @@ class JSONSchema < SimpleDelegator
|
|
31
31
|
nil => Genny::Hash
|
32
32
|
}[opts[:type]]
|
33
33
|
raise "Cannot generate JSON Schema object of type '#{opts[:type]}'." unless klass.respond_to?(:genny)
|
34
|
+
# Convert the JSONSchema items object into something Array.genny can cope with
|
35
|
+
opts[:items] = (opts[:items].is_a?(::Array) ? opts[:items] : [opts[:items]].compact).map do |item|
|
36
|
+
JSONSchema.new(item, definitions: opts[:definitions])
|
37
|
+
end if klass == Genny::Array
|
34
38
|
klass.genny(opts)
|
35
39
|
end
|
36
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|