zelda 1.0.0 → 1.1.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 +10 -1
- data/Gemfile.lock +1 -1
- data/lib/zelda/base.rb +13 -11
- data/lib/zelda/version.rb +1 -1
- data/lib/zelda/zender.rb +2 -2
- data/spec/support/shared_examples.rb +6 -2
- data/spec/zelda/aflevering_spec.rb +1 -4
- data/spec/zelda/omroep_spec.rb +1 -4
- data/spec/zelda/serie_spec.rb +7 -5
- data/spec/zelda/zender_spec.rb +2 -0
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.1.0 (Aug 11, 2011)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Return nil for attributes that exist, but have nil value
|
6
|
+
- Made the base class slimmer
|
7
|
+
- Shared examples for the base class are now less brittle
|
8
|
+
|
9
|
+
|
1
10
|
## 1.0.0 (Aug 11, 2011)
|
2
11
|
|
3
12
|
Features:
|
@@ -52,4 +61,4 @@ Features:
|
|
52
61
|
|
53
62
|
Features:
|
54
63
|
|
55
|
-
- Initial version
|
64
|
+
- Initial version
|
data/Gemfile.lock
CHANGED
data/lib/zelda/base.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
module Zelda
|
2
2
|
# Abstract base class to provide common functionality of Zelda importer classes.
|
3
|
-
# including method_missing magic to turn an @
|
3
|
+
# including method_missing magic to turn an @attributes hash into getters.
|
4
4
|
class Base
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(attributes={})
|
6
|
+
@attributes = {}
|
7
|
+
|
8
|
+
attributes.each do |key, value|
|
9
|
+
@attributes[key.to_sym] = value
|
10
|
+
end
|
7
11
|
end
|
8
|
-
|
9
|
-
|
10
|
-
@attrs
|
11
|
-
end
|
12
|
+
|
13
|
+
attr_reader :attributes
|
12
14
|
|
13
15
|
# Try both string keys and symbol keys in that order.
|
14
16
|
def method_missing(method, *args, &block)
|
15
|
-
if @
|
16
|
-
return @
|
17
|
-
elsif @
|
18
|
-
return
|
17
|
+
if @attributes[method]
|
18
|
+
return @attributes[method]
|
19
|
+
elsif @attributes.key?(method)
|
20
|
+
return nil
|
19
21
|
else
|
20
22
|
super(method, *args, &block)
|
21
23
|
end
|
data/lib/zelda/version.rb
CHANGED
data/lib/zelda/zender.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
shared_examples_for "a zelda base model" do
|
2
2
|
it "should respond to the attributes set in the constructor" do
|
3
|
-
|
3
|
+
described_class.new(:foo => 'bar').foo.should eq('bar')
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should return nil for an attribute set to nil" do
|
7
|
+
described_class.new(:foo => nil).foo.should be_nil
|
4
8
|
end
|
5
9
|
|
6
10
|
it "should not respond to attributes not set in the constructor" do
|
7
|
-
lambda {
|
11
|
+
lambda { subject.no_not_here_nope }.should raise_error(NoMethodError)
|
8
12
|
end
|
9
13
|
end
|
data/spec/zelda/omroep_spec.rb
CHANGED
data/spec/zelda/serie_spec.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Zelda::Serie do
|
4
|
+
it_should_behave_like 'a zelda base model'
|
5
|
+
|
4
6
|
describe "current series" do
|
5
7
|
it "calls Zelda with the correct url" do
|
6
|
-
Zelda::Request.should_receive(:get).with("current_series").and_return({'series' => ['
|
8
|
+
Zelda::Request.should_receive(:get).with("current_series").and_return({'series' => [{'titel' => 'Titeuf'}]})
|
7
9
|
Zelda::Serie.stub(:new).and_return('serie')
|
8
10
|
Zelda::Serie.current.should == ['serie']
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should return an array of series" do
|
12
|
-
Zelda::Request.should_receive(:get).with("
|
13
|
-
Zelda::Serie.
|
14
|
+
Zelda::Request.should_receive(:get).with("current_series").and_return({ 'series' => [{'titel' => 'Titeuf'}] })
|
15
|
+
Zelda::Serie.current.first.should be_a(Zelda::Serie)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
describe "when retrieving a list of series" do
|
18
20
|
it "should call Zelda with the correct url" do
|
19
|
-
Zelda::Request.should_receive(:get).with("series").and_return({ 'series' => ['
|
21
|
+
Zelda::Request.should_receive(:get).with("series").and_return({ 'series' => [{'titel' => 'Titeuf'}] })
|
20
22
|
Zelda::Serie.stub!(:new).and_return 'serie'
|
21
23
|
Zelda::Serie.all.should == ['serie']
|
22
24
|
end
|
23
25
|
|
24
26
|
it "should return an array of series" do
|
25
|
-
Zelda::Request.should_receive(:get).with("series").and_return({ 'series' => ['
|
27
|
+
Zelda::Request.should_receive(:get).with("series").and_return({ 'series' => [{'titel' => 'Titeuf'}] })
|
26
28
|
Zelda::Serie.all.first.should be_a(Zelda::Serie)
|
27
29
|
end
|
28
30
|
end
|
data/spec/zelda/zender_spec.rb
CHANGED