genny 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/genny/array.rb +9 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWI0NjNkOWNiOWJjODg2NTY0YTljNmJlZmE4ODc1MmYyODQxNDljZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGNmNmE4ZmMxMmRlNzBlZTRmMmRhMmMxZGUwMmNlOTQ5YjBkNGZhYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2M3YTVhMGMwMzVmMTkzMGM3YjQwZmY3YTgzZDM1NDE4YzY2NzM2NjE1ODFi
|
10
|
+
OTBmMGNkOGU3MzRjN2Y4MzczZmNiMzU0OTg3MGM4OGI5NzE4ZGM4ZTE4N2Ey
|
11
|
+
YmUzZmQzZWVmMTRkYjNjNmQyYTU2ZmIxMzdjYzAzNGFhNzZkNDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWI1NDVlZGYxZjk2MWIxOWE1MjE0YTljZTMyZjMwZGQ2ZDhkMmY2MWNmNzUz
|
14
|
+
YmExOWM3NmM0Yzg3YzhjMjBlMTUzM2Y0YmMyN2I4ZTY5NmU2ZjI2OGQzMzY2
|
15
|
+
YzU3YTNiOWE0ZjAzN2ZjOGFhN2MxMzNlM2RlMjE4Njg0YjRlYzY=
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Genny
|
1
|
+
# Genny [![Code Climate](https://codeclimate.com/github/blinkboxbooks/genny/badges/gpa.svg)](https://codeclimate.com/github/blinkboxbooks/genny) [![Test Coverage](https://codeclimate.com/github/blinkboxbooks/genny/badges/coverage.svg)](https://codeclimate.com/github/blinkboxbooks/genny)
|
2
2
|
|
3
3
|
Genny likes making things up. Unlike other faker libraries this one is based around generating whole data structures using JSONSchema as a basis.
|
4
4
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/genny/array.rb
CHANGED
@@ -23,7 +23,7 @@ module Genny
|
|
23
23
|
opts = Genny.symbolize(opts)
|
24
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
|
-
items = opts[:items].select { |item| item.respond_to?(:genny) }
|
26
|
+
items = opts[:items].select { |item| item.respond_to?(:genny) }.dup
|
27
27
|
if items.empty?
|
28
28
|
raise "No items given, cannot populate the array." unless opts[:minItems].to_i == 0
|
29
29
|
return []
|
@@ -32,7 +32,14 @@ module Genny
|
|
32
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
|
+
generated = []
|
36
|
+
count.times do
|
37
|
+
break if items.empty?
|
38
|
+
i = Random.rand(0...items.size)
|
39
|
+
generated.push(items[i].genny)
|
40
|
+
items.delete_at(i) if opts[:uniqueItems]
|
41
|
+
end
|
42
|
+
generated
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
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.4.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Genny likes to make things up. It generates ruby objects, mainly from
|
70
84
|
JSON Schema.
|
71
85
|
email:
|