tv-data-api-clients 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +11 -0
- data/lib/base.rb +2 -0
- data/lib/base/api/episode.rb +104 -0
- data/lib/base/api/show.rb +132 -0
- data/lib/core_ext/object.rb +15 -0
- data/lib/helpers.rb +22 -0
- data/lib/the_tv_db.rb +23 -0
- data/lib/the_tv_db/api/episode.rb +56 -0
- data/lib/the_tv_db/api/episode_list.rb +28 -0
- data/lib/the_tv_db/api/image.rb +114 -0
- data/lib/the_tv_db/api/image_list.rb +35 -0
- data/lib/the_tv_db/api/image_list_helpers.rb +32 -0
- data/lib/the_tv_db/api/mirror.rb +13 -0
- data/lib/the_tv_db/api/mirrors.rb +11 -0
- data/lib/the_tv_db/api/show.rb +125 -0
- data/lib/the_tv_db/configuration.rb +7 -0
- data/lib/tv_data_api_clients.rb +12 -0
- data/lib/tv_data_api_clients/version.rb +3 -0
- data/lib/tv_rage.rb +7 -0
- data/lib/tv_rage/show.rb +81 -0
- data/test/fixtures/example.gif +0 -0
- data/test/fixtures/the_tv_db/api_get_series_lost.xml +24 -0
- data/test/fixtures/the_tv_db/api_series_12345_all_en.xml +9 -0
- data/test/fixtures/the_tv_db/api_series_73739_banners.xml +157 -0
- data/test/fixtures/the_tv_db/api_series_73739_en.xml +30 -0
- data/test/fixtures/tv_rage/feeds_search_show.xml +11 -0
- data/test/fixtures/tv_rage/feeds_showinfo_sid_7926.xml +28 -0
- data/test/support/shared_episode_naming_tests.rb +90 -0
- data/test/support/shared_show_naming_tests.rb +29 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/base/api/episode_test.rb +11 -0
- data/test/unit/base/api/show_test.rb +11 -0
- data/test/unit/the_tv_db/api/episode_list_test.rb +15 -0
- data/test/unit/the_tv_db/api/episode_test.rb +93 -0
- data/test/unit/the_tv_db/api/image_list_test.rb +42 -0
- data/test/unit/the_tv_db/api/image_test.rb +35 -0
- data/test/unit/the_tv_db/api/mirrors_test.rb +17 -0
- data/test/unit/the_tv_db/api/show_test.rb +57 -0
- data/test/unit/the_tv_db/configuration_test.rb +28 -0
- data/test/unit/tv_rage/show_test.rb +55 -0
- data/tv-data-api-clients.gemspec +29 -0
- metadata +238 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TheTvDbApiShowTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
include SharedShowNamingTests
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@subject_class = ::TheTvDb::Api::Show
|
9
|
+
stub_request(:get, Regexp.new(Regexp.escape("http://thetvdb.com/api/GetSeries.php?seriesname=") + '.*')).
|
10
|
+
to_return(:status => 200, :body => File.read('test/fixtures/the_tv_db/api_get_series_lost.xml'))
|
11
|
+
|
12
|
+
stub_request(:get, "http://thetvdb.com/api/ABCDE12345/series/73739/en.xml").
|
13
|
+
to_return(:status => 200, :body => File.read('test/fixtures/the_tv_db/api_series_73739_en.xml'))
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_be_finable_by_name
|
17
|
+
assert_equal thetvdb_api_show, TheTvDb::Api::Show.find('Lost')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_be_finable_by_name_case_insensitive
|
21
|
+
assert_equal thetvdb_api_show, TheTvDb::Api::Show.find('LoST')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_extracting_all_attributes_correctly
|
25
|
+
assert_equal({
|
26
|
+
name: "Lost",
|
27
|
+
country: nil,
|
28
|
+
started: 2004,
|
29
|
+
overview: "After their plane, Oceanic Air flight 815, tore apart whilst thousands of miles off course, the survivors find themselves on a mysterious deserted island where they soon find out they are not alone.",
|
30
|
+
status: :ended
|
31
|
+
}, thetvdb_api_show.attributes)
|
32
|
+
assert_equal ['Matthew Fox', 'Terry O\'Quinn', 'Evangeline Lilly', 'Naveen Andrews'], thetvdb_api_show.actors
|
33
|
+
assert_equal [Date.parse('22/09/2004')], thetvdb_api_show.air_dates
|
34
|
+
assert thetvdb_api_show.aliases.empty?
|
35
|
+
assert_nil thetvdb_api_show.classification
|
36
|
+
assert_nil thetvdb_api_show.country
|
37
|
+
assert_equal ['Action and Adventure', 'Drama', 'Science-Fiction'], thetvdb_api_show.genres
|
38
|
+
assert_equal 'en', thetvdb_api_show.language
|
39
|
+
assert_equal 'Lost', thetvdb_api_show.name
|
40
|
+
assert_equal 'ABC', thetvdb_api_show.network
|
41
|
+
assert_equal 73739, thetvdb_api_show.network_id
|
42
|
+
assert_match thetvdb_api_show.overview, /After their plane, Oceanic Air flight 815, tore apart whilst thousands/
|
43
|
+
assert_equal [[:imdb, 'tt0411008'], [:zap2it, 'SH672362']], thetvdb_api_show.remote_ids
|
44
|
+
assert_equal (60 * 60), thetvdb_api_show.runtime
|
45
|
+
assert_equal 2004, thetvdb_api_show.started
|
46
|
+
assert_equal :ended, thetvdb_api_show.status
|
47
|
+
assert_equal 91, thetvdb_api_show.rating
|
48
|
+
assert_equal 548, thetvdb_api_show.number_of_ratings
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def thetvdb_api_show
|
54
|
+
TheTvDb::Api::Show.find(73739)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TheTvDbConfigurationTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@config = TheTvDb::Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_configuration_api_key_accessor
|
10
|
+
assert_respond_to @config, :api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_configuration_api_key_writer
|
14
|
+
assert_respond_to @config, :api_key=
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_thetvdb_module_always_makes_the_configuration_available
|
18
|
+
assert TheTvDb.configuration
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_can_configure_the_api_key
|
22
|
+
TheTvDb.configure do |config|
|
23
|
+
config.api_key = '123-test'
|
24
|
+
end
|
25
|
+
assert_equal '123-test', TheTvDb.configuration.api_key
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class TVRageAPIShowTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
include SharedShowNamingTests
|
7
|
+
|
8
|
+
def setup
|
9
|
+
|
10
|
+
@subject_class = TvRage::Api::Show
|
11
|
+
|
12
|
+
stub_request(:get, "http://services.tvrage.com/feeds/showinfo.php?sid=7926").
|
13
|
+
to_return(:status => 200, :body => File.read('test/fixtures/tv_rage/feeds_showinfo_sid_7926.xml'))
|
14
|
+
|
15
|
+
stub_request(:get, Regexp.new(Regexp.escape("http://services.tvrage.com/feeds/search.php?show=") + '.*')).
|
16
|
+
to_return(:status => 200, :body => File.read('test/fixtures/tv_rage/feeds_search_show.xml'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_also_search_by_name
|
20
|
+
assert_equal TvRage::Api::Show.find(7926), TvRage::Api::Show.find('Dexter')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_should_also_search_by_name_case_insensitive
|
24
|
+
assert_equal TvRage::Api::Show.find(7926), TvRage::Api::Show.find('DeXtEr')
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_should_extract_sane_attributes
|
28
|
+
@tvrage_api_show = TvRage::Api::Show.find(7926)
|
29
|
+
assert_equal @tvrage_api_show.attributes, {
|
30
|
+
name: "Dexter",
|
31
|
+
country: "US",
|
32
|
+
started: 2006,
|
33
|
+
overview: nil,
|
34
|
+
status: :returning_series
|
35
|
+
}
|
36
|
+
assert @tvrage_api_show.actors.empty?
|
37
|
+
assert @tvrage_api_show.air_dates.empty?
|
38
|
+
assert @tvrage_api_show.language.nil?
|
39
|
+
assert @tvrage_api_show.overview.nil?
|
40
|
+
assert @tvrage_api_show.remote_ids.empty?
|
41
|
+
assert_equal @tvrage_api_show.aliases, [[:LT, 'Deksteris'], [:LV, 'Deksters'], [:BG, 'Декстър'], [:IL, 'דקסטר']]
|
42
|
+
assert_equal @tvrage_api_show.classification, :scripted
|
43
|
+
assert_equal @tvrage_api_show.country, "US"
|
44
|
+
assert_equal @tvrage_api_show.genres, ['Crime', 'Drama']
|
45
|
+
assert_equal @tvrage_api_show.name, "Dexter"
|
46
|
+
assert_equal @tvrage_api_show.network, 'Showtime'
|
47
|
+
assert_equal @tvrage_api_show.network_id, 7926
|
48
|
+
assert_equal @tvrage_api_show.runtime, 60 * 60
|
49
|
+
assert_equal @tvrage_api_show.started, 2006
|
50
|
+
assert_equal @tvrage_api_show.status, :returning_series
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require "tv_data_api_clients/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "tv-data-api-clients"
|
8
|
+
s.version = TvDataApiClients::VERSION
|
9
|
+
s.authors = ["Lee Hambley"]
|
10
|
+
s.email = ["lee.hambley@gmail.com"]
|
11
|
+
s.homepage = "http://thetvdb.com/"
|
12
|
+
s.summary = %q{Unofficial Gem for accessing TheTvDb Api}
|
13
|
+
s.description = %q{Provides access to the TVDB Api, unofficially for an Api key, register at http://thetvdb.com/}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency("nokogiri")
|
21
|
+
s.add_dependency("fastimage")
|
22
|
+
|
23
|
+
s.add_development_dependency("minitest")
|
24
|
+
s.add_development_dependency("mocha")
|
25
|
+
s.add_development_dependency("rake")
|
26
|
+
s.add_development_dependency("ruby-debug19")
|
27
|
+
s.add_development_dependency("webmock")
|
28
|
+
s.add_development_dependency("turn")
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tv-data-api-clients
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lee Hambley
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
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'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fastimage
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: minitest
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '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: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mocha
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
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: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: ruby-debug19
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: turn
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: Provides access to the TVDB Api, unofficially for an Api key, register
|
143
|
+
at http://thetvdb.com/
|
144
|
+
email:
|
145
|
+
- lee.hambley@gmail.com
|
146
|
+
executables: []
|
147
|
+
extensions: []
|
148
|
+
extra_rdoc_files: []
|
149
|
+
files:
|
150
|
+
- .gitignore
|
151
|
+
- Gemfile
|
152
|
+
- Rakefile
|
153
|
+
- lib/base.rb
|
154
|
+
- lib/base/api/episode.rb
|
155
|
+
- lib/base/api/show.rb
|
156
|
+
- lib/core_ext/object.rb
|
157
|
+
- lib/helpers.rb
|
158
|
+
- lib/the_tv_db.rb
|
159
|
+
- lib/the_tv_db/api/episode.rb
|
160
|
+
- lib/the_tv_db/api/episode_list.rb
|
161
|
+
- lib/the_tv_db/api/image.rb
|
162
|
+
- lib/the_tv_db/api/image_list.rb
|
163
|
+
- lib/the_tv_db/api/image_list_helpers.rb
|
164
|
+
- lib/the_tv_db/api/mirror.rb
|
165
|
+
- lib/the_tv_db/api/mirrors.rb
|
166
|
+
- lib/the_tv_db/api/show.rb
|
167
|
+
- lib/the_tv_db/configuration.rb
|
168
|
+
- lib/tv_data_api_clients.rb
|
169
|
+
- lib/tv_data_api_clients/version.rb
|
170
|
+
- lib/tv_rage.rb
|
171
|
+
- lib/tv_rage/show.rb
|
172
|
+
- test/fixtures/example.gif
|
173
|
+
- test/fixtures/the_tv_db/api_get_series_lost.xml
|
174
|
+
- test/fixtures/the_tv_db/api_series_12345_all_en.xml
|
175
|
+
- test/fixtures/the_tv_db/api_series_73739_banners.xml
|
176
|
+
- test/fixtures/the_tv_db/api_series_73739_en.xml
|
177
|
+
- test/fixtures/tv_rage/feeds_search_show.xml
|
178
|
+
- test/fixtures/tv_rage/feeds_showinfo_sid_7926.xml
|
179
|
+
- test/support/shared_episode_naming_tests.rb
|
180
|
+
- test/support/shared_show_naming_tests.rb
|
181
|
+
- test/test_helper.rb
|
182
|
+
- test/unit/base/api/episode_test.rb
|
183
|
+
- test/unit/base/api/show_test.rb
|
184
|
+
- test/unit/the_tv_db/api/episode_list_test.rb
|
185
|
+
- test/unit/the_tv_db/api/episode_test.rb
|
186
|
+
- test/unit/the_tv_db/api/image_list_test.rb
|
187
|
+
- test/unit/the_tv_db/api/image_test.rb
|
188
|
+
- test/unit/the_tv_db/api/mirrors_test.rb
|
189
|
+
- test/unit/the_tv_db/api/show_test.rb
|
190
|
+
- test/unit/the_tv_db/configuration_test.rb
|
191
|
+
- test/unit/tv_rage/show_test.rb
|
192
|
+
- tv-data-api-clients.gemspec
|
193
|
+
homepage: http://thetvdb.com/
|
194
|
+
licenses: []
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options: []
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
201
|
+
requirements:
|
202
|
+
- - ! '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
none: false
|
207
|
+
requirements:
|
208
|
+
- - ! '>='
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
requirements: []
|
212
|
+
rubyforge_project:
|
213
|
+
rubygems_version: 1.8.23
|
214
|
+
signing_key:
|
215
|
+
specification_version: 3
|
216
|
+
summary: Unofficial Gem for accessing TheTvDb Api
|
217
|
+
test_files:
|
218
|
+
- test/fixtures/example.gif
|
219
|
+
- test/fixtures/the_tv_db/api_get_series_lost.xml
|
220
|
+
- test/fixtures/the_tv_db/api_series_12345_all_en.xml
|
221
|
+
- test/fixtures/the_tv_db/api_series_73739_banners.xml
|
222
|
+
- test/fixtures/the_tv_db/api_series_73739_en.xml
|
223
|
+
- test/fixtures/tv_rage/feeds_search_show.xml
|
224
|
+
- test/fixtures/tv_rage/feeds_showinfo_sid_7926.xml
|
225
|
+
- test/support/shared_episode_naming_tests.rb
|
226
|
+
- test/support/shared_show_naming_tests.rb
|
227
|
+
- test/test_helper.rb
|
228
|
+
- test/unit/base/api/episode_test.rb
|
229
|
+
- test/unit/base/api/show_test.rb
|
230
|
+
- test/unit/the_tv_db/api/episode_list_test.rb
|
231
|
+
- test/unit/the_tv_db/api/episode_test.rb
|
232
|
+
- test/unit/the_tv_db/api/image_list_test.rb
|
233
|
+
- test/unit/the_tv_db/api/image_test.rb
|
234
|
+
- test/unit/the_tv_db/api/mirrors_test.rb
|
235
|
+
- test/unit/the_tv_db/api/show_test.rb
|
236
|
+
- test/unit/the_tv_db/configuration_test.rb
|
237
|
+
- test/unit/tv_rage/show_test.rb
|
238
|
+
has_rdoc:
|