imdb 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.3.0
2
+
3
+ * Fixed typo in CLI field name 'Cast by'
4
+ * Fixed retrieval of multiple directors. (#1)
5
+
1
6
  == 0.2.0 2009-06-04
2
7
 
3
8
  * Added console tool 'imdb' for searching and getting movie info.
@@ -10,5 +10,5 @@ require 'imdb/search'
10
10
  require 'imdb/string_extensions'
11
11
 
12
12
  module Imdb
13
- VERSION = '0.2.0'
13
+ VERSION = '0.3.0'
14
14
  end
@@ -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 by: #{movie.cast_members[0..4].join(", ")}"
85
- @stdout.puts "Genres: #{movie.genres.join(", ")}"
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
@@ -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)
@@ -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 =~ /John McTiernan/
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
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom