genny 0.4.1 → 0.4.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.
Files changed (5) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/lib/genny/array.rb +9 -2
  5. metadata +16 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTk3M2Q1ZGZkM2FlNWNlZmQ2NTBhYjc3OGFjM2E3NGI0MGQwNmNhZQ==
4
+ ZWI0NjNkOWNiOWJjODg2NTY0YTljNmJlZmE4ODc1MmYyODQxNDljZQ==
5
5
  data.tar.gz: !binary |-
6
- NTY5YjQzODFmODRkZWM0YmE3N2Q4MjhiOTk5MjMyNDI0ZTIzY2I2NA==
6
+ NGNmNmE4ZmMxMmRlNzBlZTRmMmRhMmMxZGUwMmNlOTQ5YjBkNGZhYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTJlNTMxMDhmNDljNWE0MzAzMDZlZjNjOTM2MjRiNzkxYmVlNTU2ZGJmZTdk
10
- MzNhYzZkOGM3ODhkOTA5ZTg3OGYxNjdmMzc1YjM0ZGE1OWMyYzg3YjE5NGIw
11
- MDc3MWM3NzZiNDY0NDA0YTA1MmM0MGViN2VhNjBkNjlkMzk1ZDc=
9
+ M2M3YTVhMGMwMzVmMTkzMGM3YjQwZmY3YTgzZDM1NDE4YzY2NzM2NjE1ODFi
10
+ OTBmMGNkOGU3MzRjN2Y4MzczZmNiMzU0OTg3MGM4OGI5NzE4ZGM4ZTE4N2Ey
11
+ YmUzZmQzZWVmMTRkYjNjNmQyYTU2ZmIxMzdjYzAzNGFhNzZkNDE=
12
12
  data.tar.gz: !binary |-
13
- YmZhNDhmY2RkN2IwMWFmNzRkNjBiY2U4M2Y2NjM3ZTAyY2Y0ZTVmZmIzNDli
14
- MTNmMzI5YjBmMTVjMzllZTJhODU1ZGMxNjExN2YxYThjYjdiNzQ0ZDNkZmNl
15
- NjA3NmU5NDBhMzE1ODkwZmQxZTRhNzM4NDdjYmYwZWNjNjEwMjY=
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
1
+ 0.4.2
@@ -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
- return count.times.map { items.sample.genny }
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.1
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-04 00:00:00.000000000 Z
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: