bartzon-zelda 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -11,6 +11,7 @@ end
11
11
 
12
12
  require 'zelda/request'
13
13
  require 'zelda/zender'
14
+ require 'zelda/omroep'
14
15
  require 'zelda/serie'
15
16
  require 'zelda/aflevering'
16
17
 
@@ -0,0 +1,33 @@
1
+ module Zelda
2
+ class Omroep
3
+ class << self
4
+ def find(id)
5
+ new Request.get("omroepen/#{id}")['omroep']
6
+ end
7
+
8
+ def all
9
+ Request.get("omroepen")
10
+ end
11
+ end
12
+
13
+ def initialize(attrs={})
14
+ @attrs = attrs
15
+ end
16
+
17
+ def id
18
+ @attrs['id']
19
+ end
20
+
21
+ def name
22
+ @attrs['name']
23
+ end
24
+
25
+ def series
26
+ objects = []
27
+ Zelda::Request.get("omroepen/#{id}/series")['series'].each do |attrs|
28
+ objects << Zelda::Serie.new(attrs)
29
+ end
30
+ objects
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,59 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Zelda::Omroep do
4
+ describe "when retrieving a list of omroepen" do
5
+ it "should call Zelda with the correct url" do
6
+ Zelda::Request.should_receive(:get).with("omroepen")
7
+ Zelda::Omroep.all
8
+ end
9
+ end
10
+
11
+ describe "when retrieving a specific omroep" do
12
+ before(:each) do
13
+ omroep_attrs = { "omroep" => {"id" => "1", "name" => "KRO"} }
14
+ Zelda::Request.stub!(:get).with("omroepen/1").and_return omroep_attrs
15
+ end
16
+
17
+ def find_omroep
18
+ Zelda::Omroep.find(1)
19
+ end
20
+
21
+ it "should call Zelda with the correct url" do
22
+ Zelda::Request.should_receive(:get).with("omroepen/1")
23
+ find_omroep
24
+ end
25
+
26
+ it "should return a new Omroep" do
27
+ find_omroep.should be_a(Zelda::Omroep)
28
+ end
29
+
30
+ it "should return the correct id" do
31
+ find_omroep.id.should == "1"
32
+ end
33
+
34
+ it "should return the correct name" do
35
+ find_omroep.name.should == "KRO"
36
+ end
37
+ end
38
+
39
+ describe "when retrieving the series for an omroep" do
40
+ before(:each) do
41
+ @omroep = Zelda::Omroep.new('id' => 1)
42
+
43
+ Zelda::Request.stub!(:get).and_return('series' => [{'foo' => 'bar'}])
44
+ end
45
+
46
+ def find_series
47
+ @omroep.series
48
+ end
49
+
50
+ it "should call Zelda with the correct url" do
51
+ Zelda::Request.should_receive(:get).with("omroepen/1/series")
52
+ find_series
53
+ end
54
+
55
+ it "should return an array of series" do
56
+ find_series.first.should be_a(Zelda::Serie)
57
+ end
58
+ end
59
+ end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{zelda}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bart Zonneveld"]
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "lib/zelda.rb",
28
28
  "lib/zelda/aflevering.rb",
29
+ "lib/zelda/omroep.rb",
29
30
  "lib/zelda/request.rb",
30
31
  "lib/zelda/serie.rb",
31
32
  "lib/zelda/zender.rb",
@@ -35,6 +36,7 @@ Gem::Specification.new do |s|
35
36
  "spec/spec.opts",
36
37
  "spec/spec_helper.rb",
37
38
  "spec/zelda/aflevering_spec.rb",
39
+ "spec/zelda/omroep_spec.rb",
38
40
  "spec/zelda/request_spec.rb",
39
41
  "spec/zelda/serie_spec.rb",
40
42
  "spec/zelda/zender_spec.rb",
@@ -51,6 +53,7 @@ Gem::Specification.new do |s|
51
53
  s.test_files = [
52
54
  "spec/spec_helper.rb",
53
55
  "spec/zelda/aflevering_spec.rb",
56
+ "spec/zelda/omroep_spec.rb",
54
57
  "spec/zelda/request_spec.rb",
55
58
  "spec/zelda/serie_spec.rb",
56
59
  "spec/zelda/zender_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bartzon-zelda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart Zonneveld
@@ -41,6 +41,7 @@ files:
41
41
  - VERSION
42
42
  - lib/zelda.rb
43
43
  - lib/zelda/aflevering.rb
44
+ - lib/zelda/omroep.rb
44
45
  - lib/zelda/request.rb
45
46
  - lib/zelda/serie.rb
46
47
  - lib/zelda/zender.rb
@@ -50,6 +51,7 @@ files:
50
51
  - spec/spec.opts
51
52
  - spec/spec_helper.rb
52
53
  - spec/zelda/aflevering_spec.rb
54
+ - spec/zelda/omroep_spec.rb
53
55
  - spec/zelda/request_spec.rb
54
56
  - spec/zelda/serie_spec.rb
55
57
  - spec/zelda/zender_spec.rb
@@ -58,6 +60,7 @@ files:
58
60
  - zelda.gemspec
59
61
  has_rdoc: false
60
62
  homepage: http://github.com/bartzon/zelda
63
+ licenses:
61
64
  post_install_message:
62
65
  rdoc_options:
63
66
  - --charset=UTF-8
@@ -78,13 +81,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
81
  requirements: []
79
82
 
80
83
  rubyforge_project: zelda
81
- rubygems_version: 1.2.0
84
+ rubygems_version: 1.3.5
82
85
  signing_key:
83
86
  specification_version: 3
84
87
  summary: ""
85
88
  test_files:
86
89
  - spec/spec_helper.rb
87
90
  - spec/zelda/aflevering_spec.rb
91
+ - spec/zelda/omroep_spec.rb
88
92
  - spec/zelda/request_spec.rb
89
93
  - spec/zelda/serie_spec.rb
90
94
  - spec/zelda/zender_spec.rb