thetvdb_api 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/README.md +3 -3
- data/lib/thetvdb_api/actor.rb +1 -1
- data/lib/thetvdb_api/banner.rb +1 -1
- data/lib/thetvdb_api/base.rb +28 -11
- data/lib/thetvdb_api/client.rb +0 -1
- data/lib/thetvdb_api/episode.rb +8 -6
- data/lib/thetvdb_api/search.rb +4 -5
- data/lib/thetvdb_api/series.rb +2 -2
- data/lib/thetvdb_api/update.rb +4 -4
- data/lib/thetvdb_api/version.rb +1 -1
- data/spec/spec_helper.rb +17 -0
- data/spec/thetvdb_api/actor_spec.rb +9 -2
- data/spec/thetvdb_api/banner_spec.rb +9 -2
- data/spec/thetvdb_api/base_spec.rb +37 -14
- data/spec/thetvdb_api/episode_spec.rb +31 -12
- data/spec/thetvdb_api/search_spec.rb +29 -8
- data/spec/thetvdb_api/series_spec.rb +15 -2
- data/spec/thetvdb_api/update_spec.rb +5 -4
- data/thetvdb_api.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35bc99ae409ce0fdba0ddbdd73f4ac36efbd54a2
|
|
4
|
+
data.tar.gz: 26f99748d70ae7a86306f5f795013fe14c90c11e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 159ee305365dc047e9312107e81168ccb9001492cfa2097b6efb25d5b34a45359d8ea4a042197dbf54e887c75e3a731715b75e6a12df547011205e355cb223c1
|
|
7
|
+
data.tar.gz: 4a2d708ed8cc0e28f70938cf948dd1fa17481dfc7a82bf41fbd9d90f52f893e85ed49a3e87b146bcfe348c6b71b621c5219659aefea9bbb8f50298ba2d004806
|
data/README.md
CHANGED
|
@@ -24,14 +24,14 @@ After you install ThetvdbApi and add it to your Gemfile, you need to run the gen
|
|
|
24
24
|
rails generate thetvdb_api:install
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The generator will install an initializer where you must past your api_key, and can past: language (2 letters abbrevation)
|
|
27
|
+
The generator will install an initializer where you must past your api_key, and can past: language (2 letters abbrevation).
|
|
28
28
|
|
|
29
29
|
## How to use
|
|
30
30
|
|
|
31
|
-
There is one entry point, in initialize you can past hash with api_key
|
|
31
|
+
There is one entry point, in initialize you can past hash with api_key and language values, or leave empty:
|
|
32
32
|
|
|
33
33
|
```ruby
|
|
34
|
-
client = ThetvdbApi::Client.new(
|
|
34
|
+
client = ThetvdbApi::Client.new(api_key: '...', language: 'en')
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Search series by name
|
data/lib/thetvdb_api/actor.rb
CHANGED
data/lib/thetvdb_api/banner.rb
CHANGED
data/lib/thetvdb_api/base.rb
CHANGED
|
@@ -1,35 +1,52 @@
|
|
|
1
1
|
require 'httparty'
|
|
2
|
+
require 'uri_template'
|
|
2
3
|
|
|
3
4
|
class ThetvdbApi::Base
|
|
4
5
|
include HTTParty
|
|
5
6
|
base_uri 'http://thetvdb.com/api/'
|
|
6
7
|
|
|
7
|
-
attr_reader :client, :uri, :options
|
|
8
|
-
|
|
9
8
|
def initialize(client)
|
|
10
9
|
@client = client
|
|
10
|
+
@params = {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get(uri)
|
|
14
|
+
@uri_template = URITemplate.new(uri)
|
|
15
|
+
|
|
16
|
+
self
|
|
11
17
|
end
|
|
12
18
|
|
|
13
|
-
def
|
|
14
|
-
@
|
|
15
|
-
@options = options
|
|
19
|
+
def params(options)
|
|
20
|
+
@params = options
|
|
16
21
|
|
|
17
22
|
self
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def response
|
|
21
|
-
self.class.get(uri,
|
|
26
|
+
@uri_template ? self.class.get(uri, body: @options) : nil
|
|
22
27
|
end
|
|
23
28
|
|
|
24
|
-
def
|
|
25
|
-
|
|
29
|
+
def prepare_uri
|
|
30
|
+
@uri_template ? @uri_template.expand(@params.merge(api_key: @client.api_key)) : nil
|
|
26
31
|
end
|
|
27
32
|
|
|
28
|
-
def
|
|
29
|
-
|
|
33
|
+
def uri
|
|
34
|
+
uri = prepare_uri
|
|
35
|
+
@params.reject!{ |param| restful_param_keys(uri).include?(param.to_s) }
|
|
36
|
+
|
|
37
|
+
uri
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def restful_param_keys(uri_expanded)
|
|
41
|
+
@uri_template.extract(uri_expanded).keys
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def series_uri
|
|
46
|
+
'{api_key}/series/{series_id}'
|
|
30
47
|
end
|
|
31
48
|
|
|
32
49
|
def language
|
|
33
|
-
client.language
|
|
50
|
+
@client.language
|
|
34
51
|
end
|
|
35
52
|
end
|
data/lib/thetvdb_api/client.rb
CHANGED
|
@@ -2,7 +2,6 @@ class ThetvdbApi::Client
|
|
|
2
2
|
attr_reader :api_key, :language
|
|
3
3
|
|
|
4
4
|
def initialize(options = {})
|
|
5
|
-
|
|
6
5
|
@api_key = options[:api_key] ? options[:api_key] : ThetvdbApi::Configuration.api_key
|
|
7
6
|
@language = options[:language] ? options[:language] : ThetvdbApi::Configuration.language
|
|
8
7
|
end
|
data/lib/thetvdb_api/episode.rb
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
class ThetvdbApi::Episode < ThetvdbApi::Base
|
|
2
2
|
def find_by_default_order(series_id, season, episode, language = self.language)
|
|
3
|
-
|
|
3
|
+
find_by_order('default', series_id, season, episode, language)
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def find_by_dvd_order(series_id, season, episode, language = self.language)
|
|
7
|
-
|
|
7
|
+
find_by_order('dvd', series_id, season, episode, language)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def find_by_absolute_order(series_id, absolute, language = self.language)
|
|
11
|
-
get("#{series_uri
|
|
11
|
+
get("#{series_uri}/absolute/{absolute}/{language}.xml").
|
|
12
|
+
params(series_id: series_id, absolute: absolute, language: language).response
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def find(episode_id, language = self.language)
|
|
15
|
-
get("
|
|
16
|
+
get("{api_key}/episodes/{episode_id}/{language}.xml").params(episode_id: episode_id, language: language).response
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
def
|
|
19
|
-
"
|
|
19
|
+
def find_by_order(order, series_id, season, episode, language)
|
|
20
|
+
get("#{series_uri}/{order}/{season}/{episode}/{language}.xml").
|
|
21
|
+
params(series_id: series_id, season: season, episode: episode, language: language, order: order).response
|
|
20
22
|
end
|
|
21
23
|
end
|
data/lib/thetvdb_api/search.rb
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
class ThetvdbApi::Search < ThetvdbApi::Base
|
|
2
2
|
def get_series(name, language = self.language)
|
|
3
|
-
get('GetSeries.php'
|
|
3
|
+
get('GetSeries.php').params(seriesname: name, language: language).response
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def get_series_by_imdb_id(id, language = self.language)
|
|
7
|
-
get('GetSeriesByRemoteID.php'
|
|
7
|
+
get('GetSeriesByRemoteID.php').params(imdbid: id, language: language).response
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def get_series_by_zap2it_id(id, language = self.language)
|
|
11
|
-
get('GetSeriesByRemoteID.php'
|
|
11
|
+
get('GetSeriesByRemoteID.php').params(zap2it: id, language: language).response
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def get_episode_by_air_date(series_id, air_date, language = self.language)
|
|
15
|
-
get('GetEpisodeByAirDate.php'
|
|
16
|
-
response
|
|
15
|
+
get('GetEpisodeByAirDate.php').params(seriesid: series_id, airdate: air_date, language: language).response
|
|
17
16
|
end
|
|
18
17
|
end
|
data/lib/thetvdb_api/series.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
class ThetvdbApi::Series < ThetvdbApi::Base
|
|
2
2
|
def find(series_id, language = self.language)
|
|
3
|
-
get("#{series_uri
|
|
3
|
+
get("#{series_uri}/{language}.xml").params(series_id: series_id, language: language).response
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def find_full(series_id, language = self.language)
|
|
7
|
-
get("#{series_uri
|
|
7
|
+
get("#{series_uri}/all/{language}.xml").params(series_id: series_id, language: language).response
|
|
8
8
|
end
|
|
9
9
|
end
|
data/lib/thetvdb_api/update.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
class ThetvdbApi::Update < ThetvdbApi::Base
|
|
2
2
|
def day
|
|
3
|
-
get(
|
|
3
|
+
get('{api_key}/updates/updates_day.xml').response
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def week
|
|
7
|
-
get(
|
|
7
|
+
get('{api_key}/updates/updates_week.xml').response
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def month
|
|
11
|
-
get(
|
|
11
|
+
get('{api_key}/updates/updates_month.xml').response
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def all
|
|
15
|
-
get(
|
|
15
|
+
get('{api_key}/updates/updates_all.xml').response
|
|
16
16
|
end
|
|
17
17
|
end
|
data/lib/thetvdb_api/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -8,5 +8,22 @@ require File.join(File.dirname(__FILE__), 'support/thetvdb_api.rb')
|
|
|
8
8
|
|
|
9
9
|
raise 'api_key missing, use ThetvdbApi::Configuration' if ThetvdbApi::Configuration.api_key.empty?
|
|
10
10
|
|
|
11
|
+
class SampleModel
|
|
12
|
+
def auth
|
|
13
|
+
self
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get(uri)
|
|
17
|
+
self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def params(options = {})
|
|
21
|
+
self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def response
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
11
28
|
RSpec.configure do |config|
|
|
12
29
|
end
|
|
@@ -3,10 +3,17 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Actor do
|
|
4
4
|
let(:klass) { ThetvdbApi::Actor }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.find' do
|
|
8
|
-
it 'should call
|
|
9
|
-
model.should_receive(:get).with('
|
|
9
|
+
it 'should call get with specific params' do
|
|
10
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/actors.xml').and_return(mock_model)
|
|
11
|
+
|
|
12
|
+
model.find('1234')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should call params with specific params' do
|
|
16
|
+
model.should_receive(:params).with(series_id: '1234').and_return(mock_model)
|
|
10
17
|
|
|
11
18
|
model.find('1234')
|
|
12
19
|
end
|
|
@@ -3,10 +3,17 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Banner do
|
|
4
4
|
let(:klass) { ThetvdbApi::Banner }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.find' do
|
|
8
|
-
it 'should call
|
|
9
|
-
model.should_receive(:get).with('
|
|
9
|
+
it 'should call get with specific params' do
|
|
10
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/banners.xml').and_return(mock_model)
|
|
11
|
+
|
|
12
|
+
model.find('1234')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should call params with specific params' do
|
|
16
|
+
model.should_receive(:params).with(series_id: '1234').and_return(mock_model)
|
|
10
17
|
|
|
11
18
|
model.find('1234')
|
|
12
19
|
end
|
|
@@ -8,44 +8,67 @@ describe ThetvdbApi::Base do
|
|
|
8
8
|
let(:model) { klass.new(ThetvdbApi::Client.new) }
|
|
9
9
|
|
|
10
10
|
describe '.get' do
|
|
11
|
-
it 'should set
|
|
11
|
+
it 'should set @uri_template' do
|
|
12
12
|
model.get('http://example.com')
|
|
13
13
|
|
|
14
|
-
model.
|
|
14
|
+
model.instance_variable_get('@uri_template').class.should == URITemplate::RFC6570
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
it 'should
|
|
18
|
-
model.get('http://example.com'
|
|
17
|
+
it 'should return self' do
|
|
18
|
+
model.get('http://example.com').should == model
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '.params' do
|
|
23
|
+
it 'should set @params' do
|
|
24
|
+
model.params(sample: 'test')
|
|
19
25
|
|
|
20
|
-
model.
|
|
26
|
+
model.instance_variable_get('@params').should == { sample: 'test' }
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
it 'should return self' do
|
|
24
|
-
model.
|
|
30
|
+
model.params(sample: 'test').should == model
|
|
25
31
|
end
|
|
26
32
|
end
|
|
27
33
|
|
|
28
34
|
describe '.response' do
|
|
29
35
|
it 'should call get klass method' do
|
|
36
|
+
model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
|
|
30
37
|
klass.should_receive(:get)
|
|
31
38
|
|
|
32
39
|
model.response
|
|
33
40
|
end
|
|
34
41
|
end
|
|
35
42
|
|
|
36
|
-
describe '.
|
|
37
|
-
it 'should
|
|
38
|
-
|
|
43
|
+
describe '.prepare_uri' do
|
|
44
|
+
it 'should receive correct uri string' do
|
|
45
|
+
model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
|
|
46
|
+
|
|
47
|
+
model.prepare_uri.should == "#{ThetvdbApi::Configuration.api_key}/series/"
|
|
39
48
|
end
|
|
40
49
|
end
|
|
41
50
|
|
|
42
|
-
describe '.
|
|
43
|
-
it 'should
|
|
44
|
-
|
|
51
|
+
describe '.uri' do
|
|
52
|
+
it 'should receive correct uri string' do
|
|
53
|
+
model.instance_variable_set('@uri_template', URITemplate.new('{api_key}/series/{id}'))
|
|
54
|
+
model.instance_variable_set('@params', id: '1234')
|
|
55
|
+
|
|
56
|
+
model.uri.should == "#{ThetvdbApi::Configuration.api_key}/series/1234"
|
|
45
57
|
end
|
|
58
|
+
end
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
describe '.restful_param_keys' do
|
|
61
|
+
it 'should receive correct uri string' do
|
|
62
|
+
uri_template = URITemplate.new('{api_key}/series/{id}')
|
|
63
|
+
model.instance_variable_set('@uri_template', uri_template)
|
|
64
|
+
|
|
65
|
+
model.restful_param_keys(uri_template.expand).sort.should == ['api_key', 'id'].sort
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe '.series_uri' do
|
|
70
|
+
it 'should use default api_key' do
|
|
71
|
+
klass.new(ThetvdbApi::Client.new(api_key: 'API_KEY')).series_uri.should == '{api_key}/series/{series_id}'
|
|
49
72
|
end
|
|
50
73
|
end
|
|
51
74
|
|
|
@@ -3,42 +3,61 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Episode do
|
|
4
4
|
let(:klass) { ThetvdbApi::Episode }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.find_by_default_order' do
|
|
8
|
-
it 'should call
|
|
9
|
-
model.should_receive(:get).with('
|
|
9
|
+
it 'should call get with specific params' do
|
|
10
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/{order}/{season}/{episode}/{language}.xml').and_return(mock_model)
|
|
11
|
+
|
|
12
|
+
model.find_by_default_order('1234', '1', '1')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should call params with specific params' do
|
|
16
|
+
model.should_receive(:params).with(series_id: '1234', season: '1', episode: '1', language: 'en', order: 'default').and_return(mock_model)
|
|
10
17
|
|
|
11
18
|
model.find_by_default_order('1234', '1', '1')
|
|
12
19
|
end
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
describe '.find_by_dvd_order' do
|
|
16
|
-
it 'should call
|
|
17
|
-
model.should_receive(:get).with('
|
|
23
|
+
it 'should call get with specific params' do
|
|
24
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/{order}/{season}/{episode}/{language}.xml').and_return(mock_model)
|
|
25
|
+
|
|
26
|
+
model.find_by_dvd_order('1234', '1', '1')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should call params with specific params' do
|
|
30
|
+
model.should_receive(:params).with(series_id: '1234', season: '1', episode: '1', language: 'en', order: 'dvd').and_return(mock_model)
|
|
18
31
|
|
|
19
32
|
model.find_by_dvd_order('1234', '1', '1')
|
|
20
33
|
end
|
|
21
34
|
end
|
|
22
35
|
|
|
23
36
|
describe '.find_by_absolute_order' do
|
|
24
|
-
it 'should call
|
|
25
|
-
model.should_receive(:get).with('
|
|
37
|
+
it 'should call get with specific params' do
|
|
38
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/absolute/{absolute}/{language}.xml').and_return(mock_model)
|
|
39
|
+
|
|
40
|
+
model.find_by_absolute_order('1234', '1')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should call params with specific params' do
|
|
44
|
+
model.should_receive(:params).with(series_id: '1234', absolute: '1', language: 'en').and_return(mock_model)
|
|
26
45
|
|
|
27
46
|
model.find_by_absolute_order('1234', '1')
|
|
28
47
|
end
|
|
29
48
|
end
|
|
30
49
|
|
|
31
50
|
describe '.find' do
|
|
32
|
-
it 'should call
|
|
33
|
-
model.should_receive(:get).with('
|
|
51
|
+
it 'should call get with specific params' do
|
|
52
|
+
model.should_receive(:get).with('{api_key}/episodes/{episode_id}/{language}.xml').and_return(mock_model)
|
|
34
53
|
|
|
35
54
|
model.find('1234')
|
|
36
55
|
end
|
|
37
|
-
end
|
|
38
56
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
it 'should call params with specific params' do
|
|
58
|
+
model.should_receive(:params).with(episode_id: '1234', language: 'en').and_return(mock_model)
|
|
59
|
+
|
|
60
|
+
model.find('1234')
|
|
42
61
|
end
|
|
43
62
|
end
|
|
44
63
|
end
|
|
@@ -3,11 +3,17 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Search do
|
|
4
4
|
let(:klass) { ThetvdbApi::Search }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.get_series' do
|
|
8
9
|
it 'should call get with specific params' do
|
|
9
|
-
model.should_receive(:get).with('GetSeries.php'
|
|
10
|
-
|
|
10
|
+
model.should_receive(:get).with('GetSeries.php').and_return(mock_model)
|
|
11
|
+
|
|
12
|
+
model.get_series('buffy', 'en')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should call params with specific params' do
|
|
16
|
+
model.should_receive(:params).with(seriesname: 'buffy', language: 'en').and_return(mock_model)
|
|
11
17
|
|
|
12
18
|
model.get_series('buffy', 'en')
|
|
13
19
|
end
|
|
@@ -15,8 +21,13 @@ describe ThetvdbApi::Search do
|
|
|
15
21
|
|
|
16
22
|
describe '.get_series_by_imdb_id' do
|
|
17
23
|
it 'should call get with specific params' do
|
|
18
|
-
model.should_receive(:get).with('GetSeriesByRemoteID.php'
|
|
19
|
-
|
|
24
|
+
model.should_receive(:get).with('GetSeriesByRemoteID.php').and_return(mock_model)
|
|
25
|
+
|
|
26
|
+
model.get_series_by_imdb_id('1234', 'en')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should call params with specific params' do
|
|
30
|
+
model.should_receive(:params).with(imdbid: '1234', language: 'en').and_return(mock_model)
|
|
20
31
|
|
|
21
32
|
model.get_series_by_imdb_id('1234', 'en')
|
|
22
33
|
end
|
|
@@ -24,8 +35,13 @@ describe ThetvdbApi::Search do
|
|
|
24
35
|
|
|
25
36
|
describe '.get_series_by_zap2it_id' do
|
|
26
37
|
it 'should call get with specific params' do
|
|
27
|
-
model.should_receive(:get).with('GetSeriesByRemoteID.php'
|
|
28
|
-
|
|
38
|
+
model.should_receive(:get).with('GetSeriesByRemoteID.php').and_return(mock_model)
|
|
39
|
+
|
|
40
|
+
model.get_series_by_zap2it_id('1234', 'en')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should call params with specific params' do
|
|
44
|
+
model.should_receive(:params).with(zap2it: '1234', language: 'en').and_return(mock_model)
|
|
29
45
|
|
|
30
46
|
model.get_series_by_zap2it_id('1234', 'en')
|
|
31
47
|
end
|
|
@@ -33,8 +49,13 @@ describe ThetvdbApi::Search do
|
|
|
33
49
|
|
|
34
50
|
describe '#get_episode_by_air_date' do
|
|
35
51
|
it 'should call get with specific params' do
|
|
36
|
-
model.should_receive(:get).with('GetEpisodeByAirDate.php'
|
|
37
|
-
|
|
52
|
+
model.should_receive(:get).with('GetEpisodeByAirDate.php').and_return(mock_model)
|
|
53
|
+
|
|
54
|
+
model.get_episode_by_air_date('1234', '2000-01-01', 'en')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should call params with specific params' do
|
|
58
|
+
model.should_receive(:params).with(seriesid: '1234', airdate: '2000-01-01', language: 'en').and_return(mock_model)
|
|
38
59
|
|
|
39
60
|
model.get_episode_by_air_date('1234', '2000-01-01', 'en')
|
|
40
61
|
end
|
|
@@ -3,10 +3,17 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Series do
|
|
4
4
|
let(:klass) { ThetvdbApi::Series }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.find' do
|
|
8
9
|
it 'should call get with specific params' do
|
|
9
|
-
model.should_receive(:get).with('
|
|
10
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/{language}.xml').and_return(mock_model)
|
|
11
|
+
|
|
12
|
+
model.find('1234', 'en')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'should call params with specific params' do
|
|
16
|
+
model.should_receive(:params).with(series_id: '1234', language: 'en').and_return(mock_model)
|
|
10
17
|
|
|
11
18
|
model.find('1234', 'en')
|
|
12
19
|
end
|
|
@@ -14,7 +21,13 @@ describe ThetvdbApi::Series do
|
|
|
14
21
|
|
|
15
22
|
describe '.find_full' do
|
|
16
23
|
it 'should call get with specific params' do
|
|
17
|
-
model.should_receive(:get).with('
|
|
24
|
+
model.should_receive(:get).with('{api_key}/series/{series_id}/all/{language}.xml').and_return(mock_model)
|
|
25
|
+
|
|
26
|
+
model.find_full('1234', 'en')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should call params with specific params' do
|
|
30
|
+
model.should_receive(:params).with(series_id: '1234', language: 'en').and_return(mock_model)
|
|
18
31
|
|
|
19
32
|
model.find_full('1234', 'en')
|
|
20
33
|
end
|
|
@@ -3,10 +3,11 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThetvdbApi::Update do
|
|
4
4
|
let(:klass) { ThetvdbApi::Update }
|
|
5
5
|
let(:model) { klass.new(ThetvdbApi::Client.new(api_key: '123456789')) }
|
|
6
|
+
let(:mock_model) { SampleModel.new }
|
|
6
7
|
|
|
7
8
|
describe '.day' do
|
|
8
9
|
it 'should call get with specific params' do
|
|
9
|
-
model.should_receive(:get).with('
|
|
10
|
+
model.should_receive(:get).with('{api_key}/updates/updates_day.xml').and_return(mock_model)
|
|
10
11
|
|
|
11
12
|
model.day
|
|
12
13
|
end
|
|
@@ -14,7 +15,7 @@ describe ThetvdbApi::Update do
|
|
|
14
15
|
|
|
15
16
|
describe '.week' do
|
|
16
17
|
it 'should call get with specific params' do
|
|
17
|
-
model.should_receive(:get).with('
|
|
18
|
+
model.should_receive(:get).with('{api_key}/updates/updates_week.xml').and_return(mock_model)
|
|
18
19
|
|
|
19
20
|
model.week
|
|
20
21
|
end
|
|
@@ -22,7 +23,7 @@ describe ThetvdbApi::Update do
|
|
|
22
23
|
|
|
23
24
|
describe '.month' do
|
|
24
25
|
it 'should call get with specific params' do
|
|
25
|
-
model.should_receive(:get).with('
|
|
26
|
+
model.should_receive(:get).with('{api_key}/updates/updates_month.xml').and_return(mock_model)
|
|
26
27
|
|
|
27
28
|
model.month
|
|
28
29
|
end
|
|
@@ -30,7 +31,7 @@ describe ThetvdbApi::Update do
|
|
|
30
31
|
|
|
31
32
|
describe '.all' do
|
|
32
33
|
it 'should call get with specific params' do
|
|
33
|
-
model.should_receive(:get).with('
|
|
34
|
+
model.should_receive(:get).with('{api_key}/updates/updates_all.xml').and_return(mock_model)
|
|
34
35
|
|
|
35
36
|
model.all
|
|
36
37
|
end
|
data/thetvdb_api.gemspec
CHANGED
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
21
|
spec.add_runtime_dependency 'confiture', '~> 0.1.4'
|
|
22
|
-
spec.
|
|
22
|
+
spec.add_runtime_dependency 'httparty', '~> 0.12.0'
|
|
23
|
+
spec.add_runtime_dependency 'uri_template', '~> 0.6.0'
|
|
23
24
|
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
25
26
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thetvdb_api
|
|
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
|
- Krzysztof Wawer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-12-
|
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: confiture
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - ~>
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.12.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: uri_template
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ~>
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.6.0
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.6.0
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|