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