gurunavi 0.1.1 → 0.1.2
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/VERSION +1 -1
- data/gurunavi.gemspec +3 -2
- data/lib/gurunavi/client.rb +12 -0
- data/lib/gurunavi/rests.rb +6 -3
- data/test/fixtures/rests/rest_search_one_hit_case.json +99 -0
- data/test/test_rests.rb +10 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 206f37037571a8ecce7e25049890a65f71bb214c
|
4
|
+
data.tar.gz: 6b7dc6614f9e07c6dce0a249622ebb849343d7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2617d4a5d7b735b7986fb422ab23b1094f8f485a398ccbe94e25000be6a695673cce5a695c5f427bcb9fd125d0fdd005e742639850975cab4248bf5525cd16b9
|
7
|
+
data.tar.gz: 181f27a19020536dd673a0ba235e184961e6b5bad2ac38875becff1bec9fe5d07e997adf2a46fa8621211aefa90a56243ac5cc1083b08434a6d15da74bfb3940
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/gurunavi.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: gurunavi 0.1.
|
5
|
+
# stub: gurunavi 0.1.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "gurunavi".freeze
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
"test/fixtures/prefs/pref_search.json",
|
50
50
|
"test/fixtures/rests/foreign_rest_search.json",
|
51
51
|
"test/fixtures/rests/rest_search.json",
|
52
|
+
"test/fixtures/rests/rest_search_one_hit_case.json",
|
52
53
|
"test/helper.rb",
|
53
54
|
"test/test_area_codes.rb",
|
54
55
|
"test/test_areas.rb",
|
data/lib/gurunavi/client.rb
CHANGED
@@ -78,6 +78,18 @@ module Gurunavi
|
|
78
78
|
response_body
|
79
79
|
end
|
80
80
|
|
81
|
+
# Helper method to wrap object into array.
|
82
|
+
#
|
83
|
+
# this use case is return a object for Gurunavi API when hit per page is 1.
|
84
|
+
def convert_to_array_if_needed(response_body)
|
85
|
+
unless response_body.instance_of?(Hashie::Array)
|
86
|
+
array = Hashie::Array.new
|
87
|
+
array.push(response_body)
|
88
|
+
return array
|
89
|
+
end
|
90
|
+
response_body
|
91
|
+
end
|
92
|
+
|
81
93
|
private
|
82
94
|
|
83
95
|
def default_headers
|
data/lib/gurunavi/rests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
1
3
|
module Gurunavi
|
2
4
|
module Rests
|
3
5
|
|
@@ -6,7 +8,8 @@ module Gurunavi
|
|
6
8
|
response = connection.get do |req|
|
7
9
|
req.url "RestSearchAPI/#{@api_version}", options
|
8
10
|
end
|
9
|
-
return_error_or_body(response, response.body.rest)
|
11
|
+
response_body = return_error_or_body(response, response.body.rest)
|
12
|
+
convert_to_array_if_needed(response_body)
|
10
13
|
end
|
11
14
|
|
12
15
|
# Ref: http://api.gnavi.co.jp/api/manual/foreignrestsearch/
|
@@ -14,8 +17,8 @@ module Gurunavi
|
|
14
17
|
response = connection.get do |req|
|
15
18
|
req.url "ForeignRestSearchAPI/#{@api_version}", options
|
16
19
|
end
|
17
|
-
return_error_or_body(response, response.body.rest)
|
20
|
+
response_body = return_error_or_body(response, response.body.rest)
|
21
|
+
convert_to_array_if_needed(response_body)
|
18
22
|
end
|
19
|
-
|
20
23
|
end
|
21
24
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
{
|
2
|
+
"@attributes": {
|
3
|
+
"api_version": "20150630"
|
4
|
+
},
|
5
|
+
"total_hit_count": "41",
|
6
|
+
"hit_per_page": "10",
|
7
|
+
"page_offset": "5",
|
8
|
+
"rest": {
|
9
|
+
"@attributes": {
|
10
|
+
"order": "0"
|
11
|
+
},
|
12
|
+
"id": "5213224",
|
13
|
+
"update_date": "2015-08-28 05:35:19",
|
14
|
+
"name": "城門 ",
|
15
|
+
"name_kana": "ジョウモン",
|
16
|
+
"latitude": "36.038486",
|
17
|
+
"longitude": "140.105486",
|
18
|
+
"category": "ホルモン",
|
19
|
+
"url": "http://r.gnavi.co.jp/8ncn7swe0000/?ak=SUQUyeTkNn9iEGa%2FQ4Hr8VjHYUU2FXMOQv7k9OMxwi0%3D",
|
20
|
+
"url_mobile": "http://mobile.gnavi.co.jp/shop/5213224/?ak=SUQUyeTkNn9iEGa%2FQ4Hr8VjHYUU2FXMOQv7k9OMxwi0%3D",
|
21
|
+
"coupon_url": {
|
22
|
+
"pc": {},
|
23
|
+
"mobile": {}
|
24
|
+
},
|
25
|
+
"image_url": {
|
26
|
+
"shop_image1": {},
|
27
|
+
"shop_image2": {},
|
28
|
+
"qrcode": "https://c-r.gnst.jp/tool/qr/?id=5213224&q=6"
|
29
|
+
},
|
30
|
+
"address": "〒305-0853 茨城県つくば市榎戸370-2 ",
|
31
|
+
"tel": "029-838-1600",
|
32
|
+
"tel_sub": {},
|
33
|
+
"fax": {},
|
34
|
+
"opentime": {},
|
35
|
+
"holiday": {},
|
36
|
+
"access": {
|
37
|
+
"line": {},
|
38
|
+
"station": {},
|
39
|
+
"station_exit": {},
|
40
|
+
"walk": {},
|
41
|
+
"note": {}
|
42
|
+
},
|
43
|
+
"parking_lots": {},
|
44
|
+
"pr": {
|
45
|
+
"pr_short": {},
|
46
|
+
"pr_long": {}
|
47
|
+
},
|
48
|
+
"code": {
|
49
|
+
"areacode": "AREA110",
|
50
|
+
"areaname": "関東",
|
51
|
+
"prefcode": "PREF08",
|
52
|
+
"prefname": "茨城県",
|
53
|
+
"areacode_s": "AREAS2820",
|
54
|
+
"areaname_s": "その他つくば",
|
55
|
+
"category_code_l": [
|
56
|
+
"RSFST05000",
|
57
|
+
{
|
58
|
+
"@attributes": {
|
59
|
+
"order": "1"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"category_name_l": [
|
64
|
+
"焼肉・ホルモン",
|
65
|
+
{
|
66
|
+
"@attributes": {
|
67
|
+
"order": "1"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
],
|
71
|
+
"category_code_s": [
|
72
|
+
"RSFST05002",
|
73
|
+
{
|
74
|
+
"@attributes": {
|
75
|
+
"order": "1"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"category_name_s": [
|
80
|
+
"ホルモン",
|
81
|
+
{
|
82
|
+
"@attributes": {
|
83
|
+
"order": "1"
|
84
|
+
}
|
85
|
+
}
|
86
|
+
]
|
87
|
+
},
|
88
|
+
"budget": {},
|
89
|
+
"party": {},
|
90
|
+
"lunch": {},
|
91
|
+
"credit_card": {},
|
92
|
+
"e_money": {},
|
93
|
+
"flags": {
|
94
|
+
"mobile_site": "1",
|
95
|
+
"mobile_coupon": "0",
|
96
|
+
"pc_coupon": "0"
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
data/test/test_rests.rb
CHANGED
@@ -13,6 +13,16 @@ class TestGurunavi < Test::Unit::TestCase
|
|
13
13
|
rests.count.should == 10
|
14
14
|
end
|
15
15
|
|
16
|
+
should "fetch results type is HashieArray when searching from rest search api with one hit case" do
|
17
|
+
stub_get("https://api.gnavi.co.jp/RestSearchAPI/20150630?format=json&keyid=#{@client.keyid}", "rests/rest_search_one_hit_case.json")
|
18
|
+
rests = @client.rest_search
|
19
|
+
|
20
|
+
rests.count.should == 1
|
21
|
+
rests.each do |rest|
|
22
|
+
rest.id.should == "5213224"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
should "fetch results when searching from foeign rest search api with hit_per_page options" do
|
17
27
|
stub_get("https://api.gnavi.co.jp/ForeignRestSearchAPI/20150630?format=json&hit_per_page=10&keyid=#{@client.keyid}", "rests/foreign_rest_search.json")
|
18
28
|
rests = @client.foreign_rest_search(hit_per_page: 10)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gurunavi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kobayang
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- test/fixtures/prefs/pref_search.json
|
237
237
|
- test/fixtures/rests/foreign_rest_search.json
|
238
238
|
- test/fixtures/rests/rest_search.json
|
239
|
+
- test/fixtures/rests/rest_search_one_hit_case.json
|
239
240
|
- test/helper.rb
|
240
241
|
- test/test_area_codes.rb
|
241
242
|
- test/test_areas.rb
|