em-sofa 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/.yardopts +6 -0
- data/LICENSE +20 -0
- data/README.md +110 -0
- data/Rakefile +75 -0
- data/doc/Em-sofa/Mapping.html +168 -0
- data/doc/Em-sofa/Mapping/ClassMethods.html +314 -0
- data/doc/Em-sofa/Mapping/InstanceMethods.html +358 -0
- data/doc/Em-sofa/TVRage.html +85 -0
- data/doc/Em-sofa/TVRage/Episode.html +358 -0
- data/doc/Em-sofa/TVRage/Schedule.html +207 -0
- data/doc/Em-sofa/TVRage/Season.html +236 -0
- data/doc/Em-sofa/TVRage/Show.html +904 -0
- data/doc/Em-sofa/TVRage/Show/ShowNotFound.html +92 -0
- data/doc/Em-sofa/Version.html +100 -0
- data/doc/Sofa.html +85 -0
- data/doc/_index.html +233 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +50 -0
- data/doc/css/style.css +277 -0
- data/doc/file.README.html +150 -0
- data/doc/file_list.html +38 -0
- data/doc/index.html +150 -0
- data/doc/js/app.js +138 -0
- data/doc/js/full_list.js +117 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +195 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/em-sofa.rb +8 -0
- data/lib/em-sofa/mapping.rb +108 -0
- data/lib/em-sofa/tvrage.rb +14 -0
- data/lib/em-sofa/tvrage/episode.rb +41 -0
- data/lib/em-sofa/tvrage/schedule.rb +28 -0
- data/lib/em-sofa/tvrage/season.rb +38 -0
- data/lib/em-sofa/tvrage/show.rb +193 -0
- data/lib/em-sofa/version.rb +10 -0
- data/spec/fixtures/tvrage/cases/castle.xml +228 -0
- data/spec/fixtures/tvrage/cases/community.xml +109 -0
- data/spec/fixtures/tvrage/cases/live_with_regis_and_kelly.xml +56237 -0
- data/spec/fixtures/tvrage/episode_list.xml +1183 -0
- data/spec/fixtures/tvrage/episode_list_one_season.xml +17 -0
- data/spec/fixtures/tvrage/episode_list_two_episodes.xml +25 -0
- data/spec/fixtures/tvrage/full_schedule.xml +4731 -0
- data/spec/fixtures/tvrage/full_show_info.xml +1291 -0
- data/spec/fixtures/tvrage/quickinfo.html +17 -0
- data/spec/fixtures/tvrage/quickinfo_missing.html +1 -0
- data/spec/fixtures/tvrage/search.xml +151 -0
- data/spec/fixtures/tvrage/show_info.xml +42 -0
- data/spec/fixtures/tvrage/show_info_blank.xml +3 -0
- data/spec/fixtures/tvrage/single_episode.xml +8 -0
- data/spec/sofa/mapping_spec.rb +82 -0
- data/spec/sofa/tvrage/cases_spec.rb +29 -0
- data/spec/sofa/tvrage/episode_spec.rb +45 -0
- data/spec/sofa/tvrage/schedule_spec.rb +17 -0
- data/spec/sofa/tvrage/season_spec.rb +61 -0
- data/spec/sofa/tvrage/show_spec.rb +201 -0
- data/spec/sofa/version_spec.rb +11 -0
- data/spec/sofa_spec.rb +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +20 -0
- metadata +165 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
require './spec_helper'
|
2
|
+
|
3
|
+
module EventMachine::Sofa::TVRage
|
4
|
+
|
5
|
+
EM.describe EventMachine::Sofa::TVRage do
|
6
|
+
describe "greedy" do
|
7
|
+
before do
|
8
|
+
@id = "2930"
|
9
|
+
@show_xml = File.read("spec/fixtures/tvrage/show_info.xml")
|
10
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/showinfo.php?sid=#{@id}", :body => @show_xml)
|
11
|
+
@xml = File.read("spec/fixtures/tvrage/full_show_info.xml")
|
12
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/full_show_info.php?sid=#{@id}", :body => @xml)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "use full show info" do
|
16
|
+
Show.full_info @id do |full_info|
|
17
|
+
full_info.should.be {}
|
18
|
+
done
|
19
|
+
end
|
20
|
+
#Show.new(@id, :greedy => true)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "use full show info for season list" do
|
24
|
+
Show.new(@id) do |show|
|
25
|
+
#Show.expects(:episode_list).with(@id).never
|
26
|
+
Show.new(@id, :greedy => true) do |full_show|
|
27
|
+
full_show.season_list do |full_show_season_list|
|
28
|
+
show.season_list do |show_season_list|
|
29
|
+
full_show_season_list.should.be show_season_list
|
30
|
+
done
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
=begin
|
40
|
+
describe Show do
|
41
|
+
before do
|
42
|
+
@id = "2930"
|
43
|
+
@show_xml = File.read("spec/fixtures/tvrage/show_info.xml")
|
44
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/showinfo.php?sid=#{@id}", :body => @show_xml)
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "with id" do
|
48
|
+
subject { Show.new(@id) }
|
49
|
+
|
50
|
+
{ :show_id => "2930",
|
51
|
+
:show_link => "http://tvrage.com/Buffy_The_Vampire_Slayer",
|
52
|
+
:started => "1997",
|
53
|
+
:network => "UPN",
|
54
|
+
:air_time => "20:00",
|
55
|
+
:time_zone => "GMT-5 -DST",
|
56
|
+
:run_time => "60",
|
57
|
+
:origin_country => "US",
|
58
|
+
:air_day => "Tuesday",
|
59
|
+
:ended => "May/20/2003",
|
60
|
+
:classification => "Scripted",
|
61
|
+
:seasons => "7",
|
62
|
+
:start_date => "Mar/10/1997",
|
63
|
+
:status => "Canceled/Ended",
|
64
|
+
:genres => [
|
65
|
+
"Action",
|
66
|
+
"Adventure",
|
67
|
+
"Comedy",
|
68
|
+
"Drama",
|
69
|
+
"Mystery",
|
70
|
+
"Sci-Fi"
|
71
|
+
],
|
72
|
+
:name => "Buffy the Vampire Slayer",
|
73
|
+
:akas => [
|
74
|
+
"Buffy & vampyrerna",
|
75
|
+
"Buffy - Im Bann der Dämonen",
|
76
|
+
"Buffy - Vampyrenes skrekk",
|
77
|
+
"Buffy a vámpírok réme",
|
78
|
+
"Buffy Contre les Vampires",
|
79
|
+
"Buffy l'Ammazza Vampiri",
|
80
|
+
"Buffy postrach wampirów",
|
81
|
+
"Buffy, a Caça-Vampiros",
|
82
|
+
"Buffy, a Caçadora de Vampiros",
|
83
|
+
"Buffy, Cazavampiros",
|
84
|
+
"Buffy, ubojica vampira",
|
85
|
+
"Buffy, vampyyrintappaja",
|
86
|
+
"Vampiiritapja Buffy",
|
87
|
+
"Vampírubaninn Buffy"
|
88
|
+
]
|
89
|
+
}.each do |attr, value|
|
90
|
+
it "should get ##{attr}" do
|
91
|
+
subject.send(attr).should == value
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "with 1 season" do
|
96
|
+
before do
|
97
|
+
@episodes_xml = File.read("spec/fixtures/tvrage/episode_list_one_season.xml")
|
98
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/episode_list.php?sid=#{@id}", :body => @episodes_xml)
|
99
|
+
@info = Crack::XML.parse(@episodes_xml)
|
100
|
+
@seasons = [Season.new(@info["Show"]["Episodelist"]["Season"])]
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should get season_list" do
|
104
|
+
subject.season_list.should == @seasons
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should get episode_list" do
|
108
|
+
subject.episode_list.should == @seasons.map { |season| season.episodes }.flatten
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "with multiple seasons" do
|
113
|
+
before do
|
114
|
+
@episodes_xml = File.read("spec/fixtures/tvrage/episode_list.xml")
|
115
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/episode_list.php?sid=#{@id}", :body => @episodes_xml)
|
116
|
+
@info = Crack::XML.parse(@episodes_xml)
|
117
|
+
@seasons = []
|
118
|
+
@info["Show"]["Episodelist"]["Season"].each do |season|
|
119
|
+
@seasons << Season.new(season)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should get season_list" do
|
124
|
+
subject.season_list.should == @seasons
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should get episode_list" do
|
128
|
+
subject.episode_list.should == @seasons.map { |season| season.episodes }.flatten
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "without id" do
|
134
|
+
it "should raise error" do
|
135
|
+
lambda {
|
136
|
+
Show.new(nil)
|
137
|
+
}.should raise_error(RuntimeError, "id is required")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should get full show info" do
|
142
|
+
@xml = File.read("spec/fixtures/tvrage/full_show_info.xml")
|
143
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/full_show_info.php?sid=#{@id}", :body => @xml)
|
144
|
+
|
145
|
+
Show.full_info(@id).should == Crack::XML.parse(@xml)["Show"]
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should get show by name" do
|
149
|
+
@html = File.read("spec/fixtures/tvrage/quickinfo.html")
|
150
|
+
@name = "The Colbert Report"
|
151
|
+
@id = "6715"
|
152
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/tools/quickinfo.php?show=#{URI.escape(@name)}", :body => @html)
|
153
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/showinfo.php?sid=#{@id}", :body => @show_xml)
|
154
|
+
|
155
|
+
Show.by_name(@name).should be_kind_of(Show)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should raise error when get show by missing name" do
|
159
|
+
@html = File.read("spec/fixtures/tvrage/quickinfo_missing.html")
|
160
|
+
@name = "The Colbert Report"
|
161
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/tools/quickinfo.php?show=#{URI.escape(@name)}", :body => @html)
|
162
|
+
|
163
|
+
lambda {
|
164
|
+
Show.by_name(@name)
|
165
|
+
}.should raise_error(Show::ShowNotFound)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should get show by name with options" do
|
169
|
+
@html = File.read("spec/fixtures/tvrage/quickinfo.html")
|
170
|
+
@name = "The Colbert Report"
|
171
|
+
@id = "6715"
|
172
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/tools/quickinfo.php?show=#{URI.escape(@name)}", :body => @html)
|
173
|
+
Show.expects(:new).with(@id, options = mock)
|
174
|
+
|
175
|
+
Show.by_name(@name, options)
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "greedy" do
|
179
|
+
before do
|
180
|
+
@xml = File.read("spec/fixtures/tvrage/full_show_info.xml")
|
181
|
+
FakeWeb.register_uri(:get, "http://services.tvrage.com/feeds/full_show_info.php?sid=#{@id}", :body => @xml)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should use full show info" do
|
185
|
+
Show.expects(:full_info).with(@id).returns({})
|
186
|
+
Show.new(@id, :greedy => true)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should use full show info for season list" do
|
190
|
+
Show.new(@id) do |show|
|
191
|
+
Show.expects(:episode_list).with(@id).never
|
192
|
+
Show.new(@id, :greedy => true) do |full_show|
|
193
|
+
full_show.season_list.should == show.season_list
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
=end
|
data/spec/sofa_spec.rb
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
#require 'eventmachine'
|
5
|
+
require 'bacon'
|
6
|
+
require './em-spec/bacon'
|
7
|
+
require './em-sofa'
|
8
|
+
#require 'mocha'
|
9
|
+
|
10
|
+
EM.spec_backend = EventMachine::Spec::Bacon
|
11
|
+
#require 'spec'
|
12
|
+
#require 'spec/autorun'
|
13
|
+
|
14
|
+
require 'fakeweb'
|
15
|
+
|
16
|
+
FakeWeb.allow_net_connect = false
|
17
|
+
|
18
|
+
#Spec::Runner.configure do |config|
|
19
|
+
# config.mock_with :mocha
|
20
|
+
#end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: em-sofa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- DeFirence
|
9
|
+
- Henry Hsu
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-05-03 00:00:00.000000000 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: em-http-request
|
18
|
+
requirement: &25095300 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *25095300
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: crack
|
29
|
+
requirement: &25095012 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *25095012
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: fakeweb
|
40
|
+
requirement: &25094724 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *25094724
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: mocha
|
51
|
+
requirement: &25094436 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *25094436
|
60
|
+
description: A simple EventMachine based Ruby library for the TVRage API.
|
61
|
+
email: defirence@defirence.za.net
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files:
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
files:
|
68
|
+
- .document
|
69
|
+
- .gitignore
|
70
|
+
- .yardopts
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- doc/Em-sofa/Mapping.html
|
75
|
+
- doc/Em-sofa/Mapping/ClassMethods.html
|
76
|
+
- doc/Em-sofa/Mapping/InstanceMethods.html
|
77
|
+
- doc/Em-sofa/TVRage.html
|
78
|
+
- doc/Em-sofa/TVRage/Episode.html
|
79
|
+
- doc/Em-sofa/TVRage/Schedule.html
|
80
|
+
- doc/Em-sofa/TVRage/Season.html
|
81
|
+
- doc/Em-sofa/TVRage/Show.html
|
82
|
+
- doc/Em-sofa/TVRage/Show/ShowNotFound.html
|
83
|
+
- doc/Em-sofa/Version.html
|
84
|
+
- doc/Sofa.html
|
85
|
+
- doc/_index.html
|
86
|
+
- doc/class_list.html
|
87
|
+
- doc/css/common.css
|
88
|
+
- doc/css/full_list.css
|
89
|
+
- doc/css/style.css
|
90
|
+
- doc/file.README.html
|
91
|
+
- doc/file_list.html
|
92
|
+
- doc/index.html
|
93
|
+
- doc/js/app.js
|
94
|
+
- doc/js/full_list.js
|
95
|
+
- doc/js/jquery.js
|
96
|
+
- doc/method_list.html
|
97
|
+
- doc/top-level-namespace.html
|
98
|
+
- lib/em-sofa.rb
|
99
|
+
- lib/em-sofa/mapping.rb
|
100
|
+
- lib/em-sofa/tvrage.rb
|
101
|
+
- lib/em-sofa/tvrage/episode.rb
|
102
|
+
- lib/em-sofa/tvrage/schedule.rb
|
103
|
+
- lib/em-sofa/tvrage/season.rb
|
104
|
+
- lib/em-sofa/tvrage/show.rb
|
105
|
+
- lib/em-sofa/version.rb
|
106
|
+
- spec/fixtures/tvrage/cases/castle.xml
|
107
|
+
- spec/fixtures/tvrage/cases/community.xml
|
108
|
+
- spec/fixtures/tvrage/cases/live_with_regis_and_kelly.xml
|
109
|
+
- spec/fixtures/tvrage/episode_list.xml
|
110
|
+
- spec/fixtures/tvrage/episode_list_one_season.xml
|
111
|
+
- spec/fixtures/tvrage/episode_list_two_episodes.xml
|
112
|
+
- spec/fixtures/tvrage/full_schedule.xml
|
113
|
+
- spec/fixtures/tvrage/full_show_info.xml
|
114
|
+
- spec/fixtures/tvrage/quickinfo.html
|
115
|
+
- spec/fixtures/tvrage/quickinfo_missing.html
|
116
|
+
- spec/fixtures/tvrage/search.xml
|
117
|
+
- spec/fixtures/tvrage/show_info.xml
|
118
|
+
- spec/fixtures/tvrage/show_info_blank.xml
|
119
|
+
- spec/fixtures/tvrage/single_episode.xml
|
120
|
+
- spec/sofa/mapping_spec.rb
|
121
|
+
- spec/sofa/tvrage/cases_spec.rb
|
122
|
+
- spec/sofa/tvrage/episode_spec.rb
|
123
|
+
- spec/sofa/tvrage/schedule_spec.rb
|
124
|
+
- spec/sofa/tvrage/season_spec.rb
|
125
|
+
- spec/sofa/tvrage/show_spec.rb
|
126
|
+
- spec/sofa/version_spec.rb
|
127
|
+
- spec/sofa_spec.rb
|
128
|
+
- spec/spec.opts
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
has_rdoc: true
|
131
|
+
homepage: http://github.com/DeFirence/em-sofa
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options:
|
135
|
+
- --charset=UTF-8
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.5.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: An EventMachine based Ruby library for the TVRage API.
|
156
|
+
test_files:
|
157
|
+
- spec/sofa/mapping_spec.rb
|
158
|
+
- spec/sofa/tvrage/cases_spec.rb
|
159
|
+
- spec/sofa/tvrage/episode_spec.rb
|
160
|
+
- spec/sofa/tvrage/schedule_spec.rb
|
161
|
+
- spec/sofa/tvrage/season_spec.rb
|
162
|
+
- spec/sofa/tvrage/show_spec.rb
|
163
|
+
- spec/sofa/version_spec.rb
|
164
|
+
- spec/sofa_spec.rb
|
165
|
+
- spec/spec_helper.rb
|