zelda 1.1.1 → 1.2.0
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/CHANGELOG.md +8 -2
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/lib/zelda/base.rb +5 -18
- data/lib/zelda/omroep.rb +2 -0
- data/lib/zelda/version.rb +1 -1
- data/lib/zelda/zender.rb +5 -11
- data/spec/zelda/omroep_spec.rb +0 -1
- data/spec/zelda/zender_spec.rb +5 -5
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
## 1.
|
1
|
+
## 1.2.0 (Aug 15, 2011)
|
2
2
|
|
3
3
|
Bugfixes:
|
4
4
|
|
5
5
|
- Fix the response hash key, since it is named after the resource
|
6
|
-
|
6
|
+
- Zender find works using the code field, not the id.
|
7
|
+
- Replaced method_missing with define_method.
|
8
|
+
|
9
|
+
Features:
|
10
|
+
|
11
|
+
- Now tested with Travis
|
12
|
+
|
7
13
|
|
8
14
|
## 1.1.0 (Aug 11, 2011)
|
9
15
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zelda (1.
|
4
|
+
zelda (1.2.0)
|
5
5
|
httparty
|
6
6
|
|
7
7
|
GEM
|
@@ -11,6 +11,7 @@ GEM
|
|
11
11
|
diff-lcs (1.1.2)
|
12
12
|
httparty (0.7.8)
|
13
13
|
crack (= 0.1.8)
|
14
|
+
rake (0.9.2)
|
14
15
|
rspec (2.6.0)
|
15
16
|
rspec-core (~> 2.6.0)
|
16
17
|
rspec-expectations (~> 2.6.0)
|
@@ -25,5 +26,6 @@ PLATFORMS
|
|
25
26
|
|
26
27
|
DEPENDENCIES
|
27
28
|
httparty
|
29
|
+
rake
|
28
30
|
rspec
|
29
31
|
zelda!
|
data/lib/zelda/base.rb
CHANGED
@@ -1,25 +1,12 @@
|
|
1
1
|
module Zelda
|
2
2
|
# Abstract base class to provide common functionality of Zelda importer classes.
|
3
|
-
#
|
3
|
+
# Every key in the hash is turned into a method, returning the value.
|
4
4
|
class Base
|
5
5
|
def initialize(attributes={})
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_reader :attributes
|
14
|
-
|
15
|
-
# Try both string keys and symbol keys in that order.
|
16
|
-
def method_missing(method, *args, &block)
|
17
|
-
if @attributes[method]
|
18
|
-
return @attributes[method]
|
19
|
-
elsif @attributes.key?(method)
|
20
|
-
return nil
|
21
|
-
else
|
22
|
-
super(method, *args, &block)
|
6
|
+
attributes.each_pair do |key, value|
|
7
|
+
self.class.send(:define_method, key) do
|
8
|
+
value
|
9
|
+
end
|
23
10
|
end
|
24
11
|
end
|
25
12
|
end
|
data/lib/zelda/omroep.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Zelda
|
2
2
|
class Omroep < Zelda::Base
|
3
3
|
class << self
|
4
|
+
# Find an omroep by slug, such as +kro+.
|
4
5
|
def find(slug)
|
5
6
|
attrs = Request.get("omroepen/#{slug}")['omroep'] rescue nil
|
6
7
|
attrs ? new(attrs) : nil
|
7
8
|
end
|
8
9
|
|
10
|
+
# Find all omroepen.
|
9
11
|
def all
|
10
12
|
Request.get("omroepen")['omroepen']
|
11
13
|
end
|
data/lib/zelda/version.rb
CHANGED
data/lib/zelda/zender.rb
CHANGED
@@ -1,24 +1,18 @@
|
|
1
1
|
module Zelda
|
2
2
|
class Zender < Zelda::Base
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
4
|
+
# Find a Zender by code, such as +NL1+ or +101+.
|
5
|
+
def find(code)
|
6
|
+
attrs = Request.get("zenders/#{code}")['zender'] rescue nil
|
6
7
|
attrs ? new(attrs) : nil
|
7
8
|
end
|
8
9
|
|
10
|
+
# Find all Zenders.
|
9
11
|
def all
|
10
|
-
Request.get("zenders")
|
12
|
+
Request.get("zenders")['zenders']
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
def name
|
15
|
-
attributes[:zender]["name"]
|
16
|
-
end
|
17
|
-
|
18
|
-
def code
|
19
|
-
attributes[:zender]["code"]
|
20
|
-
end
|
21
|
-
|
22
16
|
# Return all Series for this Zender.
|
23
17
|
def series
|
24
18
|
Zelda::Request.get("zenders/#{id}/series")['zender']['series']['serie'].map do |attrs|
|
data/spec/zelda/omroep_spec.rb
CHANGED
data/spec/zelda/zender_spec.rb
CHANGED
@@ -5,23 +5,23 @@ describe Zelda::Zender do
|
|
5
5
|
|
6
6
|
describe "when retrieving a list of zenders" do
|
7
7
|
it "should call Zelda with the correct url" do
|
8
|
-
Zelda::Request.should_receive(:get).with("zenders")
|
9
|
-
Zelda::Zender.all
|
8
|
+
Zelda::Request.should_receive(:get).with("zenders").and_return('zenders' => ['zender'])
|
9
|
+
Zelda::Zender.all.should == ['zender']
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "when retrieving a specific zender" do
|
14
14
|
before(:each) do
|
15
15
|
zender_attrs = { "zender" => {"code" => "NL1", "name" => "Nederland 1"} }
|
16
|
-
Zelda::Request.stub!(:get).with("zenders/
|
16
|
+
Zelda::Request.stub!(:get).with("zenders/NL1").and_return zender_attrs
|
17
17
|
end
|
18
18
|
|
19
19
|
def find_zender
|
20
|
-
Zelda::Zender.find(
|
20
|
+
Zelda::Zender.find('NL1')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should call Zelda with the correct url" do
|
24
|
-
Zelda::Request.should_receive(:get).with("zenders/
|
24
|
+
Zelda::Request.should_receive(:get).with("zenders/NL1")
|
25
25
|
find_zender
|
26
26
|
end
|
27
27
|
|