dm-parse 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dm-parse.gemspec +2 -2
- data/lib/property/parse_geo_point.rb +10 -1
- data/spec/integration_spec.rb +15 -0
- data/spec/parse_geo_point_spec.rb +46 -0
- data/spec/spec_helper.rb +8 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
data/dm-parse.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dm-parse"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.11"
|
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-07-
|
12
|
+
s.date = "2012-07-07"
|
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 = [
|
@@ -11,8 +11,17 @@ module DataMapper
|
|
11
11
|
value && {"lat" => value["latitude"], "lng" => value["longitude"]}
|
12
12
|
end
|
13
13
|
|
14
|
+
def typecast(value)
|
15
|
+
case value
|
16
|
+
when ::Hash
|
17
|
+
lat = value["lat"]
|
18
|
+
lng = value["lng"]
|
19
|
+
{ "lat" => lat, "lng" => lng } if lat.present? && lng.present?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
14
23
|
def valid?(value)
|
15
|
-
return false if value && (value["lat"].
|
24
|
+
return false if value && (value["lat"].blank? || value["lng"].blank?)
|
16
25
|
super
|
17
26
|
end
|
18
27
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -145,6 +145,21 @@ describe User do
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
+
describe Company do
|
149
|
+
subject { described_class.new attributes }
|
150
|
+
|
151
|
+
let(:attributes) { { location: location } }
|
152
|
+
let(:location) { { "lat" => "5.0", "lng" => "0.0" } }
|
153
|
+
|
154
|
+
it { should be_valid }
|
155
|
+
|
156
|
+
context "when location is invalid" do
|
157
|
+
let(:location) { { "lat" => "", "lng" => "" } }
|
158
|
+
|
159
|
+
it { should_not be_valid }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
148
163
|
describe "adapter" do
|
149
164
|
subject { adapter }
|
150
165
|
|
@@ -48,16 +48,62 @@ describe DataMapper::Property::ParseGeoPoint do
|
|
48
48
|
it { should be_false }
|
49
49
|
end
|
50
50
|
|
51
|
+
context "when lat is empty string" do
|
52
|
+
let(:lat) { "" }
|
53
|
+
|
54
|
+
it { should be_false }
|
55
|
+
end
|
56
|
+
|
51
57
|
context "when lng is nil" do
|
52
58
|
let(:lng) { nil }
|
53
59
|
|
54
60
|
it { should be_false }
|
55
61
|
end
|
56
62
|
|
63
|
+
context "when lng is empty string" do
|
64
|
+
let(:lng) { "" }
|
65
|
+
|
66
|
+
it { should be_false }
|
67
|
+
end
|
68
|
+
|
57
69
|
context "when value is nil" do
|
58
70
|
let(:value) { nil }
|
59
71
|
|
60
72
|
it { should be_true }
|
61
73
|
end
|
62
74
|
end
|
75
|
+
|
76
|
+
describe "#typecast" do
|
77
|
+
subject { property.typecast value }
|
78
|
+
|
79
|
+
let(:value) { { "lat" => lat, "lng" => lng } }
|
80
|
+
let(:lat) { "20.0" }
|
81
|
+
let(:lng) { "50.0" }
|
82
|
+
|
83
|
+
it { should eq(value) }
|
84
|
+
|
85
|
+
context "when lat is nil" do
|
86
|
+
let(:lat) { nil }
|
87
|
+
|
88
|
+
it { should be_blank }
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when lat is empty string" do
|
92
|
+
let(:lat) { "" }
|
93
|
+
|
94
|
+
it { should be_blank }
|
95
|
+
end
|
96
|
+
|
97
|
+
context "when lng is nil" do
|
98
|
+
let(:lng) { nil }
|
99
|
+
|
100
|
+
it { should be_blank }
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when lng is empty string" do
|
104
|
+
let(:lng) { "" }
|
105
|
+
|
106
|
+
it { should be_blank }
|
107
|
+
end
|
108
|
+
end
|
63
109
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.3.11
|
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-07-
|
12
|
+
date: 2012-07-07 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: -
|
261
|
+
hash: -1903385392634618347
|
262
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
263
|
none: false
|
264
264
|
requirements:
|