imdb 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/imdb.rb +1 -1
- data/lib/imdb/cli.rb +3 -3
- data/lib/imdb/movie.rb +3 -2
- data/spec/imdb_movie_spec.rb +16 -1
- metadata +1 -1
data/History.txt
CHANGED
data/lib/imdb.rb
CHANGED
data/lib/imdb/cli.rb
CHANGED
@@ -80,9 +80,9 @@ module Imdb
|
|
80
80
|
@stdout.puts "=" * 72
|
81
81
|
@stdout.puts "Rating: #{movie.rating}"
|
82
82
|
@stdout.puts "Duration: #{movie.length} minutes"
|
83
|
-
@stdout.puts "Directed by: #{movie.director}"
|
84
|
-
@stdout.puts "Cast
|
85
|
-
@stdout.puts "
|
83
|
+
@stdout.puts "Directed by: #{movie.director.join(", ")}"
|
84
|
+
@stdout.puts "Cast: #{movie.cast_members[0..4].join(", ")}"
|
85
|
+
@stdout.puts "Genre: #{movie.genres.join(", ")}"
|
86
86
|
@stdout.puts "#{movie.plot}"
|
87
87
|
@stdout.puts "=" * 72
|
88
88
|
@stdout.puts
|
data/lib/imdb/movie.rb
CHANGED
@@ -17,7 +17,7 @@ module Imdb
|
|
17
17
|
def initialize(imdb_id, title = nil)
|
18
18
|
@id = imdb_id
|
19
19
|
@url = "http://www.imdb.com/title/tt#{imdb_id}/"
|
20
|
-
@title = title.gsub(/"/, "")
|
20
|
+
@title = title.nil? ? nil : title.gsub(/"/, "")
|
21
21
|
end
|
22
22
|
|
23
23
|
# Returns an array with cast members
|
@@ -27,7 +27,8 @@ module Imdb
|
|
27
27
|
|
28
28
|
# Returns the name of the director
|
29
29
|
def director
|
30
|
-
document.at("h5[text()='Director:'] ~ a").innerHTML.strip.imdb_unescape_html rescue nil
|
30
|
+
# document.at("h5[text()='Director:'] ~ a").innerHTML.strip.imdb_unescape_html rescue nil
|
31
|
+
document.search("h5[text()^='Director'] ~ a").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
|
31
32
|
end
|
32
33
|
|
33
34
|
# Returns an array of genres (as strings)
|
data/spec/imdb_movie_spec.rb
CHANGED
@@ -29,7 +29,9 @@ describe "Imdb::Movie" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should find the director" do
|
32
|
-
@movie.director.should
|
32
|
+
@movie.director.should be_an(Array)
|
33
|
+
@movie.director.size.should eql(1)
|
34
|
+
@movie.director.first.should =~ /John McTiernan/
|
33
35
|
end
|
34
36
|
|
35
37
|
it "should find the genres" do
|
@@ -70,4 +72,17 @@ describe "Imdb::Movie" do
|
|
70
72
|
@movie.year.should eql(1988)
|
71
73
|
end
|
72
74
|
|
75
|
+
describe "special scenarios" do
|
76
|
+
|
77
|
+
it "should find multiple directors" do
|
78
|
+
# The Matrix Revolutions (2003)
|
79
|
+
movie = Imdb::Movie.new("0242653")
|
80
|
+
|
81
|
+
movie.director.should be_an(Array)
|
82
|
+
movie.director.size.should eql(2)
|
83
|
+
movie.director.should include("Larry Wachowski")
|
84
|
+
movie.director.should include("Andy Wachowski")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
end
|