tvdbr 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/examples/demo2.rb +4 -0
- data/lib/tvdbr/data_set.rb +10 -4
- data/lib/tvdbr/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tvdbr (0.
|
4
|
+
tvdbr (0.2.0)
|
5
5
|
hashie
|
6
6
|
httparty (>= 0.8.0)
|
7
7
|
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
activesupport (3.0.0)
|
12
12
|
hashie (1.2.0)
|
13
|
-
httparty (0.
|
13
|
+
httparty (0.9.0)
|
14
14
|
multi_json (~> 1.0)
|
15
15
|
multi_xml
|
16
16
|
i18n (0.6.1)
|
data/examples/demo2.rb
CHANGED
@@ -5,6 +5,10 @@ require 'active_support/all'
|
|
5
5
|
# Updated APIs circa 10/05/2012
|
6
6
|
tvdb = Tvdbr::Client.new('5FEC454623154441')
|
7
7
|
|
8
|
+
# Find episode by id
|
9
|
+
episode = tvdb.find_episode_by_id(326177)
|
10
|
+
puts episode.inspect
|
11
|
+
|
8
12
|
# Find episode with airdate
|
9
13
|
episode = tvdb.find_episode_by_airdate(80348, '2007-09-24')
|
10
14
|
puts episode.inspect
|
data/lib/tvdbr/data_set.rb
CHANGED
@@ -7,10 +7,10 @@ module Tvdbr
|
|
7
7
|
## INSTANCE METHODS ##
|
8
8
|
|
9
9
|
# Tvdb::DataSet.new(self, { :foo => "bar" })
|
10
|
-
def initialize(parent,
|
10
|
+
def initialize(parent, source_hash = nil, default = nil, &block)
|
11
11
|
@parent = parent
|
12
|
-
|
13
|
-
super(
|
12
|
+
source_hash = normalize_keys(source_hash) if source_hash.is_a?(Hash)
|
13
|
+
super(source_hash, default, &block)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Outputs: <#Tvdb::Series actors="..." added=nil added_by=nil>
|
@@ -61,11 +61,17 @@ module Tvdbr
|
|
61
61
|
# => [:foo => "bar", ...]
|
62
62
|
def normalize_keys(hash)
|
63
63
|
hash.inject({}) do |options, (key, value)|
|
64
|
-
options[(underscore(key) rescue key) || key] = value
|
64
|
+
options[(underscore(key) rescue key) || key] = normalize_value(value)
|
65
65
|
options
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
# Normalizes a value for the formatted hash
|
70
|
+
# Sometimes TVDB returns a hash with a "__content__" key which needs to be removed
|
71
|
+
def normalize_value(val)
|
72
|
+
val.respond_to?(:has_key?) && val.has_key?("__content__") ? val["__content__"] : val
|
73
|
+
end
|
74
|
+
|
69
75
|
def underscore(camel_cased_word)
|
70
76
|
word = camel_cased_word.to_s.dup
|
71
77
|
word.gsub!(/::/, '/')
|
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.1
|
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-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|