memo_rage 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/memo_rage/parser/base.rb +1 -1
- data/lib/memo_rage/parser/entry.rb +3 -5
- data/lib/memo_rage/parser/episode_list.rb +21 -34
- data/lib/memo_rage/parser/show_info.rb +7 -13
- data/lib/memo_rage/parser/show_search.rb +8 -19
- data/lib/memo_rage/version.rb +1 -1
- data/lib/memo_rage.rb +4 -1
- data/memo_rage.gemspec +9 -6
- data/spec/memo_rage/parser/episode_list_spec.rb +1 -0
- data/spec/memo_rage/parser/show_info_spec.rb +9 -3
- data/spec/memo_rage/parser/show_search_spec.rb +6 -0
- data/spec/mock_xml/show_info_empty.xml +2 -17
- data/spec/mock_xml/show_info_incomplete.xml +20 -0
- data/spec/mock_xml/show_search_empty.xml +4 -0
- data/spec/spec_helper.rb +2 -2
- metadata +52 -28
@@ -6,14 +6,12 @@ module MemoRage
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def method_missing(sym, *args)
|
9
|
-
@entry.
|
9
|
+
@entry.at(sym.to_s).try(:text)
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_array(name)
|
13
|
-
return [] unless @entry.
|
14
|
-
|
15
|
-
text.text
|
16
|
-
end
|
13
|
+
return [] unless record = @entry.at(name.to_s)
|
14
|
+
record.elements.map(&:text)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -1,43 +1,30 @@
|
|
1
1
|
module MemoRage
|
2
2
|
module Parser
|
3
3
|
class EpisodeList < Base
|
4
|
-
def parse_content
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:num => episode.epnum,
|
23
|
-
:season => season.attributes["no"].to_i,
|
24
|
-
:season_num => episode.seasonnum,
|
25
|
-
:prod_num => episode.prodnum,
|
26
|
-
:airdate => episode.airdate,
|
27
|
-
:link => episode.link,
|
28
|
-
:title => episode.title,
|
29
|
-
:rating => episode.rating,
|
30
|
-
:image => episode.screencap
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
4
|
+
def parse_content
|
5
|
+
@episodes = []
|
6
|
+
doc = Nokogiri::XML(@content.body)
|
7
|
+
doc.xpath('//Show//Episodelist//Season//episode').each do |record|
|
8
|
+
season = record.parent.at("@no").text.to_i
|
9
|
+
episode = Entry.new(record)
|
10
|
+
@episodes << MemoRage::Episode.new(
|
11
|
+
:id => episode.link.match(/[0-9]+$/).to_a.first.to_i,
|
12
|
+
:num => episode.epnum,
|
13
|
+
:season => season,
|
14
|
+
:season_num => episode.seasonnum.try(:to_i),
|
15
|
+
:prod_num => episode.prodnum,
|
16
|
+
:airdate => episode.airdate,
|
17
|
+
:link => episode.link,
|
18
|
+
:title => episode.title,
|
19
|
+
:rating => episode.rating,
|
20
|
+
:image => episode.screencap
|
21
|
+
)
|
34
22
|
end
|
35
23
|
|
36
|
-
entry = MemoRage::Parser::Entry.new(entry)
|
37
24
|
MemoRage::Show.new(
|
38
|
-
:name =>
|
39
|
-
:seasons =>
|
40
|
-
:episodes => episodes
|
25
|
+
:name => doc.at('//Show//name').text,
|
26
|
+
:seasons => doc.at('//Show//totalseasons').text.to_i,
|
27
|
+
:episodes => @episodes
|
41
28
|
)
|
42
29
|
end
|
43
30
|
end
|
@@ -1,18 +1,13 @@
|
|
1
1
|
module MemoRage
|
2
2
|
module Parser
|
3
3
|
class ShowInfo < Base
|
4
|
-
def parse_content
|
5
|
-
doc =
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def parse_entry(entry)
|
14
|
-
entry = MemoRage::Parser::Entry.new(entry)
|
15
|
-
MemoRage::Show.new(
|
4
|
+
def parse_content
|
5
|
+
doc = Nokogiri::XML(@content.body)
|
6
|
+
result = doc.at("Showinfo")
|
7
|
+
return nil if result.blank? || result.text.blank?
|
8
|
+
|
9
|
+
entry = MemoRage::Parser::Entry.new(result)
|
10
|
+
show = MemoRage::Show.new(
|
16
11
|
:id => entry.showid.to_i,
|
17
12
|
:name => entry.showname,
|
18
13
|
:link => entry.showlink,
|
@@ -30,7 +25,6 @@ module MemoRage
|
|
30
25
|
:timezone => entry.timezone
|
31
26
|
)
|
32
27
|
end
|
33
|
-
|
34
28
|
end
|
35
29
|
end
|
36
30
|
end
|
@@ -1,26 +1,15 @@
|
|
1
1
|
module MemoRage
|
2
2
|
module Parser
|
3
3
|
class ShowSearch < Base
|
4
|
-
def parse_content
|
5
|
-
doc =
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
4
|
+
def parse_content
|
5
|
+
doc = Nokogiri::XML(@content.body)
|
6
|
+
doc.xpath("//Results//show").collect do |entry|
|
7
|
+
entry = MemoRage::Parser::Entry.new(entry)
|
8
|
+
MemoRage::Show.new(
|
9
|
+
:id => entry.showid.to_i,
|
10
|
+
:name => entry.name
|
11
|
+
)
|
13
12
|
end
|
14
|
-
|
15
|
-
shows
|
16
|
-
end
|
17
|
-
|
18
|
-
def parse_entry(entry)
|
19
|
-
entry = MemoRage::Parser::Entry.new(entry)
|
20
|
-
MemoRage::Show.new(
|
21
|
-
:id => entry.showid.to_i,
|
22
|
-
:name => entry.name
|
23
|
-
)
|
24
13
|
end
|
25
14
|
end
|
26
15
|
end
|
data/lib/memo_rage/version.rb
CHANGED
data/lib/memo_rage.rb
CHANGED
data/memo_rage.gemspec
CHANGED
@@ -17,10 +17,13 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
-
|
21
|
-
s.add_runtime_dependency "
|
22
|
-
s.
|
23
|
-
s.
|
24
|
-
|
25
|
-
s.add_development_dependency "
|
20
|
+
|
21
|
+
s.add_runtime_dependency "nokogiri", "~> 1.5"
|
22
|
+
s.add_runtime_dependency "httpclient", "~> 2.0"
|
23
|
+
s.add_runtime_dependency "activesupport", "~> 3.0"
|
24
|
+
|
25
|
+
s.add_development_dependency "pry"
|
26
|
+
s.add_development_dependency "rake"
|
27
|
+
s.add_development_dependency "rspec", "~> 2.0"
|
28
|
+
s.add_development_dependency "webmock", "~> 1.6"
|
26
29
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
2
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
4
3
|
|
5
4
|
describe MemoRage::Parser::ShowInfo do
|
@@ -26,11 +25,18 @@ describe MemoRage::Parser::ShowInfo do
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
it 'should handle
|
30
|
-
mock_api :get, 'showinfo', '
|
28
|
+
it 'should handle incomplete show info' do
|
29
|
+
mock_api :get, 'showinfo', 'show_info_incomplete', :params => client.params.merge(:sid => "22303") do
|
31
30
|
show = client.show_info("22303")
|
32
31
|
show.genres.should == []
|
33
32
|
end
|
34
33
|
end
|
34
|
+
|
35
|
+
it 'should handle empty show info' do
|
36
|
+
mock_api :get, 'showinfo', 'show_info_empty', :params => client.params.merge(:sid => "9999999") do
|
37
|
+
show = client.show_info("9999999")
|
38
|
+
show.should be_nil
|
39
|
+
end
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
@@ -10,4 +10,10 @@ describe MemoRage::Parser::ShowSearch do
|
|
10
10
|
show.name.should == "Buffy the Vampire Slayer"
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
it 'should handle empty result set' do
|
15
|
+
mock_api :get, 'search', 'show_search_empty', :params => client.params.merge(:show => "yolo") do
|
16
|
+
client.search("yolo").should be_empty
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
@@ -1,20 +1,5 @@
|
|
1
|
+
|
1
2
|
<?xml version="1.0" encoding="UTF-8" ?>
|
2
3
|
|
3
4
|
<Showinfo>
|
4
|
-
|
5
|
-
<showname>Alcatraz: The Whole Shocking Story</showname>
|
6
|
-
<showlink>http://www.tvrage.com/shows/id-22303</showlink>
|
7
|
-
<seasons>1</seasons>
|
8
|
-
<image>http://images.tvrage.com/shows/23/22303.jpg</image>
|
9
|
-
<started>1980</started>
|
10
|
-
<startdate>Nov/05/1980</startdate>
|
11
|
-
|
12
|
-
<ended>Nov/06/1980</ended>
|
13
|
-
<origin_country>US</origin_country>
|
14
|
-
<status>Canceled/Ended</status>
|
15
|
-
<classification>Mini-Series</classification>
|
16
|
-
<runtime>240</runtime>
|
17
|
-
<network country="US">NBC</network>
|
18
|
-
<airtime>12:00</airtime>
|
19
|
-
<timezone>GMT-5 +DST</timezone>
|
20
|
-
</Showinfo>
|
5
|
+
</Showinfo>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
|
3
|
+
<Showinfo>
|
4
|
+
<showid>22303</showid>
|
5
|
+
<showname>Alcatraz: The Whole Shocking Story</showname>
|
6
|
+
<showlink>http://www.tvrage.com/shows/id-22303</showlink>
|
7
|
+
<seasons>1</seasons>
|
8
|
+
<image>http://images.tvrage.com/shows/23/22303.jpg</image>
|
9
|
+
<started>1980</started>
|
10
|
+
<startdate>Nov/05/1980</startdate>
|
11
|
+
|
12
|
+
<ended>Nov/06/1980</ended>
|
13
|
+
<origin_country>US</origin_country>
|
14
|
+
<status>Canceled/Ended</status>
|
15
|
+
<classification>Mini-Series</classification>
|
16
|
+
<runtime>240</runtime>
|
17
|
+
<network country="US">NBC</network>
|
18
|
+
<airtime>12:00</airtime>
|
19
|
+
<timezone>GMT-5 +DST</timezone>
|
20
|
+
</Showinfo>
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
|
+
require 'pry'
|
4
5
|
require 'rspec'
|
5
|
-
require 'timecop'
|
6
6
|
require 'memo_rage'
|
7
7
|
require 'helpers/webmock_helper'
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.before(:each) do
|
11
|
-
|
11
|
+
# Do nothing
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memo_rage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,48 +10,64 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-06-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.5'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.5'
|
15
31
|
- !ruby/object:Gem::Dependency
|
16
32
|
name: httpclient
|
17
33
|
requirement: !ruby/object:Gem::Requirement
|
18
34
|
none: false
|
19
35
|
requirements:
|
20
|
-
- -
|
36
|
+
- - ~>
|
21
37
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.
|
38
|
+
version: '2.0'
|
23
39
|
type: :runtime
|
24
40
|
prerelease: false
|
25
41
|
version_requirements: !ruby/object:Gem::Requirement
|
26
42
|
none: false
|
27
43
|
requirements:
|
28
|
-
- -
|
44
|
+
- - ~>
|
29
45
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.
|
46
|
+
version: '2.0'
|
31
47
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
48
|
+
name: activesupport
|
33
49
|
requirement: !ruby/object:Gem::Requirement
|
34
50
|
none: false
|
35
51
|
requirements:
|
36
|
-
- -
|
52
|
+
- - ~>
|
37
53
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
54
|
+
version: '3.0'
|
39
55
|
type: :runtime
|
40
56
|
prerelease: false
|
41
57
|
version_requirements: !ruby/object:Gem::Requirement
|
42
58
|
none: false
|
43
59
|
requirements:
|
44
|
-
- -
|
60
|
+
- - ~>
|
45
61
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
62
|
+
version: '3.0'
|
47
63
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
64
|
+
name: pry
|
49
65
|
requirement: !ruby/object:Gem::Requirement
|
50
66
|
none: false
|
51
67
|
requirements:
|
52
68
|
- - ! '>='
|
53
69
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
70
|
+
version: '0'
|
55
71
|
type: :development
|
56
72
|
prerelease: false
|
57
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,15 +75,15 @@ dependencies:
|
|
59
75
|
requirements:
|
60
76
|
- - ! '>='
|
61
77
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0
|
78
|
+
version: '0'
|
63
79
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
80
|
+
name: rake
|
65
81
|
requirement: !ruby/object:Gem::Requirement
|
66
82
|
none: false
|
67
83
|
requirements:
|
68
84
|
- - ! '>='
|
69
85
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
86
|
+
version: '0'
|
71
87
|
type: :development
|
72
88
|
prerelease: false
|
73
89
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -75,39 +91,39 @@ dependencies:
|
|
75
91
|
requirements:
|
76
92
|
- - ! '>='
|
77
93
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
94
|
+
version: '0'
|
79
95
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
96
|
+
name: rspec
|
81
97
|
requirement: !ruby/object:Gem::Requirement
|
82
98
|
none: false
|
83
99
|
requirements:
|
84
|
-
- -
|
100
|
+
- - ~>
|
85
101
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
102
|
+
version: '2.0'
|
87
103
|
type: :development
|
88
104
|
prerelease: false
|
89
105
|
version_requirements: !ruby/object:Gem::Requirement
|
90
106
|
none: false
|
91
107
|
requirements:
|
92
|
-
- -
|
108
|
+
- - ~>
|
93
109
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
110
|
+
version: '2.0'
|
95
111
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
112
|
+
name: webmock
|
97
113
|
requirement: !ruby/object:Gem::Requirement
|
98
114
|
none: false
|
99
115
|
requirements:
|
100
|
-
- -
|
116
|
+
- - ~>
|
101
117
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
118
|
+
version: '1.6'
|
103
119
|
type: :development
|
104
120
|
prerelease: false
|
105
121
|
version_requirements: !ruby/object:Gem::Requirement
|
106
122
|
none: false
|
107
123
|
requirements:
|
108
|
-
- -
|
124
|
+
- - ~>
|
109
125
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
126
|
+
version: '1.6'
|
111
127
|
description: An object-oriented Ruby wrapper for the TVRage API http://services.tvrage.com/
|
112
128
|
email:
|
113
129
|
- aganov@gmail.com
|
@@ -144,7 +160,9 @@ files:
|
|
144
160
|
- spec/mock_xml/episode_list_empty.xml
|
145
161
|
- spec/mock_xml/show_info.xml
|
146
162
|
- spec/mock_xml/show_info_empty.xml
|
163
|
+
- spec/mock_xml/show_info_incomplete.xml
|
147
164
|
- spec/mock_xml/show_search.xml
|
165
|
+
- spec/mock_xml/show_search_empty.xml
|
148
166
|
- spec/spec_helper.rb
|
149
167
|
homepage: http://github.com/appsbakery/memo_rage
|
150
168
|
licenses: []
|
@@ -158,15 +176,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
176
|
- - ! '>='
|
159
177
|
- !ruby/object:Gem::Version
|
160
178
|
version: '0'
|
179
|
+
segments:
|
180
|
+
- 0
|
181
|
+
hash: -67969453
|
161
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
183
|
none: false
|
163
184
|
requirements:
|
164
185
|
- - ! '>='
|
165
186
|
- !ruby/object:Gem::Version
|
166
187
|
version: '0'
|
188
|
+
segments:
|
189
|
+
- 0
|
190
|
+
hash: -67969453
|
167
191
|
requirements: []
|
168
192
|
rubyforge_project: memo_rage
|
169
|
-
rubygems_version: 1.8.
|
193
|
+
rubygems_version: 1.8.24
|
170
194
|
signing_key:
|
171
195
|
specification_version: 3
|
172
196
|
summary: Ruby wrapper for the TVRage API
|