gogo_maps 0.2.71800000 → 0.2.71820000

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cca77fa34fe98578ebcc5038b66461eb997928e1
4
- data.tar.gz: dc489546114cc512ecfbd7d52a1043c70f3d2010
3
+ metadata.gz: db4c8634368f5b0e01be00a13572a0d4079a5638
4
+ data.tar.gz: 459464e04f19070b0ed0cde7aec6b209b5da43e8
5
5
  SHA512:
6
- metadata.gz: ff69ce8e7bd8a4a5377abd73a7b288c86a02d244a8d20e3513b9af57e11f674cbf7984fdd0ae0984c2db4046565653f91b42ec49d27d4ddbdb16530c31a9690a
7
- data.tar.gz: 9b36a9a782d346f96802ce5f1a9be77d8604bca1173fe59a51b2bc24c2f6002d23dc25b05f59008bbb62a66d08bc4fcc99b16db651aeac97b2ed10116bed7c41
6
+ metadata.gz: 271b8ba101defcf6623efc0805216d9d0e8fada4852e462ac798039a9937bc9afb64166189ecf06a393eaf5162df871dccd17b5331ebc685ba006acfe62b82ae
7
+ data.tar.gz: 8080f8c88f15558b0fcb6b4b3983df5f7a6569cb499a6a6b657c86a2985d38f629b13d55cd1d36106aaf26d6af10141f2e415438a2109c45047a17d10efed96c
@@ -1,4 +1,4 @@
1
1
  module GogoMaps
2
2
  # Napier's constant
3
- VERSION = "0.2.71800000"
3
+ VERSION = "0.2.71820000"
4
4
  end
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 get(opts={})
9
- fail 'Should provide either address or latlng' unless opts[:address] || opts[:latlng]
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
- opts[:address] ? :to_latlng : :to_address
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
- get({latlng:[lat, lng].join(',')}.merge(opts))
26
+ get_address([lat, lng].join(','), opts)
21
27
  rescue
22
28
  random #FIXIT:
23
29
  end
@@ -6,53 +6,47 @@ describe GogoMaps do
6
6
  expect(GogoMaps::VERSION).not_to be nil
7
7
  end
8
8
 
9
- describe '.get' do
10
- it 'should raise error' do
11
- expect { GogoMaps.get }.to raise_error(RuntimeError)
12
- end
13
-
14
- context 'to_latlng' do
15
- it 'should return proper parameters' do
16
- expect(
17
- GogoMaps.get(address: '長野県上高井郡高山村')
18
- ).to eq(
19
- { lat: 36.6797676, lng: 138.3632554 }
20
- )
21
- expect(
22
- GogoMaps.get(address: '神奈川県横浜市港北区日吉')
23
- ).to eq(
24
- { lat: 35.5565107, lng: 139.6460026 }
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
- context 'to_address' do
35
- it 'should return proper parameters' do
36
- expect(
37
- GogoMaps.get(latlng: '35.6506135,139.7539103')
38
- ).to eq(
39
- '日本, 東京都港区芝1丁目11−14'
40
- )
41
- expect(
42
- GogoMaps.get(latlng: '37.358126,-122.050636', language: :en)
43
- ).to eq(
44
- '902 Rockefeller Drive, Sunnyvale, CA 94087, USA'
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
- context '#random' do
50
- it 'should return proper parameters' do
51
- expect(
52
- GogoMaps.random
53
- ).not_to be_nil
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogo_maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.71800000
4
+ version: 0.2.71820000
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka