muve 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/muve/location.rb +2 -1
- data/lib/muve/model.rb +8 -8
- data/lib/muve/place.rb +1 -0
- data/lib/muve/store.rb +1 -1
- data/lib/muve/version.rb +1 -1
- data/spec/factories.rb +17 -0
- data/spec/model_spec.rb +2 -2
- data/spec/place_spec.rb +12 -0
- 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: d4afcea38652dfdf7e1a65d693c6816ef44d64fd
|
4
|
+
data.tar.gz: 12560dd7b090bc2120a8cf968295a056e61f43a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7dc003d0c9b54dff78491e8929b24936ba83a6b9e07b5bdbb3cf9b22b890d03a1f784065d7750c1cc65ec7cdd135f43c6f5de7124c54fef03aae79c935e1471
|
7
|
+
data.tar.gz: 3a60ad2aab6f4ee29bfe9083f761114eabafd56143b95a39025780d6e364f4b1d1e67775685f7b89e90ee6f681831b1212dcffe6ed48d0ac04c7003f26a41ecd
|
data/lib/muve/location.rb
CHANGED
data/lib/muve/model.rb
CHANGED
@@ -28,7 +28,7 @@ module Muve
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def reload
|
31
|
-
self.send(:populate, extract(adaptor.get(self.class, id))) if id
|
31
|
+
self.send(:populate, extract(adaptor.get(self.class, id), self.class)) if id
|
32
32
|
self
|
33
33
|
end
|
34
34
|
|
@@ -202,8 +202,8 @@ module Muve
|
|
202
202
|
self.class.adaptor
|
203
203
|
end
|
204
204
|
|
205
|
-
def extract(storeable)
|
206
|
-
self.class.extract(storeable)
|
205
|
+
def extract(storeable, klass=nil)
|
206
|
+
self.class.extract(storeable, klass)
|
207
207
|
end
|
208
208
|
|
209
209
|
def convert(resource)
|
@@ -231,8 +231,8 @@ module Muve
|
|
231
231
|
@adaptor or Model.handler
|
232
232
|
end
|
233
233
|
|
234
|
-
def extract(storeable)
|
235
|
-
adaptor.formatter.convert_from_storeable_object(storeable)
|
234
|
+
def extract(storeable, klass=nil)
|
235
|
+
adaptor.formatter.convert_from_storeable_object(storeable, klass)
|
236
236
|
end
|
237
237
|
|
238
238
|
def convert(resource)
|
@@ -273,8 +273,8 @@ module Muve
|
|
273
273
|
|
274
274
|
# Finds a resource by id
|
275
275
|
def find(id)
|
276
|
-
result = self.new
|
277
|
-
result.send(:populate, extract(self.adaptor.get(self, id)))
|
276
|
+
result = self.new
|
277
|
+
result.send(:populate, extract(self.adaptor.get(self, id), result.class))
|
278
278
|
result
|
279
279
|
end
|
280
280
|
|
@@ -285,7 +285,7 @@ module Muve
|
|
285
285
|
(self.adaptor.get(self, nil, params) or []).each do |details|
|
286
286
|
details
|
287
287
|
result = self.new()
|
288
|
-
result.send(:populate, extract(details))
|
288
|
+
result.send(:populate, extract(details, self.new.class))
|
289
289
|
item << result
|
290
290
|
end
|
291
291
|
end
|
data/lib/muve/place.rb
CHANGED
data/lib/muve/store.rb
CHANGED
@@ -21,7 +21,7 @@ module Muve
|
|
21
21
|
raise IncompleteImplementation, "convertor to storeable needed"
|
22
22
|
end
|
23
23
|
|
24
|
-
def convert_from_storeable_object(storeable)
|
24
|
+
def convert_from_storeable_object(storeable, klass=nil)
|
25
25
|
raise IncompleteImplementation, "convertor from storeable needed"
|
26
26
|
end
|
27
27
|
end
|
data/lib/muve/version.rb
CHANGED
data/spec/factories.rb
CHANGED
@@ -2,20 +2,37 @@ FactoryGirl.define do
|
|
2
2
|
factory Muve::Location do
|
3
3
|
lat { Faker::Geolocation.lat }
|
4
4
|
long { Faker::Geolocation.lng }
|
5
|
+
|
6
|
+
trait :invalid do
|
7
|
+
lat { 200 }
|
8
|
+
long { 200 }
|
9
|
+
end
|
5
10
|
end
|
6
11
|
|
7
12
|
factory Muve::Traveller do
|
8
13
|
name { Faker::Name.name }
|
14
|
+
|
15
|
+
trait :invalid do
|
16
|
+
name { nil }
|
17
|
+
end
|
9
18
|
end
|
10
19
|
|
11
20
|
factory Muve::Movement do
|
12
21
|
traveller { build Muve::Traveller }
|
13
22
|
location { build Muve::Location }
|
14
23
|
time { Time.now - rand(500000) }
|
24
|
+
|
25
|
+
trait :invalid do
|
26
|
+
location { build Muve::Location, :invalid }
|
27
|
+
end
|
15
28
|
end
|
16
29
|
|
17
30
|
factory Muve::Place do
|
18
31
|
name { Faker::Venue.name }
|
19
32
|
location { build Muve::Location }
|
33
|
+
|
34
|
+
trait :invalid do
|
35
|
+
location { build Muve::Location, :invalid }
|
36
|
+
end
|
20
37
|
end
|
21
38
|
end
|
data/spec/model_spec.rb
CHANGED
@@ -287,7 +287,7 @@ describe 'Model' do
|
|
287
287
|
resource
|
288
288
|
end
|
289
289
|
|
290
|
-
def self.convert_from_storeable_object(storeable)
|
290
|
+
def self.convert_from_storeable_object(storeable, klass=nil)
|
291
291
|
storeable
|
292
292
|
end
|
293
293
|
end
|
@@ -393,7 +393,7 @@ describe 'Model' do
|
|
393
393
|
expect(AnotherResource.find(@id).new_record?).to be(false)
|
394
394
|
end
|
395
395
|
|
396
|
-
it '
|
396
|
+
it 'calls the extractor on a call' do
|
397
397
|
expect(AnotherResource).to receive(:extract).at_least(:once)
|
398
398
|
AnotherResource.find(@id)
|
399
399
|
end
|
data/spec/place_spec.rb
CHANGED
@@ -12,4 +12,16 @@ describe Muve::Place do
|
|
12
12
|
expect(build Muve::Place, location: build(Muve::Location, latitude: -100)).to be_invalid
|
13
13
|
expect(build Muve::Place, location: build(Muve::Location)).to be_valid
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'is invalid when the name is not specified' do
|
17
|
+
expect(build Muve::Place, name: nil).to be_invalid
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'is invalid when the location is invalid' do
|
21
|
+
expect(build Muve::Place, location: build(Muve::Location, :invalid)).to be_invalid
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'is valid when all field are set' do
|
25
|
+
expect(build Muve::Place).to be_valid
|
26
|
+
end
|
15
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Asabina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Basic helpers to be used with Muvement
|
14
14
|
email:
|