naver_map 0.1.1 → 0.2.0
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 +4 -4
- data/.gitignore +5 -1
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +6 -20
- data/README.md +11 -1
- data/Rakefile +4 -1
- data/lib/naver_map.rb +28 -21
- data/lib/naver_map/version.rb +1 -1
- data/naver_map.gemspec +0 -3
- metadata +4 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d8d9f1c46030d5b2509621c5c4b7c1d11e395c5
|
4
|
+
data.tar.gz: 93c0795ddd0944b81bff9211e659266533bb22ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab76059381cac9f5a6e736f87f87964827e9ce5471f4cc6829dbd25b2facafd01b63e3ab1de3394c5feb5ca395f5f05a95806efccc25ef6a67a6df6b1ffa1594
|
7
|
+
data.tar.gz: 3d93fe65eb61a0a258f2bf670178fb7194a0e2ea2c2c2ac8e127c2cf199250dec4acdcb6b2cd14be9ffd5550054e11b153c97632ae857edfdc9243fedb7d05b6
|
data/.gitignore
CHANGED
@@ -61,6 +61,7 @@ build-iPhoneSimulator/
|
|
61
61
|
.idea/dictionaries
|
62
62
|
.idea/vcs.xml
|
63
63
|
.idea/jsLibraryMappings.xml
|
64
|
+
.idea/.rakeTasks
|
64
65
|
|
65
66
|
# Sensitive or high-churn files:
|
66
67
|
.idea/dataSources.ids
|
@@ -98,4 +99,7 @@ crashlytics-build.properties
|
|
98
99
|
fabric.properties
|
99
100
|
|
100
101
|
icon.png
|
101
|
-
|
102
|
+
|
103
|
+
# ctags
|
104
|
+
tags
|
105
|
+
.tags
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -3,5 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in naver_map.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'rest-client', '2.0.0'
|
7
|
-
gem '
|
6
|
+
gem 'rest-client', '~> 2.0.0'
|
7
|
+
gem 'minitest', '~> 5.8.3'
|
8
|
+
|
9
|
+
group :development, :test do
|
10
|
+
gem 'rake', '~> 11.2.2'
|
11
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
naver_map (0.1.
|
5
|
-
rest-client (~> 2.0.0, >= 2.0.0)
|
4
|
+
naver_map (0.1.1)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
9
8
|
specs:
|
10
|
-
diff-lcs (1.2.5)
|
11
9
|
domain_name (0.5.20161021)
|
12
10
|
unf (>= 0.0.5, < 1.0.0)
|
13
11
|
http-cookie (1.0.3)
|
@@ -15,25 +13,13 @@ GEM
|
|
15
13
|
mime-types (3.1)
|
16
14
|
mime-types-data (~> 3.2015)
|
17
15
|
mime-types-data (3.2016.0521)
|
16
|
+
minitest (5.8.3)
|
18
17
|
netrc (0.11.0)
|
19
|
-
rake (
|
18
|
+
rake (11.2.2)
|
20
19
|
rest-client (2.0.0)
|
21
20
|
http-cookie (>= 1.0.2, < 2.0)
|
22
21
|
mime-types (>= 1.16, < 4.0)
|
23
22
|
netrc (~> 0.8)
|
24
|
-
rspec (3.5.0)
|
25
|
-
rspec-core (~> 3.5.0)
|
26
|
-
rspec-expectations (~> 3.5.0)
|
27
|
-
rspec-mocks (~> 3.5.0)
|
28
|
-
rspec-core (3.5.4)
|
29
|
-
rspec-support (~> 3.5.0)
|
30
|
-
rspec-expectations (3.5.0)
|
31
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.5.0)
|
33
|
-
rspec-mocks (3.5.0)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.5.0)
|
36
|
-
rspec-support (3.5.0)
|
37
23
|
unf (0.1.4)
|
38
24
|
unf_ext
|
39
25
|
unf_ext (0.0.7.2)
|
@@ -43,10 +29,10 @@ PLATFORMS
|
|
43
29
|
|
44
30
|
DEPENDENCIES
|
45
31
|
bundler (~> 1.13)
|
32
|
+
minitest (~> 5.8.3)
|
46
33
|
naver_map!
|
47
|
-
rake (~>
|
48
|
-
rest-client (
|
49
|
-
rspec
|
34
|
+
rake (~> 11.2.2)
|
35
|
+
rest-client (~> 2.0.0)
|
50
36
|
|
51
37
|
BUNDLED WITH
|
52
38
|
1.13.6
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# NaverMap
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/naver_map)
|
4
|
+
[](https://travis-ci.org/say8425/naver_map_ruby)
|
5
|
+
|
3
6
|
This is ruby gem for using Naver Map API.
|
4
7
|
|
5
8
|
## Installation
|
@@ -28,13 +31,20 @@ city_hall = NaverMap.new('input your client id', 'input your client secret')
|
|
28
31
|
|
29
32
|
First you need to confirm your Naver API client id and client secret key. You can confirm it at [Naver Developer Application page](https://developers.naver.com/appinfo).
|
30
33
|
Then you can initialize `naver_map` with your client id and client secret key.
|
34
|
+
|
35
|
+
### Get coordinates with address
|
31
36
|
|
32
37
|
```ruby
|
33
38
|
city_hall.address_to_coordinates('서울특별시 중구 세종대로 110 서울특별시청')
|
34
39
|
=> [{:x=>126.9783882, :y=>37.5666103}]
|
35
40
|
```
|
36
41
|
|
37
|
-
|
42
|
+
You can get coordinates with your inputting address. This return is array, cuz coordinates can be multiplle value.
|
43
|
+
But we are plan to when return is single value then make return is not array.
|
44
|
+
|
45
|
+
### Getting address with coordinates
|
46
|
+
|
47
|
+
|
38
48
|
|
39
49
|
## Contributing
|
40
50
|
|
data/Rakefile
CHANGED
data/lib/naver_map.rb
CHANGED
@@ -5,36 +5,43 @@ require 'json'
|
|
5
5
|
class NaverMap
|
6
6
|
attr_accessor :client_id, :client_secret
|
7
7
|
|
8
|
+
GEOCODE_REQUEST_URL = 'https://openapi.naver.com/v1/map/geocode'.freeze
|
9
|
+
REVERSE_GEOCODE_URL = 'https://openapi.naver.com/v1/map/reversegeocode'.freeze
|
10
|
+
|
8
11
|
def initialize(client_id, client_secret)
|
9
12
|
@client_id = client_id
|
10
13
|
@client_secret = client_secret
|
11
14
|
end
|
12
15
|
|
13
16
|
def address_to_coordinates(address)
|
14
|
-
|
15
|
-
|
16
|
-
response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
|
17
|
-
'X-Naver-Client-Secret': @client_secret)
|
18
|
-
result = JSON.parse(response.body, symbolize_names: true)[:result]
|
19
|
-
result[:items].map do |element| element[:point] end
|
20
|
-
rescue RestClient::ExceptionWithResponse => err
|
21
|
-
err.response.body
|
22
|
-
end
|
17
|
+
response = query(GEOCODE_REQUEST_URL, address)
|
18
|
+
get_result(response.body)[:items].map { |element| element[:point] }
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
url = 'https://openapi.naver.com/v1/map/geocode'
|
29
|
-
response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
|
30
|
-
'X-Naver-Client-Secret': @client_secret)
|
31
|
-
JSON.parse(response.body, symbolize_names: true)[:result]
|
32
|
-
rescue RestClient::ExceptionWithResponse => err
|
33
|
-
err.response.body
|
34
|
-
end
|
21
|
+
def coordinates_to_address(axis_x, axis_y)
|
22
|
+
response = query(REVERSE_GEOCODE_URL, axis_x, axis_y)
|
23
|
+
get_result(response.body)[:items].map { |element| element[:address] }
|
35
24
|
end
|
36
25
|
|
37
26
|
def to_s
|
38
|
-
"Client ID: #{
|
27
|
+
"Client ID: #{client_id}, Client Secret: #{client_secret}"
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def get_result(body)
|
33
|
+
JSON.parse(body, symbolize_names: true)[:result]
|
34
|
+
end
|
35
|
+
|
36
|
+
def request_to_naver(url, *params)
|
37
|
+
RestClient.get(url, params: { query: params.join(',') },
|
38
|
+
'X-Naver-Client-Id': client_id,
|
39
|
+
'X-Naver-Client-Secret': client_secret)
|
40
|
+
end
|
41
|
+
|
42
|
+
def query(url, *params)
|
43
|
+
request_to_naver(url, params)
|
44
|
+
rescue RestClient::ExceptionWithResponse => err
|
45
|
+
err.response.body
|
39
46
|
end
|
40
|
-
end
|
47
|
+
end
|
data/lib/naver_map/version.rb
CHANGED
data/naver_map.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naver_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Penguin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,40 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.13'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rest-client
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0.0
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 2.0.0
|
51
|
-
type: :runtime
|
52
|
-
prerelease: false
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 2.0.0
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 2.0.0
|
61
27
|
description: |-
|
62
28
|
Naver support map API. But we don't have any ruby gem for this API.
|
63
29
|
So You can use it with this gem comfortable.
|
@@ -70,6 +36,8 @@ files:
|
|
70
36
|
- ".idea/encodings.xml"
|
71
37
|
- ".idea/misc.xml"
|
72
38
|
- ".idea/modules.xml"
|
39
|
+
- ".ruby-version"
|
40
|
+
- ".travis.yml"
|
73
41
|
- CODE_OF_CONDUCT.md
|
74
42
|
- Gemfile
|
75
43
|
- Gemfile.lock
|