syoboi_calendar 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,31 +1,8 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe SyoboiCalendar::Client do
5
- before do
6
- stub_request(:any, //)
7
- end
8
-
1
+ describe ::SyoboiCalendar::Client do
9
2
  let(:client) do
10
3
  described_class.new
11
4
  end
12
5
 
13
- let!(:request) do
14
- stub_request(:get, "http://cal.syoboi.jp/db.php?#{query.to_query}")
15
- end
16
-
17
- let(:call) do
18
- client.send(method_name, options)
19
- end
20
-
21
- let(:options) do
22
- {}
23
- end
24
-
25
- let(:query) do
26
- {}
27
- end
28
-
29
6
  let(:dummy_channels_response) do
30
7
  <<-EOS.strip_heredoc
31
8
  <?xml version="1.0" encoding="UTF-8"?>
@@ -143,44 +120,69 @@ describe SyoboiCalendar::Client do
143
120
  request
144
121
  end
145
122
 
146
- describe "#channels" do
147
- let(:method_name) do
148
- :channels
123
+ describe "#list_channels" do
124
+ subject do
125
+ client.list_channels(options)
126
+ end
127
+
128
+ let(:options) do
129
+ {}
149
130
  end
150
131
 
151
132
  [
152
133
  {
153
134
  options: {},
154
- query: { Command: "ChLookup" },
135
+ query: {
136
+ Command: "ChLookup",
137
+ },
155
138
  },
156
139
  {
157
- options: { channel_id: 1 },
158
- query: { Command: "ChLookup", ChID: 1 },
140
+ options: {
141
+ channel_id: 1,
142
+ },
143
+ query: {
144
+ Command: "ChLookup",
145
+ ChID: 1,
146
+ },
159
147
  },
160
148
  {
161
- options: { updated_from: Time.utc(2000) },
162
- query: { Command: "ChLookup", LastUpdate: "20000101_000000-" },
149
+ options: {
150
+ updated_from: ::Time.new(2000, 1, 1),
151
+ },
152
+ query: {
153
+ Command: "ChLookup",
154
+ LastUpdate: "20000101_000000-",
155
+ },
163
156
  },
164
157
  {
165
- options: { updated_to: Time.utc(2000) },
166
- query: { Command: "ChLookup", LastUpdate: "-20000101_000000" },
158
+ options: {
159
+ updated_to: ::Time.new(2000, 1, 1),
160
+ },
161
+ query: {
162
+ Command: "ChLookup",
163
+ LastUpdate: "-20000101_000000",
164
+ },
167
165
  },
168
166
  {
169
- options: { updated_from: Time.utc(2000), updated_to: Time.utc(2000) },
170
- query: { Command: "ChLookup", LastUpdate: "20000101_000000-20000101_000000" },
167
+ options: {
168
+ updated_from: ::Time.new(2000, 1, 1),
169
+ updated_to: ::Time.new(2000, 1, 1),
170
+ },
171
+ query: {
172
+ Command: "ChLookup",
173
+ LastUpdate: "20000101_000000-20000101_000000",
174
+ },
171
175
  },
172
- ].each do |hash|
173
- context "with options #{hash[:options].inspect}" do
176
+ ].each do |example|
177
+ context "with options #{example[:options].inspect}" do
174
178
  let(:options) do
175
- hash[:options]
176
- end
177
-
178
- let(:query) do
179
- hash[:query]
179
+ example[:options]
180
180
  end
181
181
 
182
- it "requests to http://cal.syoboi.jp/db.php?#{hash[:query].to_query}" do
183
- should have_been_made
182
+ it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
183
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
184
+ subject
185
+ expect(stub).to have_been_made
184
186
  end
185
187
  end
186
188
  end
@@ -190,9 +192,9 @@ describe SyoboiCalendar::Client do
190
192
  stub_request(:get, //).to_rack(app)
191
193
  end
192
194
 
193
- it "returns an Array of SyoboiCalendar::Resources::Channel" do
194
- channels = client.channels
195
- channels[0].should be_a SyoboiCalendar::Resources::Channel
195
+ it "returns an Array of ::SyoboiCalendar::Resources::Channel" do
196
+ channels = subject
197
+ channels[0].should be_a ::SyoboiCalendar::Resources::Channel
196
198
  channels[0].comment.should == "DummyComment"
197
199
  channels[0].epg_url.should == "http://example.com/epg-url"
198
200
  channels[0].group_id.should == 1
@@ -205,147 +207,158 @@ describe SyoboiCalendar::Client do
205
207
  end
206
208
  end
207
209
 
208
- describe "#titles" do
209
- let(:method_name) do
210
- :titles
210
+ describe "#list_programs" do
211
+ subject do
212
+ client.list_programs(options)
211
213
  end
212
214
 
213
- [
214
- {
215
- options: {},
216
- query: { Command: "TitleLookup" },
217
- },
218
- {
219
- options: { title_id: 1 },
220
- query: { Command: "TitleLookup", TID: 1 },
221
- },
222
- {
223
- options: { updated_from: Time.utc(2000) },
224
- query: { Command: "TitleLookup", LastUpdate: "20000101_000000-" },
225
- },
226
- {
227
- options: { updated_to: Time.utc(2000) },
228
- query: { Command: "TitleLookup", LastUpdate: "-20000101_000000" },
229
- },
230
- {
231
- options: { updated_from: Time.utc(2000), updated_to: Time.utc(2000) },
232
- query: { Command: "TitleLookup", LastUpdate: "20000101_000000-20000101_000000" },
233
- },
234
- ].each do |hash|
235
- context "with options #{hash[:options].inspect}" do
236
- let(:options) do
237
- hash[:options]
238
- end
239
-
240
- let(:query) do
241
- hash[:query]
242
- end
243
-
244
- it "requests to http://cal.syoboi.jp/db.php?#{hash[:query].to_query}" do
245
- should have_been_made
246
- end
247
- end
248
- end
249
-
250
- context "with real response" do
251
- let!(:request) do
252
- stub_request(:get, //).to_rack(app)
253
- end
254
-
255
- it "returns an Array of SyoboiCalendar::Resources::Title" do
256
- titles = client.titles
257
- titles[0].should be_a SyoboiCalendar::Resources::Title
258
- titles[0].category_id.should == 4
259
- titles[0].comment.should == "DummyComment"
260
- titles[0].first_channel.should == "DummyChannel"
261
- titles[0].first_end_month.should == 1
262
- titles[0].first_end_year.should == 2000
263
- titles[0].first_month.should == 1
264
- titles[0].first_year.should == 2000
265
- titles[0].keywords.should == "DummyKeywords"
266
- titles[0].short_title.should == "DummyShortTitle"
267
- titles[0].sub_titles.should == "DummySubTitles"
268
- titles[0].id.should == 2
269
- titles[0].name.should == "DummyTitle"
270
- titles[0].english_name.should == "DummyEnglishTitle"
271
- titles[0].flag.should == 0
272
- titles[0].kana.should == "ダミータイトル"
273
- titles[0].point.should == 6
274
- titles[0].rank.should == 1
275
- end
276
- end
277
- end
278
-
279
- describe "#programs" do
280
- let(:method_name) do
281
- :programs
215
+ let(:options) do
216
+ {}
282
217
  end
283
218
 
284
219
  [
285
220
  {
286
221
  options: {},
287
- query: { Command: "ProgLookup", JOIN: "SubTitles" },
222
+ query: {
223
+ Command: "ProgLookup",
224
+ JOIN: "SubTitles",
225
+ },
288
226
  },
289
227
  {
290
- options: { program_id: 1 },
291
- query: { Command: "ProgLookup", JOIN: "SubTitles", PID: 1 },
228
+ options: {
229
+ program_id: 1,
230
+ },
231
+ query: {
232
+ Command: "ProgLookup",
233
+ JOIN: "SubTitles",
234
+ PID: 1,
235
+ },
292
236
  },
293
237
  {
294
- options: { program_id: 1, channel_id: 2 },
295
- query: { Command: "ProgLookup", JOIN: "SubTitles", PID: 1, ChID: 2 },
238
+ options: {
239
+ channel_id: 2,
240
+ program_id: 1,
241
+ },
242
+ query: {
243
+ ChID: 2,
244
+ Command: "ProgLookup",
245
+ JOIN: "SubTitles",
246
+ PID: 1,
247
+ },
296
248
  },
297
249
  {
298
- options: { count: 1 },
299
- query: { Command: "ProgLookup", JOIN: "SubTitles", Count: 1 },
250
+ options: {
251
+ count: 1,
252
+ },
253
+ query: {
254
+ Command: "ProgLookup",
255
+ Count: 1,
256
+ JOIN: "SubTitles",
257
+ },
300
258
  },
301
259
  {
302
- options: { updated_from: Time.utc(2000) },
303
- query: { Command: "ProgLookup", JOIN: "SubTitles", LastUpdate: "20000101_000000-" },
260
+ options: {
261
+ updated_from: ::Time.new(2000, 1, 1),
262
+ },
263
+ query: {
264
+ Command: "ProgLookup",
265
+ JOIN: "SubTitles",
266
+ LastUpdate: "20000101_000000-",
267
+ },
304
268
  },
305
269
  {
306
- options: { updated_to: Time.utc(2000) },
307
- query: { Command: "ProgLookup", JOIN: "SubTitles", LastUpdate: "-20000101_000000" },
270
+ options: {
271
+ updated_to: ::Time.new(2000, 1, 1),
272
+ },
273
+ query: {
274
+ Command: "ProgLookup",
275
+ JOIN: "SubTitles",
276
+ LastUpdate: "-20000101_000000",
277
+ },
308
278
  },
309
279
  {
310
- options: { updated_from: Time.utc(2000), updated_to: Time.utc(2000) },
311
- query: { Command: "ProgLookup", JOIN: "SubTitles", LastUpdate: "20000101_000000-20000101_000000" },
280
+ options: {
281
+ updated_from: ::Time.new(2000, 1, 1),
282
+ updated_to: ::Time.new(2000, 1, 1),
283
+ },
284
+ query: {
285
+ Command: "ProgLookup",
286
+ JOIN: "SubTitles",
287
+ LastUpdate: "20000101_000000-20000101_000000",
288
+ },
312
289
  },
313
290
  {
314
- options: { started_from: Time.utc(2000) },
315
- query: { Command: "ProgLookup", JOIN: "SubTitles", StTime: "20000101_000000-" },
291
+ options: {
292
+ started_from: ::Time.new(2000, 1, 1),
293
+ },
294
+ query: {
295
+ Command: "ProgLookup",
296
+ JOIN: "SubTitles", StTime:
297
+ "20000101_000000-",
298
+ },
316
299
  },
317
300
  {
318
- options: { started_to: Time.utc(2000) },
319
- query: { Command: "ProgLookup", JOIN: "SubTitles", StTime: "-20000101_000000" },
301
+ options: {
302
+ started_to: ::Time.new(2000, 1, 1),
303
+ },
304
+ query: {
305
+ Command: "ProgLookup",
306
+ JOIN: "SubTitles",
307
+ StTime: "-20000101_000000",
308
+ },
320
309
  },
321
310
  {
322
- options: { started_from: Time.utc(2000), started_to: Time.utc(2000) },
323
- query: { Command: "ProgLookup", JOIN: "SubTitles", StTime: "20000101_000000-20000101_000000" },
311
+ options: {
312
+ started_from: ::Time.new(2000, 1, 1),
313
+ started_to: ::Time.new(2000, 1, 1),
314
+ },
315
+ query: {
316
+ Command: "ProgLookup",
317
+ JOIN: "SubTitles",
318
+ StTime: "20000101_000000-20000101_000000",
319
+ },
324
320
  },
325
321
  {
326
- options: { played_from: Time.utc(2000) },
327
- query: { Command: "ProgLookup", JOIN: "SubTitles", Range: "20000101_000000-" },
322
+ options: {
323
+ played_from: ::Time.new(2000, 1, 1),
324
+ },
325
+ query: {
326
+ Command: "ProgLookup",
327
+ JOIN: "SubTitles",
328
+ Range: "20000101_000000-",
329
+ },
328
330
  },
329
331
  {
330
- options: { played_to: Time.utc(2000) },
331
- query: { Command: "ProgLookup", JOIN: "SubTitles", Range: "-20000101_000000" },
332
+ options: {
333
+ played_to: ::Time.new(2000, 1, 1),
334
+ },
335
+ query: {
336
+ Command: "ProgLookup",
337
+ JOIN: "SubTitles",
338
+ Range: "-20000101_000000",
339
+ },
332
340
  },
333
341
  {
334
- options: { played_from: Time.utc(2000), played_to: Time.utc(2000) },
335
- query: { Command: "ProgLookup", JOIN: "SubTitles", Range: "20000101_000000-20000101_000000" },
342
+ options: {
343
+ played_from: ::Time.new(2000, 1, 1),
344
+ played_to: ::Time.new(2000, 1, 1),
345
+ },
346
+ query: {
347
+ Command: "ProgLookup",
348
+ JOIN: "SubTitles",
349
+ Range: "20000101_000000-20000101_000000",
350
+ },
336
351
  },
337
- ].each do |hash|
338
- context "with options #{hash[:options].inspect}" do
352
+ ].each do |example|
353
+ context "with options #{example[:options].inspect}" do
339
354
  let(:options) do
340
- hash[:options]
341
- end
342
-
343
- let(:query) do
344
- hash[:query]
355
+ example[:options]
345
356
  end
346
357
 
347
- it "requests to http://cal.syoboi.jp/db.php?#{hash[:query].to_query}" do
348
- should have_been_made
358
+ it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
359
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
360
+ subject
361
+ expect(stub).to have_been_made
349
362
  end
350
363
  end
351
364
  end
@@ -355,9 +368,9 @@ describe SyoboiCalendar::Client do
355
368
  stub_request(:get, //).to_rack(app)
356
369
  end
357
370
 
358
- it "returns an Array of SyoboiCalendar::Resources::Program" do
359
- programs = client.programs
360
- programs[0].should be_a SyoboiCalendar::Resources::Program
371
+ it "returns an Array of ::SyoboiCalendar::Resources::Program" do
372
+ programs = subject
373
+ programs[0].should be_a ::SyoboiCalendar::Resources::Program
361
374
  programs[0].channel_id.should == 3
362
375
  programs[0].comment.should == "DummyComment"
363
376
  programs[0].count.should == 1
@@ -380,9 +393,105 @@ describe SyoboiCalendar::Client do
380
393
  end
381
394
 
382
395
  it "eager loads related resources" do
383
- programs = client.programs(includes: [:channel, :title])
384
- programs[0].channel.should be_a SyoboiCalendar::Resources::Channel
385
- programs[0].title.should be_a SyoboiCalendar::Resources::Title
396
+ programs = client.list_programs(includes: [:channel, :title])
397
+ programs[0].channel.should be_a ::SyoboiCalendar::Resources::Channel
398
+ programs[0].title.should be_a ::SyoboiCalendar::Resources::Title
399
+ end
400
+ end
401
+ end
402
+
403
+ describe "#list_titles" do
404
+ subject do
405
+ client.list_titles(options)
406
+ end
407
+
408
+ let(:options) do
409
+ {}
410
+ end
411
+
412
+ [
413
+ {
414
+ options: {},
415
+ query: {
416
+ Command: "TitleLookup",
417
+ },
418
+ },
419
+ {
420
+ options: {
421
+ title_id: 1,
422
+ },
423
+ query: {
424
+ Command: "TitleLookup",
425
+ TID: 1,
426
+ },
427
+ },
428
+ {
429
+ options: {
430
+ updated_from: ::Time.new(2000, 1, 1),
431
+ },
432
+ query: {
433
+ Command: "TitleLookup",
434
+ LastUpdate: "20000101_000000-",
435
+ },
436
+ },
437
+ {
438
+ options: {
439
+ updated_to: ::Time.new(2000, 1, 1),
440
+ },
441
+ query: {
442
+ Command: "TitleLookup",
443
+ LastUpdate: "-20000101_000000",
444
+ },
445
+ },
446
+ {
447
+ options: {
448
+ updated_from: ::Time.new(2000, 1, 1),
449
+ updated_to: ::Time.new(2000, 1, 1),
450
+ },
451
+ query: {
452
+ Command: "TitleLookup",
453
+ LastUpdate: "20000101_000000-20000101_000000",
454
+ },
455
+ },
456
+ ].each do |example|
457
+ context "with options #{example[:options].inspect}" do
458
+ let(:options) do
459
+ example[:options]
460
+ end
461
+
462
+ it "sends an HTTP request to http://cal.syoboi.jp/db.php?#{example[:query].to_query}" do
463
+ stub = stub_request(:get, "http://cal.syoboi.jp/db.php?#{example[:query].to_query}")
464
+ subject
465
+ expect(stub).to have_been_made
466
+ end
467
+ end
468
+ end
469
+
470
+ context "with real response" do
471
+ let!(:request) do
472
+ stub_request(:get, //).to_rack(app)
473
+ end
474
+
475
+ it "returns an Array of ::SyoboiCalendar::Resources::Title" do
476
+ titles = subject
477
+ titles[0].should be_a ::SyoboiCalendar::Resources::Title
478
+ titles[0].category_id.should == 4
479
+ titles[0].comment.should == "DummyComment"
480
+ titles[0].first_channel.should == "DummyChannel"
481
+ titles[0].first_end_month.should == 1
482
+ titles[0].first_end_year.should == 2000
483
+ titles[0].first_month.should == 1
484
+ titles[0].first_year.should == 2000
485
+ titles[0].keywords.should == "DummyKeywords"
486
+ titles[0].short_title.should == "DummyShortTitle"
487
+ titles[0].sub_titles.should == "DummySubTitles"
488
+ titles[0].id.should == 2
489
+ titles[0].name.should == "DummyTitle"
490
+ titles[0].english_name.should == "DummyEnglishTitle"
491
+ titles[0].flag.should == 0
492
+ titles[0].kana.should == "ダミータイトル"
493
+ titles[0].point.should == 6
494
+ titles[0].rank.should == 1
386
495
  end
387
496
  end
388
497
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = SyoboiCalendar::VERSION
8
8
  spec.authors = ["Ryo Nakamura"]
9
9
  spec.email = ["r7kamura@gmail.com"]
10
- spec.summary = "A chatterbot framework, inspired by Hubot"
10
+ spec.summary = "An API Client library for http://cal.syoboi.jp/ written in Ruby."
11
11
  spec.homepage = "https://github.com/r7kamura/syoboi_calendar"
12
12
  spec.license = "MIT"
13
13
 
@@ -16,16 +16,16 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.required_ruby_version = ">= 2.2.2"
20
+
19
21
  spec.add_dependency "activesupport"
20
22
  spec.add_dependency "faraday"
21
23
  spec.add_dependency "faraday_middleware"
22
24
  spec.add_dependency "hashie"
23
25
  spec.add_dependency "multi_xml"
24
- spec.add_development_dependency "codeclimate-test-reporter", ">= 0.3.0"
25
26
  spec.add_development_dependency "pry"
26
27
  spec.add_development_dependency "rack"
27
28
  spec.add_development_dependency "rake"
28
29
  spec.add_development_dependency "rspec", "2.14.1"
29
- spec.add_development_dependency "simplecov"
30
30
  spec.add_development_dependency "webmock"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syoboi_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-03 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: codeclimate-test-reporter
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 0.3.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 0.3.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +136,6 @@ dependencies:
150
136
  - - '='
151
137
  - !ruby/object:Gem::Version
152
138
  version: 2.14.1
153
- - !ruby/object:Gem::Dependency
154
- name: simplecov
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: webmock
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +158,7 @@ extensions: []
186
158
  extra_rdoc_files: []
187
159
  files:
188
160
  - ".gitignore"
189
- - ".travis.yml"
161
+ - ".rspec"
190
162
  - CHANGELOG.md
191
163
  - Gemfile
192
164
  - LICENSE
@@ -228,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
200
  requirements:
229
201
  - - ">="
230
202
  - !ruby/object:Gem::Version
231
- version: '0'
203
+ version: 2.2.2
232
204
  required_rubygems_version: !ruby/object:Gem::Requirement
233
205
  requirements:
234
206
  - - ">="
@@ -236,11 +208,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
208
  version: '0'
237
209
  requirements: []
238
210
  rubyforge_project:
239
- rubygems_version: 2.2.2
211
+ rubygems_version: 2.5.2
240
212
  signing_key:
241
213
  specification_version: 4
242
- summary: A chatterbot framework, inspired by Hubot
214
+ summary: An API Client library for http://cal.syoboi.jp/ written in Ruby.
243
215
  test_files:
244
216
  - spec/spec_helper.rb
245
217
  - spec/syoboi_calendar/client_spec.rb
246
- has_rdoc:
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- branches:
2
- only:
3
- - master
4
- language: ruby
5
- rvm:
6
- - 1.9.3
7
- - 2.0.0
8
- env:
9
- global:
10
- secure: jireAT1B+27QH2v5EUjdIu9/ELwA+fj67PtCFiw7nSvzzQV4sC94/otyrPlNqsLKijWk+fQw5XcW9HvSTXvCgGguQn5AGW+MjPu9AbuZAbWf6ayZFHIgaPxmBzFYZaC2yK9XL0kVMG/UdhDM9Vy9auf1kDPphMhwAGZ2yjuSBj0=