the_tv_db 0.0.1 → 0.0.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.
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/README.md +33 -1
- data/lib/the_tv_db/api.rb +21 -0
- data/lib/the_tv_db/client.rb +17 -0
- data/lib/the_tv_db/connection.rb +25 -0
- data/lib/the_tv_db/core_ext/string.rb +12 -0
- data/lib/the_tv_db/episode.rb +81 -0
- data/lib/the_tv_db/errors.rb +18 -0
- data/lib/the_tv_db/model.rb +53 -0
- data/lib/the_tv_db/response/xmlize.rb +26 -0
- data/lib/the_tv_db/response.rb +24 -0
- data/lib/the_tv_db/series/collection.rb +20 -0
- data/lib/the_tv_db/series.rb +75 -0
- data/lib/the_tv_db/version.rb +1 -1
- data/lib/the_tv_db.rb +33 -2
- data/spec/fixtures/episodes/air_date.xml +5 -0
- data/spec/fixtures/episodes/api_key.xml +7 -0
- data/spec/fixtures/episodes/result.xml +30 -0
- data/spec/fixtures/episodes/series_id.xml +5 -0
- data/spec/fixtures/series/404.html +39 -0
- data/spec/fixtures/series/empty.xml +2 -0
- data/spec/fixtures/series/find.xml +751 -0
- data/spec/fixtures/series/result.xml +14 -0
- data/spec/fixtures/series/results.xml +28 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/the_tv_db/episode_spec.rb +65 -0
- data/spec/the_tv_db/series_spec.rb +42 -0
- data/spec/the_tv_db/the_tv_db_spec.rb +15 -0
- data/the_tv_db.gemspec +11 -3
- metadata +111 -7
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<Data>
|
3
|
+
<Series>
|
4
|
+
<seriesid>82066</seriesid>
|
5
|
+
<language>en</language>
|
6
|
+
<SeriesName>Fringe</SeriesName>
|
7
|
+
<banner>graphical/82066-g38.jpg</banner>
|
8
|
+
<Overview>The series follows a Federal Bureau of Investigation "Fringe Division" team based in Boston. The team uses unorthodox "fringe" science and FBI investigative techniques to investigate a series of unexplained, often ghastly occurrences, some of which are related to mysteries surrounding a parallel universe.</Overview>
|
9
|
+
<FirstAired>2008-08-26</FirstAired>
|
10
|
+
<IMDB_ID>tt1119644</IMDB_ID>
|
11
|
+
<zap2it_id>SH01059103</zap2it_id>
|
12
|
+
<id>82066</id>
|
13
|
+
</Series>
|
14
|
+
</Data>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<Data>
|
3
|
+
<Series>
|
4
|
+
<seriesid>80331</seriesid>
|
5
|
+
<language>en</language>
|
6
|
+
<SeriesName>Wilfred</SeriesName>
|
7
|
+
<banner>graphical/80331-g2.jpg</banner>
|
8
|
+
<Overview>
|
9
|
+
At the center of this sitcom is a cranky dog who believes he is human, and lives to torment the live-in boyfriend of his loving, oblivious owner Sarah. Jason Gann plays the superstar mutt Wilfred.
|
10
|
+
</Overview>
|
11
|
+
<FirstAired>2007-07-20</FirstAired>
|
12
|
+
<zap2it_id>EP01416746</zap2it_id>
|
13
|
+
<id>80331</id>
|
14
|
+
</Series>
|
15
|
+
<Series>
|
16
|
+
<seriesid>239761</seriesid>
|
17
|
+
<language>en</language>
|
18
|
+
<SeriesName>Wilfred (US)</SeriesName>
|
19
|
+
<banner>graphical/239761-g4.jpg</banner>
|
20
|
+
<Overview>
|
21
|
+
Ryan, a young man struggling unsuccessfully to make his way in the world forms a unique friendship with Wilfred, his neighbor's canine pet. Everyone else sees Wilfred as just a dog, but Ryan sees a crude and somewhat surly, yet irrepressibly brave and honest Australian bloke in a cheap dog suit. While leading him through a series of comedic and existential adventures, Wilfred the dog shows Ryan the man how to overcome his fears and joyfully embrace the unpredictability and insanity of the world around him.
|
22
|
+
</Overview>
|
23
|
+
<FirstAired>2011-06-23</FirstAired>
|
24
|
+
<IMDB_ID>tt1703925</IMDB_ID>
|
25
|
+
<zap2it_id>SH01416746</zap2it_id>
|
26
|
+
<id>239761</id>
|
27
|
+
</Series>
|
28
|
+
</Data>
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "the_tv_db"
|
2
|
+
require "webmock/rspec"
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
#
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = "random"
|
20
|
+
end
|
21
|
+
|
22
|
+
def fixture_path
|
23
|
+
File.expand_path("../fixtures", __FILE__)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fixture(file)
|
27
|
+
File.read(File.join(fixture_path, '/', file))
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_get(path, endpoint = TheTvDB::ENDPOINT.to_s)
|
31
|
+
stub_request(:get, [endpoint, path].join('/'))
|
32
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe TheTvDB::Episode do
|
4
|
+
let(:api) { TheTvDB.new(api_key: "ASDF01234F0AF1368") }
|
5
|
+
|
6
|
+
context ".find" do
|
7
|
+
context "when all parameters are valid" do
|
8
|
+
before do
|
9
|
+
stub_get("GetEpisodeByAirDate.php?airdate=2012-11-16&apikey=ASDF01234F0AF1368&language=en&seriesid=82066").
|
10
|
+
to_return(:status => 200, :body => fixture("episodes/result.xml"))
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:episodes) { api.episodes.find("82066", "2012-11-16") }
|
14
|
+
|
15
|
+
it "returns an array" do
|
16
|
+
episodes == Array
|
17
|
+
end
|
18
|
+
|
19
|
+
it "instantiates episode objects" do
|
20
|
+
episodes.first == TheTvDB::Episode
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when missing air_date" do
|
25
|
+
before do
|
26
|
+
stub_get("GetEpisodeByAirDate.php?airdate&apikey=ASDF01234F0AF1368&language=en&seriesid=82066").
|
27
|
+
to_return(:status => 200, :body => fixture("episodes/air_date.xml"))
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises TheTvDBError" do
|
31
|
+
expect {
|
32
|
+
api.episodes.find("82066")
|
33
|
+
}.to raise_error(TheTvDB::TheTvDBError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when series_id doesn't exist" do
|
38
|
+
before do
|
39
|
+
stub_get("GetEpisodeByAirDate.php?airdate=2012-11-16&apikey=ASDF01234F0AF1368&language=en&seriesid=-1").
|
40
|
+
to_return(:status => 200, :body => fixture("episodes/series_id.xml"))
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises TheTvDBError" do
|
44
|
+
expect {
|
45
|
+
api.episodes.find("-1", "2012-11-16")
|
46
|
+
}.to raise_error(TheTvDB::TheTvDBError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when missing api_key" do
|
51
|
+
before do
|
52
|
+
TheTvDB.stub(:api_key).and_return(nil)
|
53
|
+
stub_get("GetEpisodeByAirDate.php?airdate=2012-11-16&apikey&language=en&seriesid=82066").
|
54
|
+
to_return(:status => 200, :body => fixture("episodes/api_key.xml"))
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises TheTvDBError when missing API key" do
|
58
|
+
expect {
|
59
|
+
api.episodes.find("82066", "2012-11-16")
|
60
|
+
}.to raise_error(TheTvDB::TheTvDBError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe TheTvDB::Series do
|
4
|
+
let(:api) { TheTvDB.new }
|
5
|
+
|
6
|
+
context ".search" do
|
7
|
+
it "returns an empty array when no results" do
|
8
|
+
stub_get("GetSeries.php?language=en&seriesname=asdf").
|
9
|
+
to_return(:status => 200, :body => fixture("series/empty.xml"))
|
10
|
+
api.series.search("asdf").count.should == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns an array with one result" do
|
14
|
+
stub_get("GetSeries.php?language=en&seriesname=Fringe").
|
15
|
+
to_return(:status => 200, :body => fixture("series/result.xml"))
|
16
|
+
api.series.search("Fringe").count.should == 1
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns an array of results" do
|
20
|
+
stub_get("GetSeries.php?language=en&seriesname=Wilfred").
|
21
|
+
to_return(:status => 200, :body => fixture("series/results.xml"))
|
22
|
+
api.series.search("Wilfred").count.should > 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context ".find" do
|
27
|
+
it "returns a series obejct" do
|
28
|
+
stub_get("data/series/82066/all/", TheTvDB::SITE.to_s).
|
29
|
+
to_return(:status => 200, :body => fixture("series/find.xml"))
|
30
|
+
series = api.series.find("82066")
|
31
|
+
series.id.should == "82066"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises RecordNotFound" do
|
35
|
+
stub_get("data/series/-1/all/", TheTvDB::SITE.to_s).
|
36
|
+
to_return(:status => 404, :body => fixture("series/404.html"))
|
37
|
+
expect {
|
38
|
+
api.series.find("-1")
|
39
|
+
}.to raise_error(TheTvDB::RecordNotFound)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe TheTvDB do
|
4
|
+
|
5
|
+
it "sets an API key" do
|
6
|
+
api_key = "ASDF01234F0AF1368"
|
7
|
+
TheTvDB.new(api_key: api_key)
|
8
|
+
TheTvDB.api_key == api_key
|
9
|
+
end
|
10
|
+
|
11
|
+
it "instantiates TheTvDB object without an API key" do
|
12
|
+
TheTvDB.new
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/the_tv_db.gemspec
CHANGED
@@ -8,12 +8,20 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = TheTvDb::VERSION
|
9
9
|
gem.authors = ["Javier Saldana"]
|
10
10
|
gem.email = ["javier@tractical.com"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
13
|
-
gem.homepage = ""
|
11
|
+
gem.description = %q{Ruby API Client for TheTvDB.com}
|
12
|
+
gem.summary = %q{TheTvDB.com API Client}
|
13
|
+
gem.homepage = "https://github.com/jassa/the_tv_db"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "typhoeus", "~> 0.4.2"
|
21
|
+
gem.add_dependency "faraday", "~> 0.8.4"
|
22
|
+
gem.add_dependency "ox", "~> 1.6.3"
|
23
|
+
gem.add_dependency "multi_xml", "~> 0.5.1"
|
24
|
+
|
25
|
+
gem.add_development_dependency "rspec", "~> 2.11.0"
|
26
|
+
gem.add_development_dependency "webmock", "~> 1.8.11"
|
19
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_tv_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,75 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typhoeus
|
16
|
+
requirement: &70341104042660 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.4.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70341104042660
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: faraday
|
27
|
+
requirement: &70341104041740 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.4
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70341104041740
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ox
|
38
|
+
requirement: &70341104041100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.3
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70341104041100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_xml
|
49
|
+
requirement: &70341104059500 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.5.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70341104059500
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &70341104058460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.11.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70341104058460
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: &70341104057720 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.11
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70341104057720
|
80
|
+
description: Ruby API Client for TheTvDB.com
|
15
81
|
email:
|
16
82
|
- javier@tractical.com
|
17
83
|
executables: []
|
@@ -19,14 +85,39 @@ extensions: []
|
|
19
85
|
extra_rdoc_files: []
|
20
86
|
files:
|
21
87
|
- .gitignore
|
88
|
+
- .rspec
|
22
89
|
- Gemfile
|
23
90
|
- LICENSE.txt
|
24
91
|
- README.md
|
25
92
|
- Rakefile
|
26
93
|
- lib/the_tv_db.rb
|
94
|
+
- lib/the_tv_db/api.rb
|
95
|
+
- lib/the_tv_db/client.rb
|
96
|
+
- lib/the_tv_db/connection.rb
|
97
|
+
- lib/the_tv_db/core_ext/string.rb
|
98
|
+
- lib/the_tv_db/episode.rb
|
99
|
+
- lib/the_tv_db/errors.rb
|
100
|
+
- lib/the_tv_db/model.rb
|
101
|
+
- lib/the_tv_db/response.rb
|
102
|
+
- lib/the_tv_db/response/xmlize.rb
|
103
|
+
- lib/the_tv_db/series.rb
|
104
|
+
- lib/the_tv_db/series/collection.rb
|
27
105
|
- lib/the_tv_db/version.rb
|
106
|
+
- spec/fixtures/episodes/air_date.xml
|
107
|
+
- spec/fixtures/episodes/api_key.xml
|
108
|
+
- spec/fixtures/episodes/result.xml
|
109
|
+
- spec/fixtures/episodes/series_id.xml
|
110
|
+
- spec/fixtures/series/404.html
|
111
|
+
- spec/fixtures/series/empty.xml
|
112
|
+
- spec/fixtures/series/find.xml
|
113
|
+
- spec/fixtures/series/result.xml
|
114
|
+
- spec/fixtures/series/results.xml
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/the_tv_db/episode_spec.rb
|
117
|
+
- spec/the_tv_db/series_spec.rb
|
118
|
+
- spec/the_tv_db/the_tv_db_spec.rb
|
28
119
|
- the_tv_db.gemspec
|
29
|
-
homepage:
|
120
|
+
homepage: https://github.com/jassa/the_tv_db
|
30
121
|
licenses: []
|
31
122
|
post_install_message:
|
32
123
|
rdoc_options: []
|
@@ -49,5 +140,18 @@ rubyforge_project:
|
|
49
140
|
rubygems_version: 1.8.11
|
50
141
|
signing_key:
|
51
142
|
specification_version: 3
|
52
|
-
summary:
|
53
|
-
test_files:
|
143
|
+
summary: TheTvDB.com API Client
|
144
|
+
test_files:
|
145
|
+
- spec/fixtures/episodes/air_date.xml
|
146
|
+
- spec/fixtures/episodes/api_key.xml
|
147
|
+
- spec/fixtures/episodes/result.xml
|
148
|
+
- spec/fixtures/episodes/series_id.xml
|
149
|
+
- spec/fixtures/series/404.html
|
150
|
+
- spec/fixtures/series/empty.xml
|
151
|
+
- spec/fixtures/series/find.xml
|
152
|
+
- spec/fixtures/series/result.xml
|
153
|
+
- spec/fixtures/series/results.xml
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/the_tv_db/episode_spec.rb
|
156
|
+
- spec/the_tv_db/series_spec.rb
|
157
|
+
- spec/the_tv_db/the_tv_db_spec.rb
|