royw-imdb 0.0.10 → 0.0.11
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.
- data/README +7 -2
- data/lib/imdb/imdb_movie.rb +8 -18
- metadata +2 -2
data/README
CHANGED
@@ -66,6 +66,11 @@ ImdbSearch searches that match on AKA title "Open Season" movies
|
|
66
66
|
- should find id tt0400717
|
67
67
|
- should have only one movie from 2006
|
68
68
|
|
69
|
+
ImdbSearch searches that match on AKA title "Meltdown" movies
|
70
|
+
- should have multiple movies
|
71
|
+
- should find id tt0114437
|
72
|
+
- should have only one movie from 1995
|
73
|
+
|
69
74
|
ImdbMovie Indiana Jones and the Last Crusade
|
70
75
|
- should query IMDB url
|
71
76
|
- should get the image
|
@@ -77,6 +82,6 @@ String unescape_html
|
|
77
82
|
String strip_tags
|
78
83
|
- should strip HTML tags
|
79
84
|
|
80
|
-
Finished in
|
85
|
+
Finished in 3.245587 seconds
|
81
86
|
|
82
|
-
|
87
|
+
59 examples, 0 failures
|
data/lib/imdb/imdb_movie.rb
CHANGED
@@ -6,18 +6,9 @@ class ImdbMovie
|
|
6
6
|
def initialize(id, title = nil)
|
7
7
|
@id = id
|
8
8
|
@url = "http://www.imdb.com/title/tt#{@id}/"
|
9
|
-
# @url = sprintf(ImdbMovie::url_format, @id.to_s)
|
10
9
|
@title = title
|
11
10
|
end
|
12
11
|
|
13
|
-
# this is intended to be stubed by rspec where it
|
14
|
-
# should return the path to the cached html file
|
15
|
-
# Note, the returned String should have one '%s'
|
16
|
-
# which will replaced by sprintf with @id.to_s
|
17
|
-
# def self.url_format
|
18
|
-
# 'http://www.imdb.com/title/tt%s/'
|
19
|
-
# end
|
20
|
-
|
21
12
|
# this is intended to be stubed by rspec where it
|
22
13
|
# should return true.
|
23
14
|
def self.use_html_cache
|
@@ -124,14 +115,6 @@ class ImdbMovie
|
|
124
115
|
document.search(".media_strip_thumb img").map { |img| img['src'] } rescue []
|
125
116
|
end
|
126
117
|
|
127
|
-
# def get_data
|
128
|
-
# update_title
|
129
|
-
# end
|
130
|
-
|
131
|
-
# def title2
|
132
|
-
# document.at("div#tn15title h1").innerHTML.split('<span>').first.unescape_html rescue nil
|
133
|
-
# end
|
134
|
-
|
135
118
|
# return the raw title
|
136
119
|
def raw_title
|
137
120
|
document.at("h1").innerText
|
@@ -157,12 +140,19 @@ class ImdbMovie
|
|
157
140
|
aka << el.to_s unless el.elem?
|
158
141
|
el = el.next
|
159
142
|
end
|
160
|
-
aka.collect!{|a| a
|
143
|
+
aka.collect!{|a| remove_parens(a).strip}
|
161
144
|
aka.uniq!
|
162
145
|
aka.compact!
|
163
146
|
aka.select{|a| !a.empty?}
|
164
147
|
end
|
165
148
|
|
149
|
+
def remove_parens(str)
|
150
|
+
while str =~ /\(.*\)/
|
151
|
+
str.gsub!(/\([^\)\(]*\)/, '')
|
152
|
+
end
|
153
|
+
str
|
154
|
+
end
|
155
|
+
|
166
156
|
# The MPAA rating, i.e. "PG-13"
|
167
157
|
def mpaa
|
168
158
|
document.search("//h5[text()^='MPAA']/..").text.gsub('MPAA:', '').strip rescue nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: royw-imdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Gil
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|