thetvdb_party 0.0.3.pre → 0.0.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/lib/thetvdb_party/baseseriesrecord.rb +131 -0
- data/lib/thetvdb_party/client.rb +77 -0
- data/lib/thetvdb_party/searchseriesrecord.rb +82 -0
- data/lib/thetvdb_party/version.rb +1 -1
- data/spec/spec_helper.rb +91 -0
- data/spec/thetvdb_party_spec.rb +32 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a24afc1e632c9b90ef99ffc1637e516512d871b
|
4
|
+
data.tar.gz: b9108ddf1caadb00a329c1c2182d7626746aef45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d290af51be12bd346ae205265413114b97115cfb35a54eba48895bdb6af42c9afbd3b3088175acef5db2ea172e2bbb048ac712d89ac652ca9686225d5c0047c
|
7
|
+
data.tar.gz: 2ea5deaa5750fe06d0f83b28609b1e91c8ae0d38fd3beaabc156dd078d66df006ad7761f9a0a2bcfb7c8005bc9867801229d6ace130ba4285a1746619237d63b
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
module TheTvDbParty
|
2
|
+
# The Base Series Record contains all of the information available about a series. It does not include any banner, season, or episode information.
|
3
|
+
class BaseSeriesRecord
|
4
|
+
|
5
|
+
attr_reader :client
|
6
|
+
attr_reader :seriesid, :actors, :added, :addedby, :airs_dayofweek, :airs_time, :bannerpath_full, :bannerpath_relative, :contentrating, :fanartpath_full, :fanartpath_relative, :firstaired, :genres, :imdb_id, :language, :lastupdated, :network, :networkid, :overview, :posterpath_full, :posterpath_relative, :rating, :ratingcount, :runtime, :seriesid, :seriesname, :status, :tvcom_id, :zap2it_id
|
7
|
+
|
8
|
+
# @param [TheTvDbParty::Client] client
|
9
|
+
# @param [Hash{String => String}] hashValues
|
10
|
+
def initialize(client, hashValues)
|
11
|
+
@client = client
|
12
|
+
@hashValues = hashValues
|
13
|
+
end
|
14
|
+
|
15
|
+
# The client instance that retrieved this record
|
16
|
+
# @return [TheTvDbParty::Client]
|
17
|
+
def client; @client end
|
18
|
+
|
19
|
+
# The identifier that is assigned by TheTvDb to the series
|
20
|
+
# @return [Fixnum] An unsigned integer assigned by our site to the series. It does not change and will always represent the same series. Cannot be nil.
|
21
|
+
def seriesid; hashValues["id"] ? @hashValues["id"].to_i : -1 end
|
22
|
+
|
23
|
+
# The actors that make up the main cast for the series
|
24
|
+
# @return [Array<String>] An array containg the names of actors as string values. Empty if none are listed.
|
25
|
+
def actors; hashValues["Actors"] ? @hashValues["Actors"].split('|').reject { |a| a.nil? || a.empty? } : [] end
|
26
|
+
|
27
|
+
# The day of the week the series airs
|
28
|
+
# @return [String] The full name in English for the day of the week the series airs in plain text. Can be nil.
|
29
|
+
def airs_dayofweek; @hashValues["Airs_DayOfWeek"] end
|
30
|
+
|
31
|
+
# The time of day the series airs on its original network.
|
32
|
+
# @return [Time, NilClass] The time of day the series airs on its original network. Can be nil
|
33
|
+
# @note The Date portion of the returned value is not relevant
|
34
|
+
def airs_time; @hashValues["Airs_Time"] ? Time.parse(@hashValues["Airs_Time"]) : nil end
|
35
|
+
|
36
|
+
# The rating given to the series based on the US rating system
|
37
|
+
# @return [String] Can be nil or a 4-5 character string.
|
38
|
+
def contentrating; @hashValues["ContentRating"] end
|
39
|
+
|
40
|
+
# The date the series first aired
|
41
|
+
# @return [Date, NilClass] The date the series first aired. Can be nil
|
42
|
+
def firstaired; @hashValues["FirstAired"] ? Date.parse(hashValues["FirstAired"]) : nil end
|
43
|
+
|
44
|
+
# The Genres of the series
|
45
|
+
# @return [Array<String>] A list of genre names. Empty if none are listed
|
46
|
+
def genres; @hashValues["Genre"] ? @hashValues["Genre"].split('|').reject { |a| a.nil? || a.empty? } : [] end
|
47
|
+
|
48
|
+
# The IMDB ID for the series.
|
49
|
+
# @return [String] An alphanumeric string containing the IMDB ID for the series. Can be nil.
|
50
|
+
def imdb_id; @hashValues["IMDB_ID"] end
|
51
|
+
|
52
|
+
# The language of the information that is included in the current record.
|
53
|
+
# @return [String] A two character string indicating the language in accordance with ISO-639-1. Cannot be nil.
|
54
|
+
def language; @hashValues["Language"] end
|
55
|
+
|
56
|
+
# The network name on which the series airs
|
57
|
+
# @return [String] A string containing the network name in plain text. Can be nil.
|
58
|
+
def network; @hashValues["Network"] end
|
59
|
+
|
60
|
+
# @return [Fixnum] Not in use, will be an unsigned integer if ever used. Can be nil.
|
61
|
+
def networkid; @hashValues["NetworkID"] ? @hashValues["NetworkID"].to_i : -1 end
|
62
|
+
|
63
|
+
# The overview for the series, if possible in the language requested
|
64
|
+
# @return [String] A string containing the overview in the language requested. Will return the English overview if no translation is available in the language requested. Can be nil.
|
65
|
+
def overview; @hashValues["Overview"] end
|
66
|
+
|
67
|
+
# The average rating our users have rated the series out of 10
|
68
|
+
# @return [Float] The average rating our users have rated the series out of 10, rounded to 1 decimal place. 0.0 if no one has rated the series.
|
69
|
+
def rating; @hashValues["Rating"] ? @hashValues["Rating"].to_f : 0.0 end
|
70
|
+
|
71
|
+
# The number of users who have rated the series
|
72
|
+
# @return [Fixnum] An unsigned integer representing the number of users who have rated the series.
|
73
|
+
def ratingcount; @hashValues["RatingCount"] ? @hashValues["RatingCount"].to_i : 0 end
|
74
|
+
|
75
|
+
# The runtime in minutes of an episode of the series.
|
76
|
+
# @return [Fixnum] An unsigned integer representing the runtime of the series in minutes. -1 if the information is not available.
|
77
|
+
def runtime; @hashValues["Runtime"] ? @hashValues["Runtime"].to_i : -1 end
|
78
|
+
|
79
|
+
# The series id at tv.com
|
80
|
+
# @deprecated As TV.com now only uses these ID's internally it's of little use and no longer updated.
|
81
|
+
# @return [Fixnum, NilClass] An unsigned integer representing the series ID at tv.com. Can be nil.
|
82
|
+
def tvcom_id; @hashValues["SeriesID"] ? @hashValues["SeriesID"].to_i : nil end
|
83
|
+
|
84
|
+
# The name of the series, if possible in the language requested
|
85
|
+
# @return [String] A string containing the series name in the language you requested. Will return the English name if no translation is found in the language requested. Can be nil if the name isn't known in the requested language or English.
|
86
|
+
def seriesname; @hashValues["SeriesName"] end
|
87
|
+
|
88
|
+
# The status of the series
|
89
|
+
# @return [String] A string containing either "Ended" or "Continuing". Can be nil.
|
90
|
+
def status; @hashValues["Status"] end
|
91
|
+
|
92
|
+
# The date and time the series was added to the TheTvDb database.
|
93
|
+
# @return [DateTime, NilClass] Can be nil for older series
|
94
|
+
def added; @hashValues["added"] ? DateTime.parse(@hashValues["added"]) : nil end
|
95
|
+
|
96
|
+
# The user account identifier of the user who added the series to the database
|
97
|
+
# @return [Fixnum, NilClass] An unsigned integer. The ID of the user on our site who added the series to our database. Is nil for older series.
|
98
|
+
def addedby; @hashValues["addedBy"] ? @hashValues["addedBy"].to_i : nil end
|
99
|
+
|
100
|
+
# The path to the highest rated banner for this series.
|
101
|
+
# @return [String] Returns the relative path to the highest rated banner for this series. Retrieve {#bannerpath_full} get the absolute path.
|
102
|
+
def bannerpath_relative; @hashValues["banner"] end
|
103
|
+
|
104
|
+
# The path to the highest rated fanart for this series.
|
105
|
+
# @return [String] Returns the relative path to the highest rated fanart for this series. Retrieve {#fanartpath_full} get the absolute path.
|
106
|
+
def fanartpath_relative; @hashValues["fanart"] end
|
107
|
+
|
108
|
+
# The path to the highest rated poster for this series.
|
109
|
+
# @return [String] Returns the relative path to the highest rated poster for this series. Retrieve {#posterpath_full} get the absolute path.
|
110
|
+
def posterpath_relative; @hashValues["poster"] end
|
111
|
+
|
112
|
+
# The zap2it id for the series
|
113
|
+
# @return [String] An alphanumeric string containing the zap2it id. Can be nil.
|
114
|
+
def zap2it_id; @hashValues["zap2it_id"] end
|
115
|
+
|
116
|
+
# The time and date of the last time any changes were made to the series
|
117
|
+
# @return [DateTime] An instance containing both time and date of the last update. Can be nil
|
118
|
+
def lastupdated; @hashValues["lastupdated"] ? Time.at(@hashValues["lastupdated"].to_i).to_datetime : nil end
|
119
|
+
|
120
|
+
# The full path to the banner for the series.
|
121
|
+
# @return [URI] The full path for the highest rated banner for the series, returned as a URI instance.def bannerpath_full; URI::join(BASE_URL, "banners", bannerpath_relative) end
|
122
|
+
|
123
|
+
# The full path to the banner for the series.
|
124
|
+
# @return [URI] The full path for the highest rated fanart for the series, returned as a URI instance.
|
125
|
+
def fanartpath_full; URI::join(BASE_URL, "banners", fanartpath_relative) end
|
126
|
+
|
127
|
+
# The full path to the banner for the series.
|
128
|
+
# @return [URI] The full path for the highest rated poster for the series, returned as a URI instance.
|
129
|
+
def posterpath_full; URI::join(BASE_URL, "banners", posterpath_relative) end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module TheTvDbParty
|
2
|
+
# The ThTvDb API client
|
3
|
+
class Client
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
attr_accessor :apikey, :language
|
7
|
+
|
8
|
+
@language = nil
|
9
|
+
|
10
|
+
# Creates a new TheTvDb client with the given API key
|
11
|
+
# @param [String] apikey The API key to use when accessing the ThTvDb programmers API
|
12
|
+
# @note If nil is specified for _apikey_, the client will not be able to access the API successfully for most functions
|
13
|
+
# The {#search} method will always be available, even if you do not have a valid API key.
|
14
|
+
def initialize(apikey)
|
15
|
+
@apikey = apikey
|
16
|
+
end
|
17
|
+
|
18
|
+
# Accesses the API key currently used by the client
|
19
|
+
# @return [String] The API key that is currently in use
|
20
|
+
def apikey; @apikey end
|
21
|
+
# @param [String] value The new API key to use
|
22
|
+
# @return [String] The new value
|
23
|
+
def apikey=(value) @apikey = value end
|
24
|
+
|
25
|
+
# Accesses the language currently used by the client when accessing the TheTvDb API.
|
26
|
+
# @return [String] A two-letter string value indicating the language used. May also be 'all' if all availabe translations are retrieved from TheTvDb
|
27
|
+
# @return [NilClass] nil if the default language (english) should be used.
|
28
|
+
def language; @language end
|
29
|
+
# @param [String, NilClass] value A two-letter string value indicating the language used. May also be 'all' if all availabe translations are retrieved from TheTvDb. The may also be nil if the language does not need to be specified explicitly.
|
30
|
+
# @return [String] The new value
|
31
|
+
def language=(value) @language = value end
|
32
|
+
|
33
|
+
# This interface allows you to find the id of a series based on its name.
|
34
|
+
# @param [String] seriesname This is the string you want to search for. If there is an exact match for the parameter, it will be the first result returned.
|
35
|
+
# @return [Array<TheTvDbParty::SearchSeriesRecord>] An array of records that represent the search results.
|
36
|
+
# @see http://thetvdb.com/wiki/index.php?title=API:GetSeries
|
37
|
+
# @note The method call with the account identifier is currently not supported.
|
38
|
+
# @see #search
|
39
|
+
def get_series(seriesname) search seriesname end
|
40
|
+
|
41
|
+
# This interface allows you to find the id of a series based on its name.
|
42
|
+
# @param [String] seriesname This is the string you want to search for. If there is an exact match for the parameter, it will be the first result returned.
|
43
|
+
# @return [Array<TheTvDbParty::SearchSeriesRecord>] An array of records that represent the search results.
|
44
|
+
# @see http://thetvdb.com/wiki/index.php?title=API:GetSeries
|
45
|
+
# @note The method call with the account identifier is currently not supported.
|
46
|
+
def search(seriesname)
|
47
|
+
http_query = { :seriesname => seriesname }
|
48
|
+
http_query[:language => @language] if @language
|
49
|
+
response = self.class.get(URI::join(BASE_URL, 'GetSeries.php'), { :query => http_query }).parsed_response
|
50
|
+
return [] unless response["Data"]
|
51
|
+
case response["Data"]["Series"]
|
52
|
+
when Array
|
53
|
+
response["Data"]["Series"].map {|s|SearchSeriesRecord.new(self, s)}
|
54
|
+
when Hash
|
55
|
+
[SearchSeriesRecord.new(self, response["Data"]["Series"])]
|
56
|
+
else
|
57
|
+
[]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Retrieves the Base Series Record for a given series by its series id.
|
62
|
+
# @param [String, Fixnum] seriesid The TheTvDb assigned unique identifier for the series to access.
|
63
|
+
# @return [TheTvDbParty::BaseSeriesRecord] A base series record instance or nil if the series could not be found.
|
64
|
+
def get_base_series_record(seriesid, language = nil)
|
65
|
+
unless @language
|
66
|
+
request_url = "#{@apikey}/series/#{seriesid}"
|
67
|
+
else
|
68
|
+
request_url = "#{@apikey}/series/#{seriesid}/#{@language}.xml"
|
69
|
+
end
|
70
|
+
request_url = URI.join(BASE_URL, request_url)
|
71
|
+
resp = self.class.get(request_url).parsed_response
|
72
|
+
return nil unless resp["Data"]["Series"]
|
73
|
+
BaseSeriesRecord.new(self, resp["Data"]["Series"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module TheTvDbParty
|
2
|
+
# Represents one record within the search results for a series search
|
3
|
+
# @example Getting a list of search results from a client
|
4
|
+
# results = TheTvDbParty::Client.new(nil).search "The Mentalist"
|
5
|
+
# @example Using the search result record to fetch the Base Series Record
|
6
|
+
# base_series_record = TheTvDbParty::Client.new(nil).get_base_series_record search_series_record.seriesid
|
7
|
+
class SearchSeriesRecord
|
8
|
+
|
9
|
+
attr_reader :client
|
10
|
+
attr_reader :id, :seriesid, :language, :seriesname, :aliasnames, :bannerpath_relative, :overview, :firstaired, :imdb_id, :zap2it_id, :network, :bannerpath_full
|
11
|
+
|
12
|
+
# Initializes a new Search Series Record as is was retrieved from the TheTvDb API
|
13
|
+
# @param [TheTvDbParty::Client] client The client instance that retrieved the record
|
14
|
+
# @param [Hash{String => String}] hashValues A Hash instance that maps the record attribute element names against their values represented as strings.
|
15
|
+
def initialize(client, hashValues)
|
16
|
+
@client = client
|
17
|
+
@hashValues = hashValues
|
18
|
+
end
|
19
|
+
|
20
|
+
# The client instance that retrieved this record
|
21
|
+
# @return [TheTvDbParty::Client]
|
22
|
+
def client; @client end
|
23
|
+
|
24
|
+
# The unique TheTvDb identifier to access the more detailed Base Series Record and Full Series Record
|
25
|
+
# @deprecated {#id} is only included to be backwards compatible with the old API and is deprecated.
|
26
|
+
# @return [Fixnum] Returns an unsigned integer, or -1 if the record is invalid
|
27
|
+
# @see #seriesid
|
28
|
+
def id; @hashValues["id"] ? @hashValues["id"].to_i : -1 end
|
29
|
+
|
30
|
+
# The unique TheTvDb identifier to access the more detailed Base Series Record and Full Series Record
|
31
|
+
# @return [Fixnum] Returns an unsigned integer, or -1 if the record is invalid
|
32
|
+
def seriesid; @hashValues["seriesid"] ? @hashValues["seriesid"].to_i : -1 end
|
33
|
+
|
34
|
+
# The language used for the information included in the current record
|
35
|
+
# @return [String] Returns a two digit string indicating the language.
|
36
|
+
def language; @hashValues["language"] end
|
37
|
+
|
38
|
+
# The name of the Series
|
39
|
+
# @return [String] Returns a string with the series name for the language indicated
|
40
|
+
def seriesname; @hashValues["SeriesName"] end
|
41
|
+
|
42
|
+
# Other names of the series than the information returned by {#seriesname}
|
43
|
+
# @return [Array<String>] An array of alias names if the series has any other names in that language. Empty if the record does not have any aliases
|
44
|
+
def aliasnames; @hashValues["AliasNames"] ? @hashValues["AliasNames"].split('|').reject { |a| a.nil? || a.empty? } : [] end
|
45
|
+
|
46
|
+
# The path to the highest rated banner for this series.
|
47
|
+
# @return [String] Returns the relative path to the highest rated banner for this series. Retrieve {#bannerpath_full} get the absolute path.
|
48
|
+
def bannerpath_relative; @hashValues["banner"] end
|
49
|
+
|
50
|
+
# A short summary of the series
|
51
|
+
# @return [String] Returns the overview for the series
|
52
|
+
def overview; @hashValues["Overview"] end
|
53
|
+
|
54
|
+
# The first aired date of the series
|
55
|
+
# @return [Date] Returns the first aired date for the series as a Date instance
|
56
|
+
# @return [NilClass] Returns nil if the information is not available
|
57
|
+
def firstaired; @hashValues["FirstAired"] ? Date.parse(@hashValues["FirstAired"]) : nil end
|
58
|
+
|
59
|
+
# The IMDB id for the series
|
60
|
+
# @return [String] Returns the IMDB id for the series if known. Otherwise, nil
|
61
|
+
def imdb_id; @hashValues["IMDB_ID"] end
|
62
|
+
|
63
|
+
# The zap2it id for the series
|
64
|
+
# @return [String] Returns the zap2it ID if known. Otherwise, nil
|
65
|
+
def zap2it_id; @hashValues["zap2it_id"] end
|
66
|
+
|
67
|
+
# The network name on which the series aires
|
68
|
+
# @return [String] Returns the Network name if known; Otherwise, nil.
|
69
|
+
def network; @hashValues["Network"] end
|
70
|
+
|
71
|
+
# The full path to the banner for the series.
|
72
|
+
# @return [URI] The full path for the highest rated banner for the series, returned as a URI instance.
|
73
|
+
def bannerpath_full; URI::join(BASE_URL, "banners", bannerpath_relative) end
|
74
|
+
|
75
|
+
# Retrieves the Base Series Record for the series
|
76
|
+
# @return [TheTvDbParty::BaseSeriesRecord] The Base Series Record for the series
|
77
|
+
# @see TheTvDbParty::Client.get_base_series_record
|
78
|
+
def get_base_series_record
|
79
|
+
client.get_base_series_record seriesid
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
52
|
+
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
54
|
+
# recommended. For more details, see:
|
55
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
+
config.disable_monkey_patching!
|
59
|
+
|
60
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
61
|
+
# be too noisy due to issues in dependencies.
|
62
|
+
config.warnings = true
|
63
|
+
|
64
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
65
|
+
# file, and it's useful to allow more verbose output when running an
|
66
|
+
# individual spec file.
|
67
|
+
if config.files_to_run.one?
|
68
|
+
# Use the documentation formatter for detailed output,
|
69
|
+
# unless a formatter has already been configured
|
70
|
+
# (e.g. via a command-line flag).
|
71
|
+
config.default_formatter = 'doc'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Print the 10 slowest examples and example groups at the
|
75
|
+
# end of the spec run, to help surface which specs are running
|
76
|
+
# particularly slow.
|
77
|
+
config.profile_examples = 10
|
78
|
+
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
81
|
+
# the seed, which is printed after each run.
|
82
|
+
# --seed 1234
|
83
|
+
config.order = :random
|
84
|
+
|
85
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
86
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
87
|
+
# test failures related to randomization by passing the same `--seed` value
|
88
|
+
# as the one that triggered the failure.
|
89
|
+
Kernel.srand config.seed
|
90
|
+
=end
|
91
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'thetvdb_party'
|
2
|
+
|
3
|
+
describe 'Client.search' do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@client = TheTvDbParty::Client.new("5CB46CA60629B0DD")
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should return matches for "The Mentalist"' do
|
10
|
+
matches = @client.search "The Mentalist"
|
11
|
+
expect matches.count > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return more than one match for "Star Trek"' do
|
15
|
+
matches = @client.search "Star Trek"
|
16
|
+
expect matches.count > 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'Client.get_base_series_record' do
|
21
|
+
before(:each) do
|
22
|
+
@client = TheTvDbParty::Client.new("5CB46CA60629B0DD")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return records that match the search result' do
|
26
|
+
matches = @client.search "Star Trek"
|
27
|
+
matches.each do |ssr|
|
28
|
+
bsr = @client.get_base_series_record(ssr.seriesid)
|
29
|
+
expect bsr.seriesname == ssr.seriesname
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thetvdb_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fredrik Høisæther Rasch
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-02-
|
15
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -83,12 +83,18 @@ extensions: []
|
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
85
|
- ".gitignore"
|
86
|
+
- ".rspec"
|
86
87
|
- Gemfile
|
87
88
|
- LICENSE.txt
|
88
89
|
- README.md
|
89
90
|
- Rakefile
|
90
91
|
- lib/thetvdb_party.rb
|
92
|
+
- lib/thetvdb_party/baseseriesrecord.rb
|
93
|
+
- lib/thetvdb_party/client.rb
|
94
|
+
- lib/thetvdb_party/searchseriesrecord.rb
|
91
95
|
- lib/thetvdb_party/version.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/thetvdb_party_spec.rb
|
92
98
|
- thetvdb_party.gemspec
|
93
99
|
homepage: https://rubygems.org/gems/thetvdb_party
|
94
100
|
licenses:
|
@@ -119,5 +125,7 @@ rubygems_version: 2.4.5
|
|
119
125
|
signing_key:
|
120
126
|
specification_version: 4
|
121
127
|
summary: Ruby Gem for accessing the TheTVDB programmers API
|
122
|
-
test_files:
|
128
|
+
test_files:
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- spec/thetvdb_party_spec.rb
|
123
131
|
has_rdoc:
|