tvdbr 0.2.1 → 0.2.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/Gemfile.lock +1 -1
- data/examples/demo2.rb +2 -0
- data/lib/tvdbr/data_set.rb +15 -3
- data/lib/tvdbr/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/examples/demo2.rb
CHANGED
@@ -8,6 +8,8 @@ tvdb = Tvdbr::Client.new('5FEC454623154441')
|
|
8
8
|
# Find episode by id
|
9
9
|
episode = tvdb.find_episode_by_id(326177)
|
10
10
|
puts episode.inspect
|
11
|
+
episode = tvdb.find_episode_by_id(174207)
|
12
|
+
puts episode.inspect
|
11
13
|
|
12
14
|
# Find episode with airdate
|
13
15
|
episode = tvdb.find_episode_by_airdate(80348, '2007-09-24')
|
data/lib/tvdbr/data_set.rb
CHANGED
@@ -2,6 +2,8 @@ require 'hashie' unless defined?(Hashie)
|
|
2
2
|
|
3
3
|
module Tvdbr
|
4
4
|
class DataSet < Hashie::Mash
|
5
|
+
class InvalidFormat < StandardError; end
|
6
|
+
|
5
7
|
attr_reader :parent
|
6
8
|
|
7
9
|
## INSTANCE METHODS ##
|
@@ -11,6 +13,8 @@ module Tvdbr
|
|
11
13
|
@parent = parent
|
12
14
|
source_hash = normalize_keys(source_hash) if source_hash.is_a?(Hash)
|
13
15
|
super(source_hash, default, &block)
|
16
|
+
rescue ArgumentError => e # #<ArgumentError: wrong number of arguments (0 for 1)>
|
17
|
+
raise InvalidFormat, "#{self.class.name} parse failed with source #{source_hash.inspect}"
|
14
18
|
end
|
15
19
|
|
16
20
|
# Outputs: <#Tvdb::Series actors="..." added=nil added_by=nil>
|
@@ -66,10 +70,18 @@ module Tvdbr
|
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
|
-
# Normalizes a value for the formatted hash
|
70
|
-
#
|
73
|
+
# Normalizes a value for the formatted hash values
|
74
|
+
# TVDB hashes should not contain more hashes
|
75
|
+
# Sometimes TVDB returns a hash with content inside which needs to be extracted
|
71
76
|
def normalize_value(val)
|
72
|
-
|
77
|
+
if val.is_a?(Hash)
|
78
|
+
val = val["__content__"] if val.has_key?("__content__")
|
79
|
+
val = val.values.first if val.respond_to?(:values) && val.values.one?
|
80
|
+
val = val.join(" ") if val.respond_to?(:join)
|
81
|
+
val.to_s
|
82
|
+
else # any other value
|
83
|
+
val
|
84
|
+
end
|
73
85
|
end
|
74
86
|
|
75
87
|
def underscore(camel_cased_word)
|
data/lib/tvdbr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvdbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|