midna 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,38 @@
1
1
  = midna
2
2
 
3
- Ruby interface to the Midna API.
3
+ Ruby interface to the Midna API. See the [Rdoc]http://rdoc.info/projects/tilsammans/midna on how to use it.
4
4
 
5
5
  This gem chats with the Midna API so you don't have to. It will give you objects in the Midna namespace, which you can query like Active Record:
6
6
 
7
+ # all channels
7
8
  Midna::Channel.all
8
- Midna::Channel.find(code) # alphanumeric; like NL1
9
- Midna::Episode.find(id) # aflevering ID/episode ID from the omroep player
10
- Midna::Broadcast.all(code) # code is Channel code
9
+ # alphanumeric; like NL1
10
+ Midna::Channel.find(code)
11
+
12
+ # series ID from the omroep player
13
+ Midna::Series.find(id)
14
+ # searches the Solr index by series name
15
+ Midna::Series.search(query)
16
+
17
+ # aflevering/episode ID from the omroep player
18
+ Midna::Episode.find(id)
19
+ # all episodes for the given Series
20
+ Midna::Episode.series(id)
21
+ # all episodes for the given Series in the given time window
22
+ # start and end are integers (unixtimes)
23
+ Midna::Episode.series_window(id, start, end)
24
+ # all episodes for the given Series until the given time
25
+ # start is an integer (unixtime) and defaults to the current time
26
+ Midna::Episode.series_until(id, start)
27
+ # all episodes for the given Series since the given time
28
+ # start is an integer (unixtime) and defaults to the current time
29
+ Midna::Episode.series_since(id, start)
30
+
31
+ # code is Channel code
32
+ Midna::Broadcast.channel(code)
33
+ # all broadcasts for the given Channel in the given time window
34
+ # start and end are integers (unixtimes)
35
+ Midna::Broadcast.channel_window(id, start, end)
11
36
 
12
37
  All of these methods will return hashes or arrays of hashes.
13
38
 
data/Rakefile CHANGED
@@ -10,8 +10,8 @@ begin
10
10
  gem.email = "joost@spacebabies.nl"
11
11
  gem.homepage = "http://github.com/tilsammans/midna"
12
12
  gem.authors = ["Joost Baaij"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency 'httparty'
13
+ gem.add_dependency "httparty", "~> 0.6.1"
14
+ gem.add_development_dependency "rspec", "~> 1.2"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.5.0
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  require 'midna/channel'
10
10
  require 'midna/episode'
11
+ require 'midna/series'
11
12
  require 'midna/broadcast'
12
13
 
13
14
  class Midna
@@ -1,7 +1,14 @@
1
1
  class Midna
2
2
  class Broadcast
3
- def self.all(code)
3
+ # Return broadcasts for a Channel, based on the channel +code+.
4
+ def self.channel(code)
4
5
  Midna.get("/channels/#{code}/broadcasts.xml").to_hash["broadcasts"]
5
6
  end
7
+
8
+ # Return broadcasts for a Channel in a given time window.
9
+ # +starttime+ and +endtime+ are integers (unixtimes).
10
+ def self.channel_window(code, starttime, endtime)
11
+ Midna.get("/channels/#{code}/broadcasts.xml?start=#{starttime}&end=#{endtime}").to_hash["broadcasts"]
12
+ end
6
13
  end
7
14
  end
@@ -1,7 +1,39 @@
1
1
  class Midna
2
2
  class Episode
3
+ # Return one Episode based on its +id+.
3
4
  def self.find(id)
4
5
  Midna.get("/episodes/#{id}.xml").to_hash["episode"]
5
6
  end
7
+
8
+ # Return episodes for a Series, based on the series +id+.
9
+ def self.series(id)
10
+ Midna.get("/series/#{id}/episodes.xml").to_hash["episodes"]
11
+ end
12
+
13
+ # Return episodes for a Series in a given time window.
14
+ # +starttime+ and +endtime+ are integers (unixtimes).
15
+ def self.series_window(id, starttime, endtime)
16
+ Midna.get("/series/#{id}/episodes.xml?start=#{starttime}&end=#{endtime}").to_hash["episodes"]
17
+ end
18
+
19
+ # Return episodes for a Series until a certain time.
20
+ # +starttime+ is an integer (unixtime) and defaults to the current time.
21
+ def self.series_until(id, starttime=nil)
22
+ if starttime.nil?
23
+ Midna.get("/series/#{id}/episodes/until.xml").to_hash["episodes"]
24
+ else
25
+ Midna.get("/series/#{id}/episodes/until.xml?start=#{starttime}").to_hash["episodes"]
26
+ end
27
+ end
28
+
29
+ # Return episodes for a Series since a certain time.
30
+ # +starttime+ is an integer (unixtime) and defaults to the current time.
31
+ def self.series_since(id, starttime=nil)
32
+ if starttime.nil?
33
+ Midna.get("/series/#{id}/episodes/since.xml").to_hash["episodes"]
34
+ else
35
+ Midna.get("/series/#{id}/episodes/since.xml?start=#{starttime}").to_hash["episodes"]
36
+ end
37
+ end
6
38
  end
7
39
  end
@@ -0,0 +1,11 @@
1
+ class Midna
2
+ class Series
3
+ def self.find(id)
4
+ Midna.get("/series/#{id}.xml").to_hash["series"]
5
+ end
6
+
7
+ def self.search(query)
8
+ Midna.get("/series/search.xml?query=#{query}").to_hash["nebo_series"]
9
+ end
10
+ end
11
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{midna}
8
- s.version = "0.3.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joost Baaij"]
12
- s.date = %q{2010-08-06}
12
+ s.date = %q{2010-09-22}
13
13
  s.description = %q{This gem chats with the Midna API so you don’t have to. It will give you objects in the Midna namespace, which you can query like Active Record. All of these methods will return hashes or arrays of hashes.}
14
14
  s.email = %q{joost@spacebabies.nl}
15
15
  s.extra_rdoc_files = [
@@ -27,10 +27,12 @@ Gem::Specification.new do |s|
27
27
  "lib/midna/broadcast.rb",
28
28
  "lib/midna/channel.rb",
29
29
  "lib/midna/episode.rb",
30
+ "lib/midna/series.rb",
30
31
  "midna.gemspec",
31
32
  "spec/midna/broadcast_spec.rb",
32
33
  "spec/midna/channel_spec.rb",
33
34
  "spec/midna/episode_spec.rb",
35
+ "spec/midna/series_spec.rb",
34
36
  "spec/midna_spec.rb",
35
37
  "spec/spec.opts",
36
38
  "spec/spec_helper.rb",
@@ -45,6 +47,7 @@ Gem::Specification.new do |s|
45
47
  "spec/midna/broadcast_spec.rb",
46
48
  "spec/midna/channel_spec.rb",
47
49
  "spec/midna/episode_spec.rb",
50
+ "spec/midna/series_spec.rb",
48
51
  "spec/midna_spec.rb",
49
52
  "spec/spec_helper.rb",
50
53
  "spec/support/midna.rb"
@@ -55,15 +58,15 @@ Gem::Specification.new do |s|
55
58
  s.specification_version = 3
56
59
 
57
60
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
59
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
61
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
62
+ s.add_development_dependency(%q<rspec>, ["~> 1.2"])
60
63
  else
61
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
62
- s.add_dependency(%q<httparty>, [">= 0"])
64
+ s.add_dependency(%q<httparty>, ["~> 0.6.1"])
65
+ s.add_dependency(%q<rspec>, ["~> 1.2"])
63
66
  end
64
67
  else
65
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
- s.add_dependency(%q<httparty>, [">= 0"])
68
+ s.add_dependency(%q<httparty>, ["~> 0.6.1"])
69
+ s.add_dependency(%q<rspec>, ["~> 1.2"])
67
70
  end
68
71
  end
69
72
 
@@ -1,14 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Midna::Broadcast do
4
- its(:class) { should respond_to(:all) }
4
+ its(:class) { should respond_to(:channel) }
5
+ its(:class) { should respond_to(:channel_window) }
5
6
 
6
- describe 'all' do
7
+ describe 'channel' do
7
8
  it "should get /channels/NL1/broadcasts.xml" do
8
9
  hash = stub
9
- Midna.should_receive(:get).with("/channels/NL1/broadcasts.xml").and_return(all = stub)
10
- all.stub!(:to_hash).and_return({"broadcasts" => hash})
11
- Midna::Broadcast.all('NL1').should equal(hash)
10
+ Midna.should_receive(:get).with("/channels/NL1/broadcasts.xml").and_return(channel = stub)
11
+ channel.stub!(:to_hash).and_return({"broadcasts" => hash})
12
+ Midna::Broadcast.channel('NL1').should equal(hash)
12
13
  end
13
14
  end
15
+
16
+ describe 'channel_window' do
17
+ it "should get /channels/NL1/broadcasts.xml?start=123&end=456" do
18
+ hash = stub
19
+ Midna.should_receive(:get).with("/channels/NL1/broadcasts.xml?start=123&end=456").and_return(channels = stub)
20
+ channels.stub!(:to_hash).and_return({"broadcasts" => hash})
21
+ Midna::Broadcast.channel_window('NL1', 123, 456).should equal(hash)
22
+ end
23
+ end
24
+
14
25
  end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Midna::Episode do
4
4
  its(:class) { should respond_to(:find) }
5
+ its(:class) { should respond_to(:series) }
6
+ its(:class) { should respond_to(:series_window) }
5
7
 
6
8
  describe 'find' do
7
9
  it "should get /episodes/ID.xml" do
@@ -12,4 +14,62 @@ describe Midna::Episode do
12
14
  end
13
15
  end
14
16
 
17
+ describe 'series' do
18
+ it "should get /series/ID/episodes.xml" do
19
+ hash = stub
20
+ Midna.should_receive(:get).with("/series/400/episodes.xml").and_return(episodes = stub)
21
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
22
+ Midna::Episode.series('400').should equal(hash)
23
+ end
24
+ end
25
+
26
+ describe 'series_window' do
27
+ it "should get /series/ID/episodes?start=123&end=456.xml" do
28
+ hash = stub
29
+ Midna.should_receive(:get).with("/series/400/episodes.xml?start=123&end=456").and_return(episodes = stub)
30
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
31
+ Midna::Episode.series_window('400', 123, 456).should equal(hash)
32
+ end
33
+ end
34
+
35
+ describe 'series_until' do
36
+ describe 'without time' do
37
+ it "should get /series/ID/episodes/until.xml" do
38
+ hash = stub
39
+ Midna.should_receive(:get).with("/series/400/episodes/until.xml").and_return(episodes = stub)
40
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
41
+ Midna::Episode.series_until('400').should equal(hash)
42
+ end
43
+ end
44
+
45
+ describe 'with time' do
46
+ it "should get /series/ID/episodes/until.xml" do
47
+ hash = stub
48
+ Midna.should_receive(:get).with("/series/400/episodes/until.xml?start=123").and_return(episodes = stub)
49
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
50
+ Midna::Episode.series_until('400', 123).should equal(hash)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe 'series_since' do
56
+ describe 'without time' do
57
+ it "should get /series/ID/episodes/since.xml" do
58
+ hash = stub
59
+ Midna.should_receive(:get).with("/series/400/episodes/since.xml").and_return(episodes = stub)
60
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
61
+ Midna::Episode.series_since('400').should equal(hash)
62
+ end
63
+ end
64
+
65
+ describe 'with time' do
66
+ it "should get /series/ID/episodes/since.xml" do
67
+ hash = stub
68
+ Midna.should_receive(:get).with("/series/400/episodes/since.xml?start=123").and_return(episodes = stub)
69
+ episodes.stub!(:to_hash).and_return({"episodes" => hash})
70
+ Midna::Episode.series_since('400', 123).should equal(hash)
71
+ end
72
+ end
73
+ end
74
+
15
75
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Midna::Series do
4
+ its(:class) { should respond_to(:find) }
5
+ its(:class) { should respond_to(:search) }
6
+
7
+ describe 'find' do
8
+ it "should get /series/ID.xml" do
9
+ hash = stub
10
+ Midna.should_receive(:get).with("/series/1200.xml").and_return(series = stub)
11
+ series.stub!(:to_hash).and_return({"series" => hash})
12
+ Midna::Series.find(1200).should equal(hash)
13
+ end
14
+ end
15
+
16
+ describe 'search' do
17
+ it "should get /series/search.xml?query=QUERY" do
18
+ hash = stub
19
+ Midna.should_receive(:get).with("/series/search.xml?query=sesam").and_return(series = stub)
20
+ series.stub!(:to_hash).and_return({"nebo_series" => hash})
21
+ Midna::Series.search('sesam').should equal(hash)
22
+ end
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midna
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 5
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joost Baaij
@@ -15,38 +15,39 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 +02:00
18
+ date: 2010-09-22 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: httparty
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 13
29
+ hash: 5
30
30
  segments:
31
+ - 0
32
+ - 6
31
33
  - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
35
- type: :development
34
+ version: 0.6.1
35
+ type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: httparty
38
+ name: rspec
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 11
46
46
  segments:
47
- - 0
48
- version: "0"
49
- type: :runtime
47
+ - 1
48
+ - 2
49
+ version: "1.2"
50
+ type: :development
50
51
  version_requirements: *id002
51
52
  description: "This gem chats with the Midna API so you don\xE2\x80\x99t have to. It will give you objects in the Midna namespace, which you can query like Active Record. All of these methods will return hashes or arrays of hashes."
52
53
  email: joost@spacebabies.nl
@@ -68,10 +69,12 @@ files:
68
69
  - lib/midna/broadcast.rb
69
70
  - lib/midna/channel.rb
70
71
  - lib/midna/episode.rb
72
+ - lib/midna/series.rb
71
73
  - midna.gemspec
72
74
  - spec/midna/broadcast_spec.rb
73
75
  - spec/midna/channel_spec.rb
74
76
  - spec/midna/episode_spec.rb
77
+ - spec/midna/series_spec.rb
75
78
  - spec/midna_spec.rb
76
79
  - spec/spec.opts
77
80
  - spec/spec_helper.rb
@@ -114,6 +117,7 @@ test_files:
114
117
  - spec/midna/broadcast_spec.rb
115
118
  - spec/midna/channel_spec.rb
116
119
  - spec/midna/episode_spec.rb
120
+ - spec/midna/series_spec.rb
117
121
  - spec/midna_spec.rb
118
122
  - spec/spec_helper.rb
119
123
  - spec/support/midna.rb