rakuten_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +14 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +151 -0
- data/Rakefile +1 -0
- data/examples/show_ranking.rb +20 -0
- data/lib/rakuten_api/base/client.rb +41 -0
- data/lib/rakuten_api/base/item.rb +55 -0
- data/lib/rakuten_api/base/model.rb +41 -0
- data/lib/rakuten_api/base/params.rb +72 -0
- data/lib/rakuten_api/base/response.rb +39 -0
- data/lib/rakuten_api/configuration.rb +27 -0
- data/lib/rakuten_api/dummy_module.rb +6 -0
- data/lib/rakuten_api/error.rb +14 -0
- data/lib/rakuten_api/genre_search/client.rb +41 -0
- data/lib/rakuten_api/genre_search/model.rb +22 -0
- data/lib/rakuten_api/genre_search/response.rb +43 -0
- data/lib/rakuten_api/item_ranking/client.rb +29 -0
- data/lib/rakuten_api/item_ranking/model.rb +17 -0
- data/lib/rakuten_api/item_ranking/response.rb +57 -0
- data/lib/rakuten_api/item_search/client.rb +34 -0
- data/lib/rakuten_api/item_search/model.rb +15 -0
- data/lib/rakuten_api/item_search/response.rb +71 -0
- data/lib/rakuten_api/version.rb +3 -0
- data/lib/rakuten_api.rb +45 -0
- data/rakuten_api.gemspec +24 -0
- data/spec/fixtures/vcr_cassettes/genre_search_response.yml +75 -0
- data/spec/fixtures/vcr_cassettes/genre_search_response_0.yml +75 -0
- data/spec/fixtures/vcr_cassettes/genre_search_response_551169.yml +62 -0
- data/spec/fixtures/vcr_cassettes/genre_search_response_551172.yml +62 -0
- data/spec/fixtures/vcr_cassettes/item_ranking_error_response.yml +56 -0
- data/spec/fixtures/vcr_cassettes/item_ranking_response.yml +853 -0
- data/spec/fixtures/vcr_cassettes/item_ranking_response_next_ranking.yml +789 -0
- data/spec/fixtures/vcr_cassettes/item_ranking_response_prev_ranking.yml +853 -0
- data/spec/fixtures/vcr_cassettes/item_search_response.yml +116 -0
- data/spec/fixtures/vcr_cassettes/item_search_response_next_page.yml +89 -0
- data/spec/fixtures/vcr_cassettes/item_search_response_prev_page.yml +107 -0
- data/spec/rakuten_api/base/params_spec.rb +42 -0
- data/spec/rakuten_api/genre_search/client_spec.rb +37 -0
- data/spec/rakuten_api/genre_search/model_spec.rb +32 -0
- data/spec/rakuten_api/genre_search/response_spec.rb +47 -0
- data/spec/rakuten_api/item_ranking/client_spec.rb +19 -0
- data/spec/rakuten_api/item_ranking/model_spec.rb +19 -0
- data/spec/rakuten_api/item_ranking/response_spec.rb +64 -0
- data/spec/rakuten_api/item_search/client_spec.rb +35 -0
- data/spec/rakuten_api/item_search/model_spec.rb +33 -0
- data/spec/rakuten_api/item_search/response_spec.rb +73 -0
- data/spec/spec_helper.rb +34 -0
- metadata +181 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RakutenApi::ItemSearch::Response do
|
6
|
+
let(:client) {
|
7
|
+
RakutenApi::ItemSearch::Client.new do |params|
|
8
|
+
params.add_param :keyword, 'りんご'
|
9
|
+
params.add_param :hits, 2
|
10
|
+
end
|
11
|
+
}
|
12
|
+
let(:response) {
|
13
|
+
VCR.use_cassette('item_search_response') do
|
14
|
+
client.get
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
describe '#initialize' do
|
19
|
+
let(:obj) { described_class.new(response) }
|
20
|
+
it { obj.page_count.should >= 2 }
|
21
|
+
it { obj.page.should eql 1 }
|
22
|
+
it { obj.carrier.should eql 0 }
|
23
|
+
it { obj.first.should eql 1 }
|
24
|
+
it { obj.last.should eql 2 }
|
25
|
+
it { obj.should be_success }
|
26
|
+
it { obj.should_not be_error }
|
27
|
+
|
28
|
+
context "error raise" do
|
29
|
+
it { lambda { described_class.new('foo') }.should raise_error(RakutenApi::Error) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#simple_mapping' do
|
34
|
+
let(:obj) { described_class.new(response) }
|
35
|
+
subject { obj.simple_mapping }
|
36
|
+
it { should have(2).items }
|
37
|
+
its([0]) { should be_kind_of RakutenApi::ItemSearch::Model }
|
38
|
+
its([1]) { should be_kind_of RakutenApi::ItemSearch::Model }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#next?, #prev?' do
|
42
|
+
specify do
|
43
|
+
obj = described_class.new(response, client.params)
|
44
|
+
obj.should be_next
|
45
|
+
obj.should_not be_prev
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#next_page' do
|
50
|
+
let(:obj) { described_class.new(response, client.params) }
|
51
|
+
let(:next_page) {
|
52
|
+
VCR.use_cassette('item_search_response_next_page') do
|
53
|
+
obj.get_next_page
|
54
|
+
end
|
55
|
+
}
|
56
|
+
it { next_page.should be_kind_of ::RakutenApi::ItemSearch::Response }
|
57
|
+
it { next_page.page.should eql 2 }
|
58
|
+
it { next_page.first.should eql 3 }
|
59
|
+
it { next_page.last.should eql 4 }
|
60
|
+
|
61
|
+
describe '#prev_page' do
|
62
|
+
let(:prev_page) {
|
63
|
+
VCR.use_cassette('item_search_response_prev_page') do
|
64
|
+
next_page.get_prev_page
|
65
|
+
end
|
66
|
+
}
|
67
|
+
it { prev_page.should be_kind_of ::RakutenApi::ItemSearch::Response }
|
68
|
+
it { prev_page.page.should eql 1 }
|
69
|
+
it { prev_page.first.should eql 1 }
|
70
|
+
it { prev_page.last.should eql 2 }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'tapp'
|
5
|
+
rescue Exception
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'faraday'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
WebMock.disable_net_connect!
|
11
|
+
require 'vcr'
|
12
|
+
|
13
|
+
VCR.configure do |c|
|
14
|
+
c.cassette_library_dir = File.expand_path(File.dirname(__FILE__) + '/fixtures/vcr_cassettes')
|
15
|
+
c.hook_into :webmock
|
16
|
+
c.allow_http_connections_when_no_cassette = true
|
17
|
+
end
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/rakuten_api')
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.mock_with :rspec
|
23
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
24
|
+
config.filter_run focus: true
|
25
|
+
config.run_all_when_everything_filtered = true
|
26
|
+
end
|
27
|
+
|
28
|
+
RakutenApi.configure do |config|
|
29
|
+
config.application_id = "16d8dfe13fde99ac5479d789764d2f7a"
|
30
|
+
end
|
31
|
+
|
32
|
+
def json_fixture_path(filename)
|
33
|
+
File.expand_path(File.dirname(__FILE__) + '/fixtures/json/' + filename)
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rakuten_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kengos
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.12'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.12'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: vcr
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.4.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.4.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: webmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.9.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.9.2
|
78
|
+
description: Rakuten Api
|
79
|
+
email:
|
80
|
+
- kengo@kengos.jp
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- Guardfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- examples/show_ranking.rb
|
92
|
+
- lib/rakuten_api.rb
|
93
|
+
- lib/rakuten_api/base/client.rb
|
94
|
+
- lib/rakuten_api/base/item.rb
|
95
|
+
- lib/rakuten_api/base/model.rb
|
96
|
+
- lib/rakuten_api/base/params.rb
|
97
|
+
- lib/rakuten_api/base/response.rb
|
98
|
+
- lib/rakuten_api/configuration.rb
|
99
|
+
- lib/rakuten_api/dummy_module.rb
|
100
|
+
- lib/rakuten_api/error.rb
|
101
|
+
- lib/rakuten_api/genre_search/client.rb
|
102
|
+
- lib/rakuten_api/genre_search/model.rb
|
103
|
+
- lib/rakuten_api/genre_search/response.rb
|
104
|
+
- lib/rakuten_api/item_ranking/client.rb
|
105
|
+
- lib/rakuten_api/item_ranking/model.rb
|
106
|
+
- lib/rakuten_api/item_ranking/response.rb
|
107
|
+
- lib/rakuten_api/item_search/client.rb
|
108
|
+
- lib/rakuten_api/item_search/model.rb
|
109
|
+
- lib/rakuten_api/item_search/response.rb
|
110
|
+
- lib/rakuten_api/version.rb
|
111
|
+
- rakuten_api.gemspec
|
112
|
+
- spec/fixtures/vcr_cassettes/genre_search_response.yml
|
113
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_0.yml
|
114
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_551169.yml
|
115
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_551172.yml
|
116
|
+
- spec/fixtures/vcr_cassettes/item_ranking_error_response.yml
|
117
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response.yml
|
118
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response_next_ranking.yml
|
119
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response_prev_ranking.yml
|
120
|
+
- spec/fixtures/vcr_cassettes/item_search_response.yml
|
121
|
+
- spec/fixtures/vcr_cassettes/item_search_response_next_page.yml
|
122
|
+
- spec/fixtures/vcr_cassettes/item_search_response_prev_page.yml
|
123
|
+
- spec/rakuten_api/base/params_spec.rb
|
124
|
+
- spec/rakuten_api/genre_search/client_spec.rb
|
125
|
+
- spec/rakuten_api/genre_search/model_spec.rb
|
126
|
+
- spec/rakuten_api/genre_search/response_spec.rb
|
127
|
+
- spec/rakuten_api/item_ranking/client_spec.rb
|
128
|
+
- spec/rakuten_api/item_ranking/model_spec.rb
|
129
|
+
- spec/rakuten_api/item_ranking/response_spec.rb
|
130
|
+
- spec/rakuten_api/item_search/client_spec.rb
|
131
|
+
- spec/rakuten_api/item_search/model_spec.rb
|
132
|
+
- spec/rakuten_api/item_search/response_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: https://github.com/kengos/rakuten_api
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.23
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Rakuten Api(http://webservice.rakuten.co.jp/)
|
159
|
+
test_files:
|
160
|
+
- spec/fixtures/vcr_cassettes/genre_search_response.yml
|
161
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_0.yml
|
162
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_551169.yml
|
163
|
+
- spec/fixtures/vcr_cassettes/genre_search_response_551172.yml
|
164
|
+
- spec/fixtures/vcr_cassettes/item_ranking_error_response.yml
|
165
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response.yml
|
166
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response_next_ranking.yml
|
167
|
+
- spec/fixtures/vcr_cassettes/item_ranking_response_prev_ranking.yml
|
168
|
+
- spec/fixtures/vcr_cassettes/item_search_response.yml
|
169
|
+
- spec/fixtures/vcr_cassettes/item_search_response_next_page.yml
|
170
|
+
- spec/fixtures/vcr_cassettes/item_search_response_prev_page.yml
|
171
|
+
- spec/rakuten_api/base/params_spec.rb
|
172
|
+
- spec/rakuten_api/genre_search/client_spec.rb
|
173
|
+
- spec/rakuten_api/genre_search/model_spec.rb
|
174
|
+
- spec/rakuten_api/genre_search/response_spec.rb
|
175
|
+
- spec/rakuten_api/item_ranking/client_spec.rb
|
176
|
+
- spec/rakuten_api/item_ranking/model_spec.rb
|
177
|
+
- spec/rakuten_api/item_ranking/response_spec.rb
|
178
|
+
- spec/rakuten_api/item_search/client_spec.rb
|
179
|
+
- spec/rakuten_api/item_search/model_spec.rb
|
180
|
+
- spec/rakuten_api/item_search/response_spec.rb
|
181
|
+
- spec/spec_helper.rb
|