dm-parse 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.16
1
+ 0.3.17
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dm-parse"
8
- s.version = "0.3.16"
8
+ s.version = "0.3.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zhi-Qiang Lei"]
12
- s.date = "2012-08-16"
12
+ s.date = "2012-08-28"
13
13
  s.description = "An extension to make DataMapper working on Parse.com"
14
14
  s.email = "zhiqiang.lei@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -4,24 +4,24 @@ module DataMapper
4
4
  class ParseGeoPoint < Object
5
5
 
6
6
  def dump(value)
7
- value && {"__type" => "GeoPoint", "latitude" => value["lat"].to_f, "longitude" => value["lng"].to_f}
7
+ value && value.merge("__type" => "GeoPoint")
8
8
  end
9
9
 
10
10
  def load(value)
11
- value && {"lat" => value["latitude"], "lng" => value["longitude"]}
11
+ value
12
12
  end
13
13
 
14
14
  def typecast(value)
15
15
  case value
16
16
  when ::Hash
17
- lat = value["lat"]
18
- lng = value["lng"]
19
- { "lat" => lat, "lng" => lng } if lat.present? && lng.present?
17
+ lat = value["latitude"]
18
+ lng = value["longitude"]
19
+ { "latitude" => lat.to_f, "longitude" => lng.to_f } if lat.present? && lng.present?
20
20
  end
21
21
  end
22
22
 
23
23
  def valid?(value)
24
- return false if value && (value["lat"].blank? || value["lng"].blank?)
24
+ return false if value && (value["latitude"].blank? || value["longitude"].blank?)
25
25
  super
26
26
  end
27
27
  end
@@ -155,12 +155,12 @@ describe Company do
155
155
  subject { described_class.new attributes }
156
156
 
157
157
  let(:attributes) { { location: location } }
158
- let(:location) { { "lat" => "5.0", "lng" => "0.0" } }
158
+ let(:location) { { "latitude" => "5.0", "longitude" => "0.0" } }
159
159
 
160
160
  it { should be_valid }
161
161
 
162
162
  context "when location is invalid" do
163
- let(:location) { { "lat" => "", "lng" => "" } }
163
+ let(:location) { { "latitude" => "", "longitude" => "" } }
164
164
 
165
165
  it { should_not be_valid }
166
166
  end
@@ -8,9 +8,9 @@ describe DataMapper::Property::ParseGeoPoint do
8
8
  describe "#dump" do
9
9
  subject { property.dump value }
10
10
 
11
- let(:value) { { "lat" => "20", "lng" => "50" } }
11
+ let(:value) { { "latitude" => 20.0, "longitude" => 50.0 } }
12
12
 
13
- it { should eq("__type" => "GeoPoint", "latitude" => value["lat"].to_f, "longitude" => value["lng"].to_f) }
13
+ it { should eq("__type" => "GeoPoint", "latitude" => 20.0, "longitude" => 50.0) }
14
14
 
15
15
  context "when value is nil" do
16
16
  let(:value) { nil }
@@ -24,7 +24,7 @@ describe DataMapper::Property::ParseGeoPoint do
24
24
 
25
25
  let(:value) { { "__type" => "GeoPoint", "latitude" => 20.0, "longitude" => 50.0 } }
26
26
 
27
- it { should eq("lat" => value["latitude"], "lng" => value["longitude"]) }
27
+ it { should eq(value) }
28
28
 
29
29
  context "when value is nil" do
30
30
  let(:value) { nil }
@@ -36,31 +36,31 @@ describe DataMapper::Property::ParseGeoPoint do
36
36
  describe "#valid?" do
37
37
  subject { property.valid? value }
38
38
 
39
- let(:value) { { "lat" => lat, "lng" => lng } }
39
+ let(:value) { { "latitude" => lat, "longitude" => lng } }
40
40
  let(:lat) { "20.0" }
41
41
  let(:lng) { "50.0" }
42
42
 
43
43
  it { should be_true }
44
44
 
45
- context "when lat is nil" do
45
+ context "when latitude is nil" do
46
46
  let(:lat) { nil }
47
47
 
48
48
  it { should be_false }
49
49
  end
50
50
 
51
- context "when lat is empty string" do
51
+ context "when latitude is empty string" do
52
52
  let(:lat) { "" }
53
53
 
54
54
  it { should be_false }
55
55
  end
56
56
 
57
- context "when lng is nil" do
57
+ context "when longitude is nil" do
58
58
  let(:lng) { nil }
59
59
 
60
60
  it { should be_false }
61
61
  end
62
62
 
63
- context "when lng is empty string" do
63
+ context "when longitude is empty string" do
64
64
  let(:lng) { "" }
65
65
 
66
66
  it { should be_false }
@@ -76,31 +76,31 @@ describe DataMapper::Property::ParseGeoPoint do
76
76
  describe "#typecast" do
77
77
  subject { property.typecast value }
78
78
 
79
- let(:value) { { "lat" => lat, "lng" => lng } }
79
+ let(:value) { { "latitude" => lat, "longitude" => lng } }
80
80
  let(:lat) { "20.0" }
81
81
  let(:lng) { "50.0" }
82
82
 
83
- it { should eq(value) }
83
+ it { should eq("latitude" => lat.to_f, "longitude" => lng.to_f) }
84
84
 
85
- context "when lat is nil" do
85
+ context "when latitude is nil" do
86
86
  let(:lat) { nil }
87
87
 
88
88
  it { should be_blank }
89
89
  end
90
90
 
91
- context "when lat is empty string" do
91
+ context "when latitude is empty string" do
92
92
  let(:lat) { "" }
93
93
 
94
94
  it { should be_blank }
95
95
  end
96
96
 
97
- context "when lng is nil" do
97
+ context "when longitude is nil" do
98
98
  let(:lng) { nil }
99
99
 
100
100
  it { should be_blank }
101
101
  end
102
102
 
103
- context "when lng is empty string" do
103
+ context "when longitude is empty string" do
104
104
  let(:lng) { "" }
105
105
 
106
106
  it { should be_blank }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-parse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.16
4
+ version: 0.3.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dm-core
@@ -258,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
258
  version: '0'
259
259
  segments:
260
260
  - 0
261
- hash: -3903379747305984450
261
+ hash: -1110332828123516189
262
262
  required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  none: false
264
264
  requirements: