imdb 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.rdoc +18 -2
- data/Rakefile +48 -40
- data/VERSION +1 -0
- data/config/website.yml +2 -0
- data/imdb.gemspec +91 -0
- data/lib/imdb.rb +1 -1
- data/lib/imdb/cli.rb +10 -6
- data/lib/imdb/movie.rb +2 -2
- data/lib/imdb/string_extensions.rb +0 -1
- data/spec/fixtures/search_matrix_revolutions +5 -5
- data/spec/fixtures/search_star_trek +360 -285
- data/spec/fixtures/top_250 +1030 -708
- data/spec/fixtures/tt0095016 +521 -460
- data/spec/fixtures/tt0111161 +511 -436
- data/spec/fixtures/tt0117731 +523 -364
- data/spec/fixtures/tt0242653 +509 -417
- data/spec/fixtures/tt1352369 +1032 -0
- data/spec/imdb/movie_spec.rb +86 -64
- data/spec/spec_helper.rb +14 -10
- data/tasks/fixtures.rake +15 -0
- metadata +39 -21
data/spec/imdb/movie_spec.rb
CHANGED
@@ -7,87 +7,109 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
7
7
|
|
8
8
|
describe "Imdb::Movie" do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
describe "valid movie" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
# Get Die Hard (1988)
|
14
|
+
@movie = Imdb::Movie.new("0095016")
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
it "should find the cast members" do
|
18
|
+
cast = @movie.cast_members
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
cast.should be_an(Array)
|
21
|
+
cast.should include("Bruce Willis")
|
22
|
+
cast.should include("Bonnie Bedelia")
|
23
|
+
cast.should include("Alan Rickman")
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
it "should find the director" do
|
27
|
+
@movie.director.should be_an(Array)
|
28
|
+
@movie.director.size.should eql(1)
|
29
|
+
@movie.director.first.should =~ /John McTiernan/
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
it "should find the genres" do
|
33
|
+
genres = @movie.genres
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
it "should find the length (in minutes)" do
|
41
|
-
@movie.length.should eql(131)
|
42
|
-
end
|
35
|
+
genres.should be_an(Array)
|
36
|
+
genres.should include('Action')
|
37
|
+
genres.should include('Crime')
|
38
|
+
genres.should include('Drama')
|
39
|
+
genres.should include('Thriller')
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
it "should find the length (in minutes)" do
|
43
|
+
@movie.length.should eql(131)
|
44
|
+
end
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
it "should find the plot" do
|
47
|
+
@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.")
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
it "should find the poster" do
|
51
|
+
@movie.poster.should eql("http://ia.media-imdb.com/images/M/MV5BMTIxNTY3NjM0OV5BMl5BanBnXkFtZTcwNzg5MzY0MQ@@.jpg")
|
52
|
+
end
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
it "should find the rating" do
|
55
|
+
@movie.rating.should eql(8.3)
|
56
|
+
end
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
it "should find the title" do
|
59
|
+
@movie.title.should =~ /Die Hard/
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
it "should find the tagline" do
|
63
|
+
@movie.tagline.should =~ /It will blow you through the back wall of the theater/
|
64
|
+
end
|
67
65
|
|
68
|
-
|
66
|
+
it "should find the year" do
|
67
|
+
@movie.year.should eql(1988)
|
68
|
+
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
describe "special scenarios" do
|
71
|
+
|
72
|
+
it "should find multiple directors" do
|
73
|
+
# The Matrix Revolutions (2003)
|
74
|
+
movie = Imdb::Movie.new("0242653")
|
73
75
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
movie.director.should be_an(Array)
|
77
|
+
movie.director.size.should eql(2)
|
78
|
+
movie.director.should include("Larry Wachowski")
|
79
|
+
movie.director.should include("Andy Wachowski")
|
80
|
+
end
|
78
81
|
end
|
79
|
-
end
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
it "should provide a convenience method to search" do
|
84
|
+
movies = Imdb::Movie.search("Star Trek")
|
85
|
+
movies.should respond_to(:each)
|
86
|
+
movies.each { |movie| movie.should be_an_instance_of(Imdb::Movie) }
|
87
|
+
end
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
it "should provide a convenience method to top 250" do
|
90
|
+
movies = Imdb::Movie.top_250
|
91
|
+
movies.should respond_to(:each)
|
92
|
+
movies.each { |movie| movie.should be_an_instance_of(Imdb::Movie) }
|
93
|
+
end
|
91
94
|
end
|
92
95
|
|
96
|
+
describe "with no submitted poster" do
|
97
|
+
|
98
|
+
before(:each) do
|
99
|
+
# Grotesque (2009)
|
100
|
+
@movie = Imdb::Movie.new("1352369")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should have a title" do
|
104
|
+
@movie.title(true).should =~ /Gurotesuku/
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should have a year" do
|
108
|
+
@movie.year.should eql(2009)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return nil as poster url" do
|
112
|
+
@movie.poster.should be_nil
|
113
|
+
end
|
114
|
+
end
|
93
115
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# run they will hit recorded responses. However, if you don't have
|
3
3
|
# the FakeWeb gem installed or you set the environment variable
|
4
4
|
# LIVE_TEST then the tests will hit the live site IMDB.com.
|
5
|
-
|
5
|
+
#
|
6
6
|
# Having both methods available for testing allows you to quickly
|
7
7
|
# refactor and add features, while also being able to make sure that
|
8
8
|
# no changes to the IMDB.com interface have affected the parser.
|
@@ -23,21 +23,25 @@ def read_fixture(path)
|
|
23
23
|
File.read(File.expand_path(File.join(File.dirname(__FILE__), "fixtures", path)))
|
24
24
|
end
|
25
25
|
|
26
|
+
IMDB_SAMPLES = {
|
27
|
+
"http://www.imdb.com:80/find?q=Matrix+Revolutions;s=tt" => "search_matrix_revolutions",
|
28
|
+
"http://www.imdb.com:80/find?q=Star+Trek;s=tt" => "search_star_trek",
|
29
|
+
"http://www.imdb.com:80/title/tt0117731/" => "tt0117731",
|
30
|
+
"http://www.imdb.com:80/title/tt0095016/" => "tt0095016",
|
31
|
+
"http://www.imdb.com:80/title/tt0242653/" => "tt0242653",
|
32
|
+
"http://www.imdb.com/title/tt0242653/?fr=c2M9MXxsbT01MDB8ZmI9dXx0dD0xfG14PTIwfGh0bWw9MXxjaD0xfGNvPTF8cG49MHxmdD0xfGt3PTF8cXM9TWF0cml4IFJldm9sdXRpb25zfHNpdGU9ZGZ8cT1NYXRyaXggUmV2b2x1dGlvbnN8bm09MQ__;fc=1;ft=20" => "tt0242653",
|
33
|
+
"http://www.imdb.com:80/chart/top" => "top_250",
|
34
|
+
"http://www.imdb.com/title/tt0111161/" => "tt0111161",
|
35
|
+
"http://www.imdb.com/title/tt1352369/" => "tt1352369"
|
36
|
+
}
|
37
|
+
|
26
38
|
unless ENV['LIVE_TEST']
|
27
39
|
begin
|
28
40
|
require 'rubygems'
|
29
41
|
require 'fakeweb'
|
30
42
|
|
31
43
|
FakeWeb.allow_net_connect = false
|
32
|
-
|
33
|
-
"http://www.imdb.com:80/find?q=Star+Trek;s=tt" => "search_star_trek",
|
34
|
-
"http://www.imdb.com:80/title/tt0117731/" => "tt0117731",
|
35
|
-
"http://www.imdb.com:80/title/tt0095016/" => "tt0095016",
|
36
|
-
"http://www.imdb.com:80/title/tt0242653/" => "tt0242653",
|
37
|
-
"http://www.imdb.com:80/title/tt0242653/?fr=c2M9MXxsbT01MDB8ZmI9dXx0dD0xfG14PTIwfHFzPU1hdHJpeCBSZXZvbHV0aW9uc3xodG1sPTF8c2l0ZT1kZnxxPU1hdHJpeCBSZXZvbHV0aW9uc3xwbj0w;fc=1;ft=20" => "tt0242653",
|
38
|
-
"http://www.imdb.com:80/chart/top" => "top_250",
|
39
|
-
"http://www.imdb.com/title/tt0111161/" => "tt0111161",
|
40
|
-
}.each do |url, response|
|
44
|
+
IMDB_SAMPLES.each do |url, response|
|
41
45
|
FakeWeb.register_uri(:get, url, :response => read_fixture(response))
|
42
46
|
end
|
43
47
|
rescue LoadError
|
data/tasks/fixtures.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :fixtures do
|
2
|
+
desc "Refresh spec fixtures with fresh data from IMDB.com"
|
3
|
+
task :refresh do
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec/spec_helper")
|
5
|
+
|
6
|
+
IMDB_SAMPLES.each_pair do |url, fixture|
|
7
|
+
page = `curl -is #{url}`
|
8
|
+
|
9
|
+
File.open(File.expand_path(File.dirname(__FILE__) + "/../spec/fixtures/#{fixture}"), 'w') do |f|
|
10
|
+
f.write(page)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ariejan de Vroom
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-11-25 00:00:00 +01:00
|
13
|
+
default_executable: imdb
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: hpricot
|
17
27
|
type: :runtime
|
@@ -23,42 +33,43 @@ dependencies:
|
|
23
33
|
version: 0.8.1
|
24
34
|
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
36
|
+
name: fakeweb
|
27
37
|
type: :development
|
28
38
|
version_requirement:
|
29
39
|
version_requirements: !ruby/object:Gem::Requirement
|
30
40
|
requirements:
|
31
41
|
- - ">="
|
32
42
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
43
|
+
version: "0"
|
34
44
|
version:
|
35
45
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
46
|
+
name: rspec
|
37
47
|
type: :development
|
38
48
|
version_requirement:
|
39
49
|
version_requirements: !ruby/object:Gem::Requirement
|
40
50
|
requirements:
|
41
51
|
- - ">="
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
53
|
+
version: "0"
|
44
54
|
version:
|
45
|
-
description:
|
46
|
-
email:
|
47
|
-
- ariejan@ariejan.net
|
55
|
+
description: Easily use Ruby or the command line to find information on IMDB.com.
|
56
|
+
email: ariejan@ariejan.net
|
48
57
|
executables:
|
49
58
|
- imdb
|
50
59
|
extensions: []
|
51
60
|
|
52
61
|
extra_rdoc_files:
|
53
|
-
- History.txt
|
54
|
-
- Manifest.txt
|
55
62
|
- README.rdoc
|
56
63
|
files:
|
64
|
+
- .gitignore
|
57
65
|
- History.txt
|
58
66
|
- Manifest.txt
|
59
67
|
- README.rdoc
|
60
68
|
- Rakefile
|
69
|
+
- VERSION
|
61
70
|
- bin/imdb
|
71
|
+
- config/website.yml
|
72
|
+
- imdb.gemspec
|
62
73
|
- lib/imdb.rb
|
63
74
|
- lib/imdb/cli.rb
|
64
75
|
- lib/imdb/movie.rb
|
@@ -76,19 +87,22 @@ files:
|
|
76
87
|
- spec/fixtures/tt0111161
|
77
88
|
- spec/fixtures/tt0117731
|
78
89
|
- spec/fixtures/tt0242653
|
90
|
+
- spec/fixtures/tt1352369
|
79
91
|
- spec/imdb/cli_spec.rb
|
80
92
|
- spec/imdb/movie_spec.rb
|
81
93
|
- spec/imdb/search_spec.rb
|
82
94
|
- spec/imdb/top_250_spec.rb
|
83
95
|
- spec/spec.opts
|
84
96
|
- spec/spec_helper.rb
|
97
|
+
- tasks/fixtures.rake
|
85
98
|
- tasks/rspec.rake
|
86
99
|
has_rdoc: true
|
87
|
-
homepage:
|
100
|
+
homepage: http://github.com/ariejan/imdb
|
101
|
+
licenses: []
|
102
|
+
|
88
103
|
post_install_message:
|
89
104
|
rdoc_options:
|
90
|
-
- --
|
91
|
-
- README.rdoc
|
105
|
+
- --charset=UTF-8
|
92
106
|
require_paths:
|
93
107
|
- lib
|
94
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -105,10 +119,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
119
|
version:
|
106
120
|
requirements: []
|
107
121
|
|
108
|
-
rubyforge_project:
|
109
|
-
rubygems_version: 1.3.
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.3.5
|
110
124
|
signing_key:
|
111
|
-
specification_version:
|
112
|
-
summary:
|
113
|
-
test_files:
|
114
|
-
|
125
|
+
specification_version: 3
|
126
|
+
summary: Easily access the publicly available information on IMDB.
|
127
|
+
test_files:
|
128
|
+
- spec/imdb/cli_spec.rb
|
129
|
+
- spec/imdb/movie_spec.rb
|
130
|
+
- spec/imdb/search_spec.rb
|
131
|
+
- spec/imdb/top_250_spec.rb
|
132
|
+
- spec/spec_helper.rb
|