imdb 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/History.txt +4 -0
- data/README.rdoc +10 -8
- data/Rakefile +10 -2
- data/imdb.gemspec +4 -2
- data/lib/imdb/movie.rb +35 -29
- data/lib/imdb/movie_list.rb +9 -1
- data/lib/imdb/search.rb +3 -2
- data/lib/imdb/string_extensions.rb +6 -2
- data/lib/imdb/version.rb +1 -1
- data/spec/imdb/cli_spec.rb +1 -1
- data/spec/imdb/movie_spec.rb +47 -42
- data/spec/imdb/search_spec.rb +24 -1
- data/spec/imdb/top_250_spec.rb +1 -1
- metadata +78 -83
data/.gitignore
CHANGED
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
= imdb
|
2
2
|
|
3
|
-
|
3
|
+
Allows you to search and inspect movies from IMDB.com.
|
4
4
|
|
5
|
-
|
5
|
+
The code, issue tracker and wiki can be found at: http://github.com/ariejan/imdb
|
6
|
+
|
7
|
+
API documentation is available at http://ariejan.github.com/imdb/
|
6
8
|
|
7
9
|
== DESCRIPTION:
|
8
10
|
|
@@ -54,24 +56,24 @@ All required gems are installed automagically through RubyGems.
|
|
54
56
|
|
55
57
|
== DOCUMENTATION:
|
56
58
|
|
57
|
-
This README and generated RDoc documentation are available from http://
|
59
|
+
This README and generated RDoc documentation are available from http://ariejan.github.com/imdb/
|
58
60
|
|
59
61
|
== TESTING:
|
60
62
|
|
61
63
|
You'll need rspec and fakeweb installed to run the specs. Y
|
62
64
|
|
63
|
-
$
|
64
|
-
$ rake spec
|
65
|
+
$ bundle install
|
66
|
+
$ bundle exec rake spec
|
65
67
|
|
66
68
|
Although not recommended, you may run the specs against the live imdb.com
|
67
69
|
website. This will make a lot of calls to imdb.com, use it wisely.
|
68
70
|
|
69
|
-
$ LIVE_TEST=true rake spec
|
71
|
+
$ LIVE_TEST=true bundle exec rake spec
|
70
72
|
|
71
73
|
To update the packaged fixtures files with actual imdb.com samples, use the
|
72
74
|
fixtures:refresh rake task
|
73
75
|
|
74
|
-
$ rake fixtures:refresh
|
76
|
+
$ bundle exec rake fixtures:refresh
|
75
77
|
|
76
78
|
== LICENSE:
|
77
79
|
|
@@ -96,4 +98,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
96
98
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
97
99
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
98
100
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
99
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
101
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -19,9 +19,17 @@ task :default => :spec
|
|
19
19
|
|
20
20
|
require 'imdb/version'
|
21
21
|
require 'rdoc/task'
|
22
|
-
RDoc::Task.new do |rdoc|
|
22
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
23
23
|
rdoc.rdoc_dir = 'rdoc'
|
24
|
-
rdoc.title = "imdb #{Imdb::VERSION}"
|
24
|
+
rdoc.title = "imdb #{Imdb::VERSION} documentation"
|
25
25
|
rdoc.rdoc_files.include('README*')
|
26
26
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
rdoc.options << '--webcvs=http://github.com/ariejan/imdb/tree/master/'
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'gokdok'
|
31
|
+
Gokdok::Dokker.new do |gd|
|
32
|
+
gd.repo_url = "git@github.com:ariejan/imdb.git"
|
33
|
+
gd.doc_home = "rdoc"
|
34
|
+
gd.remote_path = "."
|
27
35
|
end
|
data/imdb.gemspec
CHANGED
@@ -19,9 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'hpricot', '
|
22
|
+
s.add_dependency 'hpricot', '~> 0.8.4'
|
23
23
|
|
24
|
-
s.add_development_dependency '
|
24
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
25
25
|
s.add_development_dependency 'rspec', '~> 1.3.2'
|
26
|
+
s.add_development_dependency 'gokdok'
|
27
|
+
s.add_development_dependency 'rdoc', '~> 3.11'
|
26
28
|
s.add_development_dependency 'fakeweb'
|
27
29
|
end
|
data/lib/imdb/movie.rb
CHANGED
@@ -1,37 +1,43 @@
|
|
1
1
|
module Imdb
|
2
|
-
|
2
|
+
|
3
3
|
# Represents a Movie on IMDB.com
|
4
4
|
class Movie
|
5
|
-
attr_accessor :id, :url, :title
|
6
|
-
|
5
|
+
attr_accessor :id, :url, :title, :also_known_as
|
6
|
+
|
7
7
|
# Initialize a new IMDB movie object with it's IMDB id (as a String)
|
8
8
|
#
|
9
9
|
# movie = Imdb::Movie.new("0095016")
|
10
10
|
#
|
11
11
|
# Imdb::Movie objects are lazy loading, meaning that no HTTP request
|
12
|
-
# will be performed when a new object is created. Only when you use an
|
12
|
+
# will be performed when a new object is created. Only when you use an
|
13
13
|
# accessor that needs the remote data, a HTTP request is made (once).
|
14
14
|
#
|
15
|
-
def initialize(imdb_id, title = nil)
|
15
|
+
def initialize(imdb_id, title = nil, also_known_as = [])
|
16
16
|
@id = imdb_id
|
17
17
|
@url = "http://akas.imdb.com/title/tt#{imdb_id}/combined"
|
18
18
|
@title = title.gsub(/"/, "") if title
|
19
|
+
@also_known_as = also_known_as
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
# Returns an array with cast members
|
22
23
|
def cast_members
|
23
24
|
document.search("table.cast td.nm a").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
def cast_member_ids
|
27
28
|
document.search("table.cast td.nm a").map {|l| l['href'].sub(%r{^/name/(.*)/}, '\1') }
|
28
29
|
end
|
29
|
-
|
30
|
+
|
30
31
|
# Returns the name of the director
|
31
32
|
def director
|
32
33
|
document.search("h5[text()^='Director'] ~ a").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
33
34
|
end
|
34
|
-
|
35
|
+
|
36
|
+
# Returns the url to the "Watch a trailer" page
|
37
|
+
def trailer_url
|
38
|
+
'http://imdb.com' + document.at("a[@href*=/video/screenplay/]")["href"] rescue nil
|
39
|
+
end
|
40
|
+
|
35
41
|
# Returns an array of genres (as strings)
|
36
42
|
def genres
|
37
43
|
document.search("h5[text()='Genre:'] ~ a[@href*=/Sections/Genres/']").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
@@ -41,22 +47,22 @@ module Imdb
|
|
41
47
|
def languages
|
42
48
|
document.search("h5[text()='Language:'] ~ a[@href*=/language/']").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
43
49
|
end
|
44
|
-
|
50
|
+
|
45
51
|
# Returns an array of countries as strings.
|
46
52
|
def countries
|
47
53
|
document.search("h5[text()='Country:'] ~ a[@href*=/country/']").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
48
54
|
end
|
49
|
-
|
55
|
+
|
50
56
|
# Returns the duration of the movie in minutes as an integer.
|
51
57
|
def length
|
52
58
|
document.search("//h5[text()='Runtime:']/..").innerHTML[/\d+ min/].to_i rescue nil
|
53
59
|
end
|
54
|
-
|
60
|
+
|
55
61
|
# Returns a string containing the plot.
|
56
62
|
def plot
|
57
63
|
sanitize_plot(document.search("h5[text()='Plot:'] ~ div").first.innerHTML) rescue nil
|
58
64
|
end
|
59
|
-
|
65
|
+
|
60
66
|
# Returns a string containing the URL to the movie poster.
|
61
67
|
def poster
|
62
68
|
src = document.at("a[@name='poster'] img")['src'] rescue nil
|
@@ -67,7 +73,7 @@ module Imdb
|
|
67
73
|
$1 + '.jpg'
|
68
74
|
end
|
69
75
|
end
|
70
|
-
|
76
|
+
|
71
77
|
# Returns a float containing the average user rating
|
72
78
|
def rating
|
73
79
|
document.at(".starbar-meta b").innerHTML.strip.imdb_unescape_html.split('/').first.to_f rescue nil
|
@@ -82,43 +88,43 @@ module Imdb
|
|
82
88
|
def tagline
|
83
89
|
document.search("h5[text()='Tagline:'] ~ div").first.innerHTML.gsub(/<.+>.+<\/.+>/, '').strip.imdb_unescape_html rescue nil
|
84
90
|
end
|
85
|
-
|
91
|
+
|
86
92
|
# Returns a string containing the mpaa rating and reason for rating
|
87
93
|
def mpaa_rating
|
88
94
|
document.search("h5[text()='MPAA:'] ~ div").first.innerHTML.strip.imdb_unescape_html rescue nil
|
89
95
|
end
|
90
|
-
|
96
|
+
|
91
97
|
# Returns a string containing the title
|
92
98
|
def title(force_refresh = false)
|
93
99
|
if @title && !force_refresh
|
94
100
|
@title
|
95
101
|
else
|
96
|
-
@title = document.at("h1").innerHTML.split('<span').first.strip.imdb_unescape_html rescue nil
|
102
|
+
@title = document.at("h1").innerHTML.split('<span').first.strip.imdb_unescape_html rescue nil
|
97
103
|
end
|
98
104
|
end
|
99
|
-
|
105
|
+
|
100
106
|
# Returns an integer containing the year (CCYY) the movie was released in.
|
101
107
|
def year
|
102
108
|
document.search('a[@href^="/year/"]').innerHTML.to_i
|
103
109
|
end
|
104
|
-
|
110
|
+
|
105
111
|
# Returns release date for the movie.
|
106
112
|
def release_date
|
107
113
|
sanitize_release_date(document.search('h5[text()*=Release Date]').first.next_sibling.innerHTML.to_s) rescue nil
|
108
114
|
end
|
109
115
|
|
110
116
|
private
|
111
|
-
|
117
|
+
|
112
118
|
# Returns a new Hpricot document for parsing.
|
113
119
|
def document
|
114
120
|
@document ||= Hpricot(Imdb::Movie.find_by_id(@id))
|
115
121
|
end
|
116
|
-
|
122
|
+
|
117
123
|
# Use HTTParty to fetch the raw HTML for this movie.
|
118
124
|
def self.find_by_id(imdb_id)
|
119
125
|
open("http://akas.imdb.com/title/tt#{imdb_id}/combined")
|
120
126
|
end
|
121
|
-
|
127
|
+
|
122
128
|
# Convenience method for search
|
123
129
|
def self.search(query)
|
124
130
|
Imdb::Search.new(query).movies
|
@@ -127,27 +133,27 @@ module Imdb
|
|
127
133
|
def self.top_250
|
128
134
|
Imdb::Top250.new.movies
|
129
135
|
end
|
130
|
-
|
136
|
+
|
131
137
|
def sanitize_plot(the_plot)
|
132
138
|
the_plot = the_plot.imdb_strip_tags
|
133
|
-
|
139
|
+
|
134
140
|
the_plot = the_plot.gsub(/add\ssummary|full\ssummary/i, "")
|
135
141
|
the_plot = the_plot.gsub(/add\ssynopsis|full\ssynopsis/i, "")
|
136
142
|
the_plot = the_plot.gsub(/ |»/i, "")
|
137
143
|
the_plot = the_plot.gsub(/see|more/i, "")
|
138
144
|
the_plot = the_plot.gsub(/\|/i, "")
|
139
|
-
|
145
|
+
|
140
146
|
the_plot = the_plot.strip.imdb_unescape_html
|
141
147
|
end
|
142
|
-
|
148
|
+
|
143
149
|
def sanitize_release_date(the_release_date)
|
144
150
|
the_release_date = the_release_date.gsub(/<a.*a>/,"")
|
145
151
|
the_release_date = the_release_date.gsub(/ |»/i, "")
|
146
152
|
the_release_date = the_release_date.gsub(/see|more/i, "")
|
147
|
-
|
153
|
+
|
148
154
|
the_release_date = the_release_date.strip.imdb_unescape_html
|
149
155
|
end
|
150
|
-
|
156
|
+
|
151
157
|
end # Movie
|
152
|
-
|
158
|
+
|
153
159
|
end # Imdb
|
data/lib/imdb/movie_list.rb
CHANGED
@@ -23,7 +23,15 @@ module Imdb
|
|
23
23
|
title = title.imdb_strip_tags.imdb_unescape_html
|
24
24
|
title.gsub!(/\s+\(\d\d\d\d\)$/, '')
|
25
25
|
|
26
|
-
[
|
26
|
+
alternative_titles = []
|
27
|
+
|
28
|
+
if title =~ /\saka\s/
|
29
|
+
titles = title.split(/\saka\s/)
|
30
|
+
title = titles.shift.strip.imdb_unescape_html
|
31
|
+
alternative_titles = titles.map { |t| t.strip.imdb_strip_tags.imdb_unescape_html }
|
32
|
+
end
|
33
|
+
|
34
|
+
[id, title, alternative_titles]
|
27
35
|
end.uniq.map do |values|
|
28
36
|
Imdb::Movie.new(*values)
|
29
37
|
end
|
data/lib/imdb/search.rb
CHANGED
@@ -31,8 +31,9 @@ module Imdb
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def parse_movie
|
34
|
-
id
|
35
|
-
title
|
34
|
+
id = document.at("head/link[@rel='canonical']")['href'][/\d+/]
|
35
|
+
title = document.at("h1").innerHTML.split('<span').first.strip.imdb_unescape_html
|
36
|
+
|
36
37
|
[Imdb::Movie.new(id, title)]
|
37
38
|
end
|
38
39
|
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'cgi'
|
2
|
-
require 'iconv'
|
3
2
|
|
4
3
|
module Imdb #:nordoc:
|
5
4
|
module StringExtensions
|
6
5
|
|
7
6
|
# Unescape HTML
|
8
7
|
def imdb_unescape_html
|
9
|
-
|
8
|
+
if String.method_defined?(:encode)
|
9
|
+
CGI::unescapeHTML(self.encode("UTF-8", 'ISO-8859-1'))
|
10
|
+
else
|
11
|
+
require 'iconv'
|
12
|
+
Iconv.conv("UTF-8", 'ISO-8859-1', CGI::unescapeHTML(self))
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
# Strip tags
|
data/lib/imdb/version.rb
CHANGED
data/spec/imdb/cli_spec.rb
CHANGED
data/spec/imdb/movie_spec.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
# This test uses "Die hard (1988)" as a testing sample:
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# http://akas.imdb.com/title/tt0095016/combined
|
6
6
|
#
|
7
7
|
|
8
8
|
describe "Imdb::Movie" do
|
9
|
-
|
9
|
+
|
10
10
|
describe "valid movie" do
|
11
11
|
|
12
12
|
before(:each) do
|
13
13
|
# Get Die Hard (1988)
|
14
14
|
@movie = Imdb::Movie.new("0095016")
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should find the cast members" do
|
18
18
|
cast = @movie.cast_members
|
19
|
-
|
19
|
+
|
20
20
|
cast.should be_an(Array)
|
21
21
|
cast.should include("Bruce Willis")
|
22
22
|
cast.should include("Bonnie Bedelia")
|
@@ -27,36 +27,41 @@ describe "Imdb::Movie" do
|
|
27
27
|
it 'should not require arguments' do
|
28
28
|
lambda { @movie.cast_member_ids }.should_not raise_error(ArgumentError)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it 'should not allow arguments' do
|
32
32
|
lambda { @movie.cast_member_ids(:foo) }.should raise_error(ArgumentError)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should return the imdb actor number for each cast member' do
|
36
36
|
@movie.cast_member_ids.sort.should == [
|
37
|
-
"nm0000246", "nm0000614", "nm0000889", "nm0000952", "nm0001108", "nm0001817", "nm0005598",
|
38
|
-
"nm0033749", "nm0040472", "nm0048326", "nm0072054", "nm0094770", "nm0101088", "nm0112505",
|
39
|
-
"nm0112779", "nm0119594", "nm0127960", "nm0142420", "nm0160690", "nm0162041", "nm0234426",
|
40
|
-
"nm0236525", "nm0239958", "nm0278010", "nm0296791", "nm0319739", "nm0322339", "nm0324231",
|
41
|
-
"nm0326276", "nm0338808", "nm0356114", "nm0370729", "nm0383487", "nm0416429", "nm0421114",
|
42
|
-
"nm0441665", "nm0484360", "nm0484650", "nm0493493", "nm0502959", "nm0503610", "nm0504342",
|
43
|
-
"nm0539639", "nm0546076", "nm0546747", "nm0662568", "nm0669625", "nm0681604", "nm0687270",
|
44
|
-
"nm0688235", "nm0718021", "nm0731114", "nm0748041", "nm0776208", "nm0793363", "nm0852311",
|
45
|
-
"nm0870729", "nm0882139", "nm0902455", "nm0907234", "nm0924636", "nm0936591", "nm0958105",
|
37
|
+
"nm0000246", "nm0000614", "nm0000889", "nm0000952", "nm0001108", "nm0001817", "nm0005598",
|
38
|
+
"nm0033749", "nm0040472", "nm0048326", "nm0072054", "nm0094770", "nm0101088", "nm0112505",
|
39
|
+
"nm0112779", "nm0119594", "nm0127960", "nm0142420", "nm0160690", "nm0162041", "nm0234426",
|
40
|
+
"nm0236525", "nm0239958", "nm0278010", "nm0296791", "nm0319739", "nm0322339", "nm0324231",
|
41
|
+
"nm0326276", "nm0338808", "nm0356114", "nm0370729", "nm0383487", "nm0416429", "nm0421114",
|
42
|
+
"nm0441665", "nm0484360", "nm0484650", "nm0493493", "nm0502959", "nm0503610", "nm0504342",
|
43
|
+
"nm0539639", "nm0546076", "nm0546747", "nm0662568", "nm0669625", "nm0681604", "nm0687270",
|
44
|
+
"nm0688235", "nm0718021", "nm0731114", "nm0748041", "nm0776208", "nm0793363", "nm0852311",
|
45
|
+
"nm0870729", "nm0882139", "nm0902455", "nm0907234", "nm0924636", "nm0936591", "nm0958105",
|
46
46
|
"nm2476262", "nm2565888"
|
47
47
|
].sort
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
it "returns the url to the movie trailer" do
|
52
|
+
@movie.trailer_url.should be_an(String)
|
53
|
+
@movie.trailer_url.should == 'http://imdb.com/video/screenplay/vi581042457/'
|
54
|
+
end
|
55
|
+
|
51
56
|
it "should find the director" do
|
52
57
|
@movie.director.should be_an(Array)
|
53
58
|
@movie.director.size.should eql(1)
|
54
59
|
@movie.director.first.should =~ /John McTiernan/
|
55
60
|
end
|
56
|
-
|
61
|
+
|
57
62
|
it "should find the genres" do
|
58
63
|
genres = @movie.genres
|
59
|
-
|
64
|
+
|
60
65
|
genres.should be_an(Array)
|
61
66
|
genres.should include('Action')
|
62
67
|
genres.should include('Thriller')
|
@@ -71,7 +76,7 @@ describe "Imdb::Movie" do
|
|
71
76
|
languages.should include('German')
|
72
77
|
languages.should include('Italian')
|
73
78
|
end
|
74
|
-
|
79
|
+
|
75
80
|
it "should find the countries" do
|
76
81
|
# The Dark Knight (2008)
|
77
82
|
@movie = Imdb::Movie.new("0468569")
|
@@ -81,46 +86,46 @@ describe "Imdb::Movie" do
|
|
81
86
|
countries.size.should eql(2)
|
82
87
|
countries.should include('USA')
|
83
88
|
countries.should include('UK')
|
84
|
-
end
|
89
|
+
end
|
85
90
|
|
86
91
|
it "should find the length (in minutes)" do
|
87
92
|
@movie.length.should eql(131)
|
88
93
|
end
|
89
|
-
|
94
|
+
|
90
95
|
it "should find the plot" do
|
91
96
|
@movie.plot.should eql("New York cop John McClane gives terrorists a dose of their own medicine as they hold hostages in an LA office building.")
|
92
97
|
end
|
93
|
-
|
98
|
+
|
94
99
|
it "should find the poster" do
|
95
100
|
@movie.poster.should eql("http://ia.media-imdb.com/images/M/MV5BMTIxNTY3NjM0OV5BMl5BanBnXkFtZTcwNzg5MzY0MQ@@.jpg")
|
96
101
|
end
|
97
|
-
|
102
|
+
|
98
103
|
it "should find the rating" do
|
99
104
|
@movie.rating.should eql(8.3)
|
100
105
|
end
|
101
|
-
|
106
|
+
|
102
107
|
it "should find number of votes" do
|
103
108
|
@movie.votes.should be_close(210000, 100000)
|
104
109
|
end
|
105
|
-
|
110
|
+
|
106
111
|
it "should find the title" do
|
107
112
|
@movie.title.should =~ /Die Hard/
|
108
113
|
end
|
109
|
-
|
114
|
+
|
110
115
|
it "should find the tagline" do
|
111
116
|
@movie.tagline.should =~ /It will blow you through the back wall of the theater/
|
112
117
|
end
|
113
|
-
|
118
|
+
|
114
119
|
it "should find the year" do
|
115
120
|
@movie.year.should eql(1988)
|
116
121
|
end
|
117
|
-
|
122
|
+
|
118
123
|
describe "special scenarios" do
|
119
|
-
|
124
|
+
|
120
125
|
it "should find multiple directors" do
|
121
126
|
# The Matrix Revolutions (2003)
|
122
127
|
movie = Imdb::Movie.new("0242653")
|
123
|
-
|
128
|
+
|
124
129
|
movie.director.should be_an(Array)
|
125
130
|
movie.director.size.should eql(2)
|
126
131
|
movie.director.should include("Lana Wachowski")
|
@@ -133,53 +138,53 @@ describe "Imdb::Movie" do
|
|
133
138
|
movies.should respond_to(:each)
|
134
139
|
movies.each { |movie| movie.should be_an_instance_of(Imdb::Movie) }
|
135
140
|
end
|
136
|
-
|
141
|
+
|
137
142
|
it "should provide a convenience method to top 250" do
|
138
143
|
movies = Imdb::Movie.top_250
|
139
144
|
movies.should respond_to(:each)
|
140
145
|
movies.each { |movie| movie.should be_an_instance_of(Imdb::Movie) }
|
141
146
|
end
|
142
147
|
end
|
143
|
-
|
148
|
+
|
144
149
|
describe "plot" do
|
145
150
|
it "should find a correct plot when HTML links are present" do
|
146
151
|
movie = Imdb::Movie.new("0083987")
|
147
152
|
movie.plot.should eql("Biography of 'Mahatma Gandhi' , the lawyer who became the famed leader of the Indian revolts against the British rule through his philosophy of non-violent protest.")
|
148
153
|
end
|
149
|
-
|
154
|
+
|
150
155
|
it "should not have a 'more' link in the plot" do
|
151
156
|
movie = Imdb::Movie.new("0036855")
|
152
157
|
movie.plot.should eql("Years after her aunt was murdered in her home, a young woman moves back into the house with her new husband. However, he has a secret which he will do anything to protect, even if that means driving his wife insane.")
|
153
158
|
end
|
154
159
|
end
|
155
|
-
|
160
|
+
|
156
161
|
describe "mpaa rating" do
|
157
162
|
it "should find the mpaa rating when present" do
|
158
163
|
movie = Imdb::Movie.new("0111161")
|
159
164
|
movie.mpaa_rating.should == "Rated R for language and prison violence (certificate 33087)"
|
160
165
|
end
|
161
|
-
|
166
|
+
|
162
167
|
it "should be nil when not present" do
|
163
168
|
movie = Imdb::Movie.new("0095016")
|
164
169
|
movie.mpaa_rating.should be_nil
|
165
170
|
end
|
166
171
|
end
|
167
|
-
|
172
|
+
|
168
173
|
describe "with no submitted poster" do
|
169
|
-
|
170
|
-
before(:each) do
|
174
|
+
|
175
|
+
before(:each) do
|
171
176
|
# Up Is Down (1969)
|
172
177
|
@movie = Imdb::Movie.new("1401252")
|
173
178
|
end
|
174
|
-
|
179
|
+
|
175
180
|
it "should have a title" do
|
176
181
|
@movie.title(true).should =~ /Up Is Down/
|
177
182
|
end
|
178
|
-
|
179
|
-
it "should have a year" do
|
183
|
+
|
184
|
+
it "should have a year" do
|
180
185
|
@movie.year.should eql(1969)
|
181
186
|
end
|
182
|
-
|
187
|
+
|
183
188
|
it "should return nil as poster url" do
|
184
189
|
@movie.poster.should be_nil
|
185
190
|
end
|
data/spec/imdb/search_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Imdb::Search with multiple search results" do
|
4
4
|
|
@@ -22,6 +22,29 @@ describe "Imdb::Search with multiple search results" do
|
|
22
22
|
@search.movies.each { |movie| movie.title.should_not be_blank }
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should return only the title of the result" do
|
26
|
+
@search.movies.first.title.should eql("Star Trek (1966) (TV series)")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return aka titles as well" do
|
30
|
+
alt_titles = [
|
31
|
+
'"Star Trek: TOS" - USA (promotional abbreviation)',
|
32
|
+
'"Star Trek: The Original Series" - USA (informal title)',
|
33
|
+
'"Viaje a las estrellas" - Argentina, Mexico',
|
34
|
+
'"Jornada nas Estrelas" - Brazil',
|
35
|
+
'"La conquista del espacio" - Spain',
|
36
|
+
'"La patrouille du cosmos" - Canada (French title)',
|
37
|
+
'"Raumschiff Enterprise" - West Germany',
|
38
|
+
'"Star Trek" - France',
|
39
|
+
'"Star Trek" - Greece',
|
40
|
+
'"Star Trek" - Italy',
|
41
|
+
'"Star Trek: The Original Series" - Spain',
|
42
|
+
'"Uchuu Daisakusen" - Japan (first season title)',
|
43
|
+
'"Uzay yolu" - Turkey (Turkish title)']
|
44
|
+
|
45
|
+
alt_titles.each { |aka| @search.movies.first.also_known_as.should include(aka) }
|
46
|
+
end
|
47
|
+
|
25
48
|
end
|
26
49
|
|
27
50
|
describe "Imdb::Search with an exact match and no poster" do
|
data/spec/imdb/top_250_spec.rb
CHANGED
metadata
CHANGED
@@ -1,92 +1,90 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: imdb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 6
|
10
|
-
version: 0.6.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ariejan de Vroom
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: hpricot
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70365148085040 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 8
|
32
|
-
- 1
|
33
|
-
version: 0.8.1
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.4
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rdoc
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *70365148085040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70365148084380 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.2
|
48
33
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rspec
|
52
34
|
prerelease: false
|
53
|
-
|
35
|
+
version_requirements: *70365148084380
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70365148083900 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
40
|
+
requirements:
|
56
41
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 31
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 3
|
62
|
-
- 2
|
42
|
+
- !ruby/object:Gem::Version
|
63
43
|
version: 1.3.2
|
64
44
|
type: :development
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: fakeweb
|
68
45
|
prerelease: false
|
69
|
-
|
46
|
+
version_requirements: *70365148083900
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: gokdok
|
49
|
+
requirement: &70365148083520 !ruby/object:Gem::Requirement
|
70
50
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
78
55
|
type: :development
|
79
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70365148083520
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rdoc
|
60
|
+
requirement: &70365148082960 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '3.11'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70365148082960
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakeweb
|
71
|
+
requirement: &70365148082540 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70365148082540
|
80
80
|
description: Easily use Ruby or the command line to find information on IMDB.com.
|
81
|
-
email:
|
81
|
+
email:
|
82
82
|
- ariejan@ariejan.net
|
83
|
-
executables:
|
83
|
+
executables:
|
84
84
|
- imdb
|
85
85
|
extensions: []
|
86
|
-
|
87
86
|
extra_rdoc_files: []
|
88
|
-
|
89
|
-
files:
|
87
|
+
files:
|
90
88
|
- .gitignore
|
91
89
|
- Gemfile
|
92
90
|
- History.txt
|
@@ -132,38 +130,35 @@ files:
|
|
132
130
|
- tasks/rspec.rake
|
133
131
|
homepage: http://github.com/ariejan/imdb
|
134
132
|
licenses: []
|
135
|
-
|
136
133
|
post_install_message:
|
137
134
|
rdoc_options: []
|
138
|
-
|
139
|
-
require_paths:
|
135
|
+
require_paths:
|
140
136
|
- lib
|
141
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
138
|
none: false
|
143
|
-
requirements:
|
144
|
-
- -
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
|
147
|
-
segments:
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
segments:
|
148
144
|
- 0
|
149
|
-
|
150
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
hash: -638483093117193784
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
147
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
segments:
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
157
153
|
- 0
|
158
|
-
|
154
|
+
hash: -638483093117193784
|
159
155
|
requirements: []
|
160
|
-
|
161
156
|
rubyforge_project: imdb
|
162
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.10
|
163
158
|
signing_key:
|
164
159
|
specification_version: 3
|
165
160
|
summary: Easily access the publicly available information on IMDB.
|
166
|
-
test_files:
|
161
|
+
test_files:
|
167
162
|
- spec/fixtures/search_kannethirey_thondrinal
|
168
163
|
- spec/fixtures/search_killed_wife
|
169
164
|
- spec/fixtures/search_star_trek
|