gogo_maps 0.2.71800000 → 0.2.71820000
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gogo_maps/version.rb +1 -1
- data/lib/gogo_maps.rb +11 -5
- data/spec/gogo_maps_spec.rb +37 -43
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db4c8634368f5b0e01be00a13572a0d4079a5638
|
4
|
+
data.tar.gz: 459464e04f19070b0ed0cde7aec6b209b5da43e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 271b8ba101defcf6623efc0805216d9d0e8fada4852e462ac798039a9937bc9afb64166189ecf06a393eaf5162df871dccd17b5331ebc685ba006acfe62b82ae
|
7
|
+
data.tar.gz: 8080f8c88f15558b0fcb6b4b3983df5f7a6569cb499a6a6b657c86a2985d38f629b13d55cd1d36106aaf26d6af10141f2e415438a2109c45047a17d10efed96c
|
data/lib/gogo_maps/version.rb
CHANGED
data/lib/gogo_maps.rb
CHANGED
@@ -5,19 +5,25 @@ require 'json'
|
|
5
5
|
module GogoMaps
|
6
6
|
class << self
|
7
7
|
# @param Hash opts - to support below Ruby1.9x.
|
8
|
-
def
|
9
|
-
|
8
|
+
def get_latlng(address, opts={})
|
9
|
+
GoogleMapClient.call(
|
10
|
+
{ address: address, language: :ja, sensor: false }.merge(opts),
|
11
|
+
:to_latlng
|
12
|
+
)
|
13
|
+
end
|
10
14
|
|
15
|
+
# @param Hash opts - to support below Ruby1.9x.
|
16
|
+
def get_address(latlng, opts={})
|
11
17
|
GoogleMapClient.call(
|
12
|
-
{ language: :ja, sensor: false }.merge(opts),
|
13
|
-
|
18
|
+
{ latlng: latlng, language: :ja, sensor: false }.merge(opts),
|
19
|
+
:to_address
|
14
20
|
)
|
15
21
|
end
|
16
22
|
|
17
23
|
def random(opts={})
|
18
24
|
lat = ((-180..180).to_a.sample + rand).round(8)
|
19
25
|
lng = ((-180..180).to_a.sample + rand).round(8)
|
20
|
-
|
26
|
+
get_address([lat, lng].join(','), opts)
|
21
27
|
rescue
|
22
28
|
random #FIXIT:
|
23
29
|
end
|
data/spec/gogo_maps_spec.rb
CHANGED
@@ -6,53 +6,47 @@ describe GogoMaps do
|
|
6
6
|
expect(GogoMaps::VERSION).not_to be nil
|
7
7
|
end
|
8
8
|
|
9
|
-
describe '
|
10
|
-
it 'should
|
11
|
-
expect
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
expect(
|
27
|
-
GogoMaps.get(address: '902 Rockefeller Dr, Sunnyvale, CA', language: :en)
|
28
|
-
).to eq(
|
29
|
-
{ lat: 37.358126, lng: -122.050636 }
|
30
|
-
)
|
31
|
-
end
|
9
|
+
describe '#get_latlng' do
|
10
|
+
it 'should return proper parameters' do
|
11
|
+
expect(
|
12
|
+
GogoMaps.get_latlng('長野県上高井郡高山村')
|
13
|
+
).to eq(
|
14
|
+
{ lat: 36.6797676, lng: 138.3632554 }
|
15
|
+
)
|
16
|
+
expect(
|
17
|
+
GogoMaps.get_latlng('神奈川県横浜市港北区日吉')
|
18
|
+
).to eq(
|
19
|
+
{ lat: 35.5565107, lng: 139.6460026 }
|
20
|
+
)
|
21
|
+
expect(
|
22
|
+
GogoMaps.get_latlng('902 Rockefeller Dr, Sunnyvale, CA', language: :en)
|
23
|
+
).to eq(
|
24
|
+
{ lat: 37.358126, lng: -122.050636 }
|
25
|
+
)
|
32
26
|
end
|
27
|
+
end
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
29
|
+
describe 'get_address' do
|
30
|
+
it 'should return proper parameters' do
|
31
|
+
expect(
|
32
|
+
GogoMaps.get_address('35.6506135,139.7539103')
|
33
|
+
).to eq(
|
34
|
+
'日本, 東京都港区芝1丁目11−14'
|
35
|
+
)
|
36
|
+
expect(
|
37
|
+
GogoMaps.get_address('37.358126,-122.050636', language: :en)
|
38
|
+
).to eq(
|
39
|
+
'902 Rockefeller Drive, Sunnyvale, CA 94087, USA'
|
40
|
+
)
|
47
41
|
end
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
44
|
+
describe '#random' do
|
45
|
+
it 'should return proper parameters' do
|
46
|
+
expect(
|
47
|
+
GogoMaps.random
|
48
|
+
).not_to be_nil
|
55
49
|
end
|
56
|
-
|
57
50
|
end
|
51
|
+
|
58
52
|
end
|