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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86078fd9dbc468dc0837688bd28c9ffbad043681
4
- data.tar.gz: 3de1f46815f7ec2cdb1511b8c24445277a06df7a
3
+ metadata.gz: d4afcea38652dfdf7e1a65d693c6816ef44d64fd
4
+ data.tar.gz: 12560dd7b090bc2120a8cf968295a056e61f43a4
5
5
  SHA512:
6
- metadata.gz: b83a8681897f5ef214d6aaa3ed729972c38e263bd91e62fa12cc555775fa2cb6e413bad80911d704eb027c553d06c08e2e3ef9b9628fb1e2a5669d11a9a475db
7
- data.tar.gz: b0fb6001de7b85bb2b60e9fea97f32466e5365d058bcfba4aa65548b1456fa4b14ec9202270c4c04bc4260c633ed2bc33b9a8d38475b1251ac261841d1251c57
6
+ metadata.gz: c7dc003d0c9b54dff78491e8929b24936ba83a6b9e07b5bdbb3cf9b22b890d03a1f784065d7750c1cc65ec7cdd135f43c6f5de7124c54fef03aae79c935e1471
7
+ data.tar.gz: 3a60ad2aab6f4ee29bfe9083f761114eabafd56143b95a39025780d6e364f4b1d1e67775685f7b89e90ee6f681831b1212dcffe6ed48d0ac04c7003f26a41ecd
@@ -27,7 +27,8 @@ module Muve
27
27
  @longitude = value.to_f
28
28
  end
29
29
 
30
- def random(center, range)
30
+ def save
31
+ true
31
32
  end
32
33
  end
33
34
  end
@@ -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
@@ -5,6 +5,7 @@ module Muve
5
5
  with_fields :name, :location
6
6
 
7
7
  def valid?
8
+ return false unless name
8
9
  return false unless location.kind_of?(Muve::Location) && location.valid?
9
10
  true
10
11
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Muve
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -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
@@ -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 'converts stored data to a workable object' do
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
@@ -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.0
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-12 00:00:00.000000000 Z
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: