bartzon-zelda 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ pkg
2
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -6,7 +6,6 @@ require 'httparty'
6
6
  require 'zelda/base'
7
7
  require 'zelda/object'
8
8
  require 'zelda/request'
9
- require 'zelda/collection'
10
9
  require 'zelda/zender'
11
10
  require 'zelda/serie'
12
11
 
@@ -5,8 +5,8 @@ module Zelda
5
5
  Zelda::Request.get(url)
6
6
  end
7
7
 
8
- def find(code)
9
- new Zelda::Request.get(url(code))
8
+ def find(id)
9
+ new Zelda::Request.get(url(id))
10
10
  end
11
11
  end
12
12
 
@@ -12,6 +12,14 @@ class Zelda::Serie < Zelda::Object
12
12
  end
13
13
 
14
14
  def afleveringen
15
- @afleveringen ||= Zelda::Collection.create(:prefix => "series/#{serieid}/afleveringen")
15
+ @afleveringen ||= Zelda::Request.get("series/#{serieid}/afleveringen")["afleveringen"]
16
+ end
17
+
18
+ def upcoming_afleveringen
19
+ @upcoming_afleveringen ||= Zelda::Request.get("series/#{serieid}/afleveringen/upcoming")["afleveringen"]
20
+ end
21
+
22
+ def past_afleveringen
23
+ @past_afleveringen ||= Zelda::Request.get("series/#{serieid}/afleveringen/past")["afleveringen"]
16
24
  end
17
25
  end
@@ -10,8 +10,4 @@ class Zelda::Zender < Zelda::Object
10
10
  def code
11
11
  @attrs["zender"]["code"]
12
12
  end
13
-
14
- def series
15
- @series ||= Zelda::Collection.create(:prefix => self.class.url(code) + "/series")
16
- end
17
13
  end
@@ -27,18 +27,22 @@ describe Zelda::Serie do
27
27
  find_serie.should be_a(Zelda::Serie)
28
28
  end
29
29
 
30
- it "should return the correct name" do
31
- find_serie.name.should == "3 op reis"
30
+ it "should send the correct request when asked for afleveringen" do
31
+ serie = find_serie
32
+ Zelda::Request.should_receive(:get).with("series/POW_00243538/afleveringen").and_return("afleveringen" => ["foo"])
33
+ serie.afleveringen.should == ["foo"]
32
34
  end
33
-
34
- it "should raise the correct error for an undefined attribute" do
35
- lambda { find_serie.foo }.should raise_error(NoMethodError)
35
+
36
+ it "should send the correct request when asked for upcoming afleveringen" do
37
+ serie = find_serie
38
+ Zelda::Request.should_receive(:get).with("series/POW_00243538/afleveringen/upcoming").and_return("afleveringen" => ["foo"])
39
+ serie.upcoming_afleveringen.should == ["foo"]
36
40
  end
37
-
38
- it "should create the correct collection when asked for afleveringen" do
41
+
42
+ it "should send the correct request when asked for past afleveringen" do
39
43
  serie = find_serie
40
- Zelda::Collection.should_receive(:create).with({:prefix => "series/POW_00243538/afleveringen"})
41
- serie.afleveringen
44
+ Zelda::Request.should_receive(:get).with("series/POW_00243538/afleveringen/past").and_return("afleveringen" => ["foo"])
45
+ serie.past_afleveringen.should == ["foo"]
42
46
  end
43
47
  end
44
48
  end
@@ -34,11 +34,5 @@ describe Zelda::Zender do
34
34
  it "should raise the correct error for an undefined attribute" do
35
35
  lambda { find_zender.foo }.should raise_error(NoMethodError)
36
36
  end
37
-
38
- it "should create the correct collection when asked for series" do
39
- zender = find_zender
40
- Zelda::Collection.should_receive(:create).with({:prefix => "zenders/NL1/series"})
41
- zender.series
42
- end
43
37
  end
44
38
  end
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{zelda}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bart Zonneveld"]
12
+ s.date = %q{2009-08-13}
13
+ s.description = %q{ }
14
+ s.email = %q{loop@superinfinite.com}
15
+ s.extra_rdoc_files = [
16
+ "History.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "History.txt",
22
+ "Manifest.txt",
23
+ "PostInstall.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/zelda.rb",
28
+ "lib/zelda/base.rb",
29
+ "lib/zelda/object.rb",
30
+ "lib/zelda/request.rb",
31
+ "lib/zelda/serie.rb",
32
+ "lib/zelda/zender.rb",
33
+ "script/console",
34
+ "script/destroy",
35
+ "script/generate",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb",
38
+ "spec/zelda/base_spec.rb",
39
+ "spec/zelda/request_spec.rb",
40
+ "spec/zelda/serie_spec.rb",
41
+ "spec/zelda/zender_spec.rb",
42
+ "tasks/rspec.rake",
43
+ "zelda.gemspec"
44
+ ]
45
+ s.homepage = %q{http://github.com/bartzon/zelda}
46
+ s.rdoc_options = ["--charset=UTF-8"]
47
+ s.require_paths = ["lib"]
48
+ s.rubyforge_project = %q{zelda}
49
+ s.rubygems_version = %q{1.3.5}
50
+ s.summary = %q{ }
51
+ s.test_files = [
52
+ "spec/spec_helper.rb",
53
+ "spec/zelda/base_spec.rb",
54
+ "spec/zelda/request_spec.rb",
55
+ "spec/zelda/serie_spec.rb",
56
+ "spec/zelda/zender_spec.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<httparty>, [">= 0.4.4"])
65
+ else
66
+ s.add_dependency(%q<httparty>, [">= 0.4.4"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<httparty>, [">= 0.4.4"])
70
+ end
71
+ end
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.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart Zonneveld
@@ -32,6 +32,7 @@ extra_rdoc_files:
32
32
  - History.txt
33
33
  - README.rdoc
34
34
  files:
35
+ - .gitignore
35
36
  - History.txt
36
37
  - Manifest.txt
37
38
  - PostInstall.txt
@@ -40,7 +41,6 @@ files:
40
41
  - VERSION
41
42
  - lib/zelda.rb
42
43
  - lib/zelda/base.rb
43
- - lib/zelda/collection.rb
44
44
  - lib/zelda/object.rb
45
45
  - lib/zelda/request.rb
46
46
  - lib/zelda/serie.rb
@@ -51,11 +51,11 @@ files:
51
51
  - spec/spec.opts
52
52
  - spec/spec_helper.rb
53
53
  - spec/zelda/base_spec.rb
54
- - spec/zelda/collection_spec.rb
55
54
  - spec/zelda/request_spec.rb
56
55
  - spec/zelda/serie_spec.rb
57
56
  - spec/zelda/zender_spec.rb
58
57
  - tasks/rspec.rake
58
+ - zelda.gemspec
59
59
  has_rdoc: false
60
60
  homepage: http://github.com/bartzon/zelda
61
61
  licenses:
@@ -86,7 +86,6 @@ summary: ""
86
86
  test_files:
87
87
  - spec/spec_helper.rb
88
88
  - spec/zelda/base_spec.rb
89
- - spec/zelda/collection_spec.rb
90
89
  - spec/zelda/request_spec.rb
91
90
  - spec/zelda/serie_spec.rb
92
91
  - spec/zelda/zender_spec.rb
@@ -1,27 +0,0 @@
1
- module Zelda
2
- class Collection
3
- include Enumerable
4
-
5
- def self.create(attrs={})
6
- new(attrs)
7
- end
8
-
9
- def initialize(attrs={})
10
- raise ZeldaCollectionError.new("No prefix specified") unless attrs[:prefix]
11
- @attrs = attrs
12
- end
13
-
14
- def all
15
- fetch
16
- end
17
-
18
- def each
19
- fetch.each { |result| yield result }
20
- end
21
-
22
- private
23
- def fetch
24
- @results ||= Zelda::Request.get("#{@attrs[:prefix]}")
25
- end
26
- end
27
- end
@@ -1,32 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Zelda::Collection do
4
- before(:each) do
5
- @collection = Zelda::Collection.new(:prefix => "foo")
6
- end
7
-
8
- it "should raise an error if a collection is created without a prefix" do
9
- lambda { Zelda::Collection.create }.should raise_error(Zelda::ZeldaCollectionError, "No prefix specified")
10
- end
11
-
12
- it "should create a collection" do
13
- Zelda::Collection.create(:prefix => "foo").should be_a(Zelda::Collection)
14
- end
15
-
16
- it "should call Zelda when asked for all results" do
17
- Zelda::Request.should_receive(:get).with('foo')
18
- @collection.all
19
- end
20
-
21
- it "should be able to iterate over series correctly" do
22
- Zelda::Request.should_receive(:get).with("foo").and_return [1,2,3,4]
23
- results = []
24
- @collection.each { |serie| results << serie }
25
- results.should == [1,2,3,4]
26
- end
27
-
28
- it "should call Zelda with the correct url" do
29
- Zelda::Request.should_receive(:get).with("foo")
30
- @collection.all
31
- end
32
- end