rakuten_web_service 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -4
  4. data/README.en.md +19 -2
  5. data/README.md +18 -3
  6. data/lib/rakuten_web_service.rb +4 -13
  7. data/lib/rakuten_web_service/books.rb +11 -0
  8. data/lib/rakuten_web_service/books/book.rb +29 -0
  9. data/lib/rakuten_web_service/books/cd.rb +25 -0
  10. data/lib/rakuten_web_service/books/dvd.rb +25 -0
  11. data/lib/rakuten_web_service/books/foreign_book.rb +24 -0
  12. data/lib/rakuten_web_service/books/game.rb +25 -0
  13. data/lib/rakuten_web_service/books/genre.rb +66 -0
  14. data/lib/rakuten_web_service/books/magazine.rb +26 -0
  15. data/lib/rakuten_web_service/books/resource.rb +52 -0
  16. data/lib/rakuten_web_service/books/software.rb +25 -0
  17. data/lib/rakuten_web_service/books/total.rb +16 -0
  18. data/lib/rakuten_web_service/ichiba.rb +7 -0
  19. data/lib/rakuten_web_service/ichiba/genre.rb +27 -20
  20. data/lib/rakuten_web_service/ichiba/item.rb +6 -4
  21. data/lib/rakuten_web_service/ichiba/ranking.rb +3 -2
  22. data/lib/rakuten_web_service/ichiba/shop.rb +3 -0
  23. data/lib/rakuten_web_service/resource.rb +29 -6
  24. data/lib/rakuten_web_service/search_result.rb +34 -1
  25. data/lib/rakuten_web_service/version.rb +1 -1
  26. data/rakuten_web_service.gemspec +1 -0
  27. data/spec/fixtures/books/book_search_with_keyword_Ruby.json +1 -0
  28. data/spec/fixtures/books/cd_search_with_keyword_Ruby.json +1 -0
  29. data/spec/fixtures/books/dvd_search_with_keyword_Ruby.json +1 -0
  30. data/spec/fixtures/books/foreign_book_search_with_keyword_Ruby.json +1 -0
  31. data/spec/fixtures/books/game_search_with_keyword_Ruby.json +1 -0
  32. data/spec/fixtures/books/genre_search.json +1 -0
  33. data/spec/fixtures/books/magazine_search_with_keyword_Ruby.json +1 -0
  34. data/spec/fixtures/books/software_search_with_keyword_Ruby.json +1 -0
  35. data/spec/fixtures/books/total_search_with_keyword_Ruby.json +1 -0
  36. data/spec/rakuten_web_service/books/book_spec.rb +93 -0
  37. data/spec/rakuten_web_service/books/cd_spec.rb +63 -0
  38. data/spec/rakuten_web_service/books/dvd_spec.rb +63 -0
  39. data/spec/rakuten_web_service/books/foreign_book_spec.rb +62 -0
  40. data/spec/rakuten_web_service/books/game_spec.rb +56 -0
  41. data/spec/rakuten_web_service/books/genre_spec.rb +187 -0
  42. data/spec/rakuten_web_service/books/magazine_spec.rb +56 -0
  43. data/spec/rakuten_web_service/books/software_spec.rb +56 -0
  44. data/spec/rakuten_web_service/books/total_spec.rb +38 -0
  45. data/spec/rakuten_web_service/ichiba/item_spec.rb +19 -0
  46. metadata +64 -16
@@ -0,0 +1,38 @@
1
+ require 'rspec'
2
+ require 'rakuten_web_service'
3
+
4
+ describe RakutenWebService::Books::Total do
5
+ let(:endpoint) { 'https://app.rakuten.co.jp/services/api/BooksTotal/Search/20130522' }
6
+ let(:affiliate_id) { 'dummy_affiliate_id' }
7
+ let(:application_id) { 'dummy_application_id' }
8
+ let(:expected_query) do
9
+ {
10
+ :affiliateId => affiliate_id,
11
+ :applicationId => application_id,
12
+ :keyword => 'Ruby'
13
+ }
14
+ end
15
+
16
+ before do
17
+ RakutenWebService.configuration do |c|
18
+ c.affiliate_id = affiliate_id
19
+ c.application_id = application_id
20
+ end
21
+ end
22
+
23
+ describe '.search' do
24
+ before do
25
+ response = JSON.parse(fixture('books/total_search_with_keyword_Ruby.json'))
26
+ @expected_request = stub_request(:get, endpoint).
27
+ with(:query => expected_query).to_return(:body => response.to_json)
28
+ end
29
+
30
+ specify 'call endpoint when accessing results' do
31
+ items = RakutenWebService::Books::Total.search(:keyword => 'Ruby')
32
+ expect(@expected_request).to_not have_been_made
33
+
34
+ item = items.first
35
+ expect(@expected_request).to have_been_made.once
36
+ end
37
+ end
38
+ end
@@ -59,6 +59,9 @@ describe RakutenWebService::Ichiba::Item do
59
59
  expect(subject['item_name']).to eq(expected_json['itemName'])
60
60
  end
61
61
  its(:name) { should eq(expected_json['itemName']) }
62
+ specify 'should have xxx? method if the object has xxx_flag' do
63
+ expect(subject.tax?).to eq(expected_json['taxFlag'] == 1)
64
+ end
62
65
  end
63
66
 
64
67
  context 'after that, call each' do
@@ -121,4 +124,20 @@ describe RakutenWebService::Ichiba::Item do
121
124
  expect(subject.url).to eq(expected_item['shopUrl'])
122
125
  end
123
126
  end
127
+
128
+ describe '#order' do
129
+ specify 'convert sort parameter' do
130
+ query = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby').order(affiliate_rate: :desc)
131
+
132
+ expect(query.params[:sort]).to eq('-affiliateRate')
133
+ end
134
+
135
+ specify 'reproduces new SearchResult object' do
136
+ first_query = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby')
137
+ second_query = first_query.order(affiliate_rate: :desc)
138
+
139
+ expect(first_query.params[:sort]).to be_nil
140
+ expect(second_query.params[:sort]).to eq('-affiliateRate')
141
+ end
142
+ end
124
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakuten_web_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuya Sato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-14 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,56 +56,56 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tapp
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Ruby Client for Rakuten Web Service
@@ -124,8 +124,20 @@ files:
124
124
  - Rakefile
125
125
  - examples/ichiba_item_search.rb
126
126
  - lib/rakuten_web_service.rb
127
+ - lib/rakuten_web_service/books.rb
128
+ - lib/rakuten_web_service/books/book.rb
129
+ - lib/rakuten_web_service/books/cd.rb
130
+ - lib/rakuten_web_service/books/dvd.rb
131
+ - lib/rakuten_web_service/books/foreign_book.rb
132
+ - lib/rakuten_web_service/books/game.rb
133
+ - lib/rakuten_web_service/books/genre.rb
134
+ - lib/rakuten_web_service/books/magazine.rb
135
+ - lib/rakuten_web_service/books/resource.rb
136
+ - lib/rakuten_web_service/books/software.rb
137
+ - lib/rakuten_web_service/books/total.rb
127
138
  - lib/rakuten_web_service/client.rb
128
139
  - lib/rakuten_web_service/configuration.rb
140
+ - lib/rakuten_web_service/ichiba.rb
129
141
  - lib/rakuten_web_service/ichiba/genre.rb
130
142
  - lib/rakuten_web_service/ichiba/item.rb
131
143
  - lib/rakuten_web_service/ichiba/ranking.rb
@@ -134,9 +146,27 @@ files:
134
146
  - lib/rakuten_web_service/search_result.rb
135
147
  - lib/rakuten_web_service/version.rb
136
148
  - rakuten_web_service.gemspec
149
+ - spec/fixtures/books/book_search_with_keyword_Ruby.json
150
+ - spec/fixtures/books/cd_search_with_keyword_Ruby.json
151
+ - spec/fixtures/books/dvd_search_with_keyword_Ruby.json
152
+ - spec/fixtures/books/foreign_book_search_with_keyword_Ruby.json
153
+ - spec/fixtures/books/game_search_with_keyword_Ruby.json
154
+ - spec/fixtures/books/genre_search.json
155
+ - spec/fixtures/books/magazine_search_with_keyword_Ruby.json
156
+ - spec/fixtures/books/software_search_with_keyword_Ruby.json
157
+ - spec/fixtures/books/total_search_with_keyword_Ruby.json
137
158
  - spec/fixtures/ichiba/genre_search.json
138
159
  - spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
139
160
  - spec/fixtures/ichiba/ranking_search.json
161
+ - spec/rakuten_web_service/books/book_spec.rb
162
+ - spec/rakuten_web_service/books/cd_spec.rb
163
+ - spec/rakuten_web_service/books/dvd_spec.rb
164
+ - spec/rakuten_web_service/books/foreign_book_spec.rb
165
+ - spec/rakuten_web_service/books/game_spec.rb
166
+ - spec/rakuten_web_service/books/genre_spec.rb
167
+ - spec/rakuten_web_service/books/magazine_spec.rb
168
+ - spec/rakuten_web_service/books/software_spec.rb
169
+ - spec/rakuten_web_service/books/total_spec.rb
140
170
  - spec/rakuten_web_service/client_spec.rb
141
171
  - spec/rakuten_web_service/configuration_spec.rb
142
172
  - spec/rakuten_web_service/ichiba/genre_spec.rb
@@ -155,24 +185,42 @@ require_paths:
155
185
  - lib
156
186
  required_ruby_version: !ruby/object:Gem::Requirement
157
187
  requirements:
158
- - - ! '>='
188
+ - - '>'
159
189
  - !ruby/object:Gem::Version
160
- version: '0'
190
+ version: 1.9.2
161
191
  required_rubygems_version: !ruby/object:Gem::Requirement
162
192
  requirements:
163
- - - ! '>='
193
+ - - '>='
164
194
  - !ruby/object:Gem::Version
165
195
  version: '0'
166
196
  requirements: []
167
197
  rubyforge_project:
168
- rubygems_version: 2.0.7
198
+ rubygems_version: 2.0.3
169
199
  signing_key:
170
200
  specification_version: 4
171
201
  summary: Ruby Client for Rakuten Web Service
172
202
  test_files:
203
+ - spec/fixtures/books/book_search_with_keyword_Ruby.json
204
+ - spec/fixtures/books/cd_search_with_keyword_Ruby.json
205
+ - spec/fixtures/books/dvd_search_with_keyword_Ruby.json
206
+ - spec/fixtures/books/foreign_book_search_with_keyword_Ruby.json
207
+ - spec/fixtures/books/game_search_with_keyword_Ruby.json
208
+ - spec/fixtures/books/genre_search.json
209
+ - spec/fixtures/books/magazine_search_with_keyword_Ruby.json
210
+ - spec/fixtures/books/software_search_with_keyword_Ruby.json
211
+ - spec/fixtures/books/total_search_with_keyword_Ruby.json
173
212
  - spec/fixtures/ichiba/genre_search.json
174
213
  - spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
175
214
  - spec/fixtures/ichiba/ranking_search.json
215
+ - spec/rakuten_web_service/books/book_spec.rb
216
+ - spec/rakuten_web_service/books/cd_spec.rb
217
+ - spec/rakuten_web_service/books/dvd_spec.rb
218
+ - spec/rakuten_web_service/books/foreign_book_spec.rb
219
+ - spec/rakuten_web_service/books/game_spec.rb
220
+ - spec/rakuten_web_service/books/genre_spec.rb
221
+ - spec/rakuten_web_service/books/magazine_spec.rb
222
+ - spec/rakuten_web_service/books/software_spec.rb
223
+ - spec/rakuten_web_service/books/total_spec.rb
176
224
  - spec/rakuten_web_service/client_spec.rb
177
225
  - spec/rakuten_web_service/configuration_spec.rb
178
226
  - spec/rakuten_web_service/ichiba/genre_spec.rb