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 +4 -4
- data/lib/bodhi-slam.rb +1 -1
- data/lib/bodhi-slam/factory.rb +17 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e24fa8d801c59a7acef1feb963981e247884d38
|
4
|
+
data.tar.gz: d5a098d7fd280e9d59977342968aa2ea198e69b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9abc1448b20db9dd36920067a0539f0d87f51cc159b5e56f26d5cd156e518e858dad4769545832616470de95af86a22694f3e98ada744d47d4ee29b5e5ab71a7
|
7
|
+
data.tar.gz: e8063b4ab6dd1200d7c75d7ca28b9f0624b44789ef515e38e212b67b6ec7b52f69e3f63261d186246b19ed91968a3363f7a0ccf1885c6c54bd7eb6e6974a7bae
|
data/lib/bodhi-slam.rb
CHANGED
@@ -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
|
data/lib/bodhi-slam/factory.rb
CHANGED
@@ -19,7 +19,7 @@ module Bodhi
|
|
19
19
|
|
20
20
|
object = klass.new
|
21
21
|
@generators.each_pair do |attribute, generator|
|
22
|
-
if params
|
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..
|
81
|
+
[*0..5].sample.times.collect{ [*0..100].sample.times.map{ characters[rand(characters.length)] }.join }
|
82
82
|
else
|
83
|
-
[*0..
|
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{
|
109
|
+
generator = lambda { [*0..5].sample.times.collect{ rand(min..max) } }
|
107
110
|
else
|
108
|
-
generator = lambda {
|
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
|
-
|
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[
|
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[
|
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[
|
153
|
+
Bodhi::Enumeration.cache[enum_name.to_sym].values.sample
|
147
154
|
else
|
148
|
-
Bodhi::Enumeration.cache[
|
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.
|
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-
|
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
|