bodhi-slam 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7df4ebf9c2577abec27eacc7953ea109db4aed6
4
- data.tar.gz: e890e28511e0d38ce8c64f9b2dbe51c02855de8b
3
+ metadata.gz: 3e24fa8d801c59a7acef1feb963981e247884d38
4
+ data.tar.gz: d5a098d7fd280e9d59977342968aa2ea198e69b2
5
5
  SHA512:
6
- metadata.gz: 7b64ca0e19980677f7440350a921f71584960057e5f6f2f4066c03a62f55f3ba15aea9ddda8d8f3e3223a452fe9f152220323a0f653c9b1b3d28cb3c43121ce4
7
- data.tar.gz: a3c470dc1558adcf74dde5516aedeabcec4d5c27c95b0b79a8fe627660a57a4d572d8a3151aa91852aa2d6a6641fc35efdd61d8915717d1db42a5786281c7cf0
6
+ metadata.gz: 9abc1448b20db9dd36920067a0539f0d87f51cc159b5e56f26d5cd156e518e858dad4769545832616470de95af86a22694f3e98ada744d47d4ee29b5e5ab71a7
7
+ data.tar.gz: e8063b4ab6dd1200d7c75d7ca28b9f0624b44789ef515e38e212b67b6ec7b52f69e3f63261d186246b19ed91968a3363f7a0ccf1885c6c54bd7eb6e6974a7bae
@@ -25,8 +25,8 @@ class BodhiSlam
25
25
  def self.analyze(context)
26
26
  raise context.errors unless context.valid?
27
27
 
28
- all_types = Bodhi::Type.find_all(context)
29
28
  all_enums = Bodhi::Enumeration.find_all(context)
29
+ all_types = Bodhi::Type.find_all(context)
30
30
  all_types.collect{ |type| Bodhi::Type.create_class_with(type) }
31
31
  end
32
32
  end
@@ -19,7 +19,7 @@ module Bodhi
19
19
 
20
20
  object = klass.new
21
21
  @generators.each_pair do |attribute, generator|
22
- if params[attribute]
22
+ if params.has_key?(attribute)
23
23
  object.send("#{attribute}=", params[attribute])
24
24
  else
25
25
  object.send("#{attribute}=", generator.call)
@@ -78,9 +78,9 @@ module Bodhi
78
78
 
79
79
  generator = lambda do
80
80
  if options[:multi]
81
- [*0..5].sample.times.collect{ [*0..50].sample.times.map{ characters[rand(characters.length)] }.join }
81
+ [*0..5].sample.times.collect{ [*0..100].sample.times.map{ characters[rand(characters.length)] }.join }
82
82
  else
83
- [*0..50].sample.times.map{ characters[rand(characters.length)] }.join
83
+ [*0..100].sample.times.map{ characters[rand(characters.length)] }.join
84
84
  end
85
85
  end
86
86
 
@@ -102,10 +102,13 @@ module Bodhi
102
102
  end
103
103
 
104
104
  when "Real"
105
+ options[:min].nil? ? min = -1483647.0 : min = options[:min]
106
+ options[:max].nil? ? max = 1483647.0 : max = options[:max]
107
+
105
108
  if options[:multi]
106
- generator = lambda { [*0..5].sample.times.collect{ SecureRandom.random_number*[-1,1,1,1].sample*[10,100,1000,10000].sample } }
109
+ generator = lambda { [*0..5].sample.times.collect{ rand(min..max) } }
107
110
  else
108
- generator = lambda { SecureRandom.random_number*[-1,1,1,1].sample*[10,100,1000,10000].sample }
111
+ generator = lambda { rand(min..max) }
109
112
  end
110
113
 
111
114
  when "Boolean"
@@ -132,20 +135,24 @@ module Bodhi
132
135
  when "Enumerated"
133
136
  generator = lambda do
134
137
  ref = options[:ref].split('.')
135
- name = ref[0]
138
+ enum_name = ref[0]
136
139
  field = ref[1]
137
140
 
141
+ if Bodhi::Enumeration.cache[enum_name.to_sym].nil?
142
+ raise RuntimeError.new("Cannot add generator for attribute: #{name}. #{enum_name} enumeration not found")
143
+ end
144
+
138
145
  if options[:multi]
139
146
  if field.nil?
140
- [*0..5].sample.times.collect{ Bodhi::Enumeration.cache[name.to_sym].values.sample }
147
+ [*0..5].sample.times.collect{ Bodhi::Enumeration.cache[enum_name.to_sym].values.sample }
141
148
  else
142
- [*0..5].sample.times.collect{ Bodhi::Enumeration.cache[name.to_sym].values.sample[field.to_sym] }
149
+ [*0..5].sample.times.collect{ Bodhi::Enumeration.cache[enum_name.to_sym].values.sample[field.to_sym] }
143
150
  end
144
151
  else
145
152
  if field.nil?
146
- Bodhi::Enumeration.cache[name.to_sym].values.sample
153
+ Bodhi::Enumeration.cache[enum_name.to_sym].values.sample
147
154
  else
148
- Bodhi::Enumeration.cache[name.to_sym].values.sample[field.to_sym]
155
+ Bodhi::Enumeration.cache[enum_name.to_sym].values.sample[field.to_sym]
149
156
  end
150
157
  end
151
158
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bodhi-slam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - willdavis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http-persistent