bodhi-slam 0.8.0 → 0.8.1
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/factory.rb +95 -4
- data/lib/bodhi-slam/properties.rb +6 -0
- data/lib/bodhi-slam/resource.rb +1 -1
- data/lib/bodhi-slam/simulator.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb342b224cdd7e0845a8576ffda340df13b91368
|
4
|
+
data.tar.gz: 80000e6c757b7df93e627f3214c9f55a2adebbd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40c6c073da78ef1e048da472d1b1a0ecc26c8b8f73bd236eed22104646bc631d1c33aa4a5c91a4a9a24afa78758c9d47c976fb2f98869f9691291522cf744f7
|
7
|
+
data.tar.gz: 5366f40e16369940ff7518153e1711a241d1e4088a0fbda655f7081efcf26b56664cb6704c89af405f39e13cd57387133a40bb41844ed7d2b7bc5905ebe5bf58
|
data/lib/bodhi-slam/factory.rb
CHANGED
@@ -171,10 +171,77 @@ module Bodhi
|
|
171
171
|
end
|
172
172
|
|
173
173
|
when "GeoJSON"
|
174
|
+
# define the GeoJSON coordinate types
|
175
|
+
geojson_types = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"]
|
176
|
+
|
177
|
+
# define max/min longitude
|
178
|
+
min_long = -180.0
|
179
|
+
max_long = 180.0
|
180
|
+
|
181
|
+
# define max/min lattitude
|
182
|
+
min_lat = -90.0
|
183
|
+
max_lat = 90.0
|
184
|
+
|
174
185
|
if options[:multi]
|
175
|
-
generator = lambda
|
186
|
+
generator = lambda do
|
187
|
+
[*0..5].sample.times.collect do
|
188
|
+
type = geojson_types.sample
|
189
|
+
|
190
|
+
case type
|
191
|
+
when "Point"
|
192
|
+
coordinates = [rand(min_long..max_long), rand(min_lat..max_lat)]
|
193
|
+
when "MultiPoint"
|
194
|
+
coordinates = [*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
195
|
+
when "LineString"
|
196
|
+
coordinates = [*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
197
|
+
when "MultiLineString"
|
198
|
+
coordinates = [*2..10].sample.times.collect do
|
199
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
200
|
+
end
|
201
|
+
when "Polygon"
|
202
|
+
coordinates = [*2..10].sample.times.collect do
|
203
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
204
|
+
end
|
205
|
+
when "MultiPolygon"
|
206
|
+
coordinates = [*2..10].sample.times.collect do
|
207
|
+
[*2..10].sample.times.collect do
|
208
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
{ type: type, coordinates: coordinates }
|
214
|
+
end
|
215
|
+
end
|
176
216
|
else
|
177
|
-
generator = lambda
|
217
|
+
generator = lambda do
|
218
|
+
type = geojson_types.sample
|
219
|
+
|
220
|
+
case type
|
221
|
+
when "Point"
|
222
|
+
coordinates = [rand(min_long..max_long), rand(min_lat..max_lat)]
|
223
|
+
when "MultiPoint"
|
224
|
+
coordinates = [*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
225
|
+
when "LineString"
|
226
|
+
coordinates = [*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
227
|
+
when "MultiLineString"
|
228
|
+
coordinates = [*2..10].sample.times.collect do
|
229
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
230
|
+
end
|
231
|
+
when "Polygon"
|
232
|
+
coordinates = [*2..10].sample.times.collect do
|
233
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
234
|
+
end
|
235
|
+
when "MultiPolygon"
|
236
|
+
coordinates = [*2..10].sample.times.collect do
|
237
|
+
[*2..10].sample.times.collect do
|
238
|
+
[*2..10].sample.times.collect{ [rand(min_long..max_long), rand(min_lat..max_lat)] }
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
{ type: type, coordinates: coordinates }
|
244
|
+
end
|
178
245
|
end
|
179
246
|
|
180
247
|
when "Object"
|
@@ -186,9 +253,33 @@ module Bodhi
|
|
186
253
|
|
187
254
|
when "Link"
|
188
255
|
if options[:multi]
|
189
|
-
generator = lambda
|
256
|
+
generator = lambda do
|
257
|
+
[*0..5].sample.times.collect do
|
258
|
+
result = Hash.new
|
259
|
+
result[:href] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example
|
260
|
+
result[:name] = Regexp.new(/^.{10,20}$/).random_example if [true, false].sample == true
|
261
|
+
result[:title] = Regexp.new(/^.{10,20}$/).random_example if [true, false].sample == true
|
262
|
+
result[:templated] = [true, false].sample if [true, false].sample == true
|
263
|
+
result[:type] = ["application/json", "text/css", "application/exe", "zip"].sample if [true, false].sample == true
|
264
|
+
result[:deprecation] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example if [true, false].sample == true
|
265
|
+
result[:profile] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example if [true, false].sample == true
|
266
|
+
result[:hreflang] = ["en-us", "fr", "de"].sample if [true, false].sample == true
|
267
|
+
result
|
268
|
+
end
|
269
|
+
end
|
190
270
|
else
|
191
|
-
generator = lambda
|
271
|
+
generator = lambda do
|
272
|
+
result = Hash.new
|
273
|
+
result[:href] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example
|
274
|
+
result[:name] = Regexp.new(/^.{10,20}$/).random_example if [true, false].sample == true
|
275
|
+
result[:title] = Regexp.new(/^.{10,20}$/).random_example if [true, false].sample == true
|
276
|
+
result[:templated] = [true, false].sample if [true, false].sample == true
|
277
|
+
result[:type] = ["application/json", "text/css", "application/exe", "zip"].sample if [true, false].sample == true
|
278
|
+
result[:deprecation] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example if [true, false].sample == true
|
279
|
+
result[:profile] = Regexp.new(/^https?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).random_example if [true, false].sample == true
|
280
|
+
result[:hreflang] = ["en-us", "fr", "de"].sample if [true, false].sample == true
|
281
|
+
result
|
282
|
+
end
|
192
283
|
end
|
193
284
|
|
194
285
|
when "Enumerated"
|
@@ -38,6 +38,7 @@ module Bodhi
|
|
38
38
|
options = JSON.parse(options)
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set properties defined by the +options+ parameter
|
41
42
|
options = Bodhi::Support.symbolize_keys(options)
|
42
43
|
options.each do |property, value|
|
43
44
|
property_options = self.class.properties[property]
|
@@ -47,6 +48,11 @@ module Bodhi
|
|
47
48
|
send("#{property}=", Bodhi::Support.coerce(value, property_options))
|
48
49
|
end
|
49
50
|
end
|
51
|
+
|
52
|
+
# Set any default values
|
53
|
+
self.class.properties.select{ |k,v| !v[:default].nil? }.each do |property, property_options|
|
54
|
+
send("#{property}=", property_options[:default]) if send("#{property}").nil?
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
# Returns a Hash of the class properties and their values.
|
data/lib/bodhi-slam/resource.rb
CHANGED
@@ -140,7 +140,7 @@ module Bodhi
|
|
140
140
|
records << result.body
|
141
141
|
end while records.size == 100
|
142
142
|
|
143
|
-
records.flatten.collect{ |record| Object.const_get(name).new(record) }
|
143
|
+
records.flatten.collect{ |record| Object.const_get(name).new(record.merge(bodhi_context: context)) }
|
144
144
|
end
|
145
145
|
alias :all :find_all
|
146
146
|
|
data/lib/bodhi-slam/simulator.rb
CHANGED
@@ -55,7 +55,7 @@ module Bodhi
|
|
55
55
|
end
|
56
56
|
|
57
57
|
if simulation.current_frame.nil?
|
58
|
-
simulation.current_frame = Bodhi::SimulationFrame.new(
|
58
|
+
simulation.current_frame = Bodhi::SimulationFrame.new(time: simulation.starts_at)
|
59
59
|
else
|
60
60
|
simulation.current_frame.iteration = 0
|
61
61
|
simulation.current_frame.time = simulation.starts_at
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willdavis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
227
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.5
|
228
|
+
rubygems_version: 2.4.5
|
229
229
|
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: Ruby bindings for the Bodhi API & factories for random data generation
|