imdb 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,29 @@
1
+ == 0.4.1 2009-06-14
2
+
3
+ * Added support for FakeWeb so specs run faster. [mguterl]
4
+ * Cache the search query i Imdb::Search.query. [mguterl]
5
+ * Added a convenience method Imdb::Search.search. [mguterl]
6
+
1
7
  == 0.4.0 2009-06-14
2
8
 
3
- * Updates to the console 'imdb' utility
9
+ * Updates to the console 'imdb' utility [ariejan]
4
10
  * Show the IMDB ID
5
11
  * Show the full IMDB URL
6
12
 
7
13
  == 0.3.0 2009-06-07
8
14
 
9
- * Fixed typo in CLI field name 'Cast by'
10
- * Fixed retrieval of multiple directors. (#1)
15
+ * Fixed typo in CLI field name 'Cast by' [ariejan]
16
+ * Fixed retrieval of multiple directors. (#1) [ariejan]
11
17
 
12
18
  == 0.2.0 2009-06-04
13
19
 
14
- * Added console tool 'imdb' for searching and getting movie info.
15
- * Fixed issue #2
20
+ * Added console tool 'imdb' for searching and getting movie info. [ariejan]
21
+ * Fixed issue #2 [ariejan]
16
22
 
17
23
  == 0.1.0 2009-06-03
18
24
 
19
- * Added Imdb::Search that allows search IMDB for a specific movie.
25
+ * Added Imdb::Search that allows search IMDB for a specific movie. [ariejan]
20
26
 
21
27
  == 0.0.1 2009-06-03
22
28
 
23
- * First release of the IMDB gem.
29
+ * First release of the IMDB gem. [ariejan]
@@ -10,5 +10,5 @@ require 'imdb/search'
10
10
  require 'imdb/string_extensions'
11
11
 
12
12
  module Imdb
13
- VERSION = '0.4.0'
13
+ VERSION = '0.4.1'
14
14
  end
@@ -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.nil? ? nil : title.gsub(/"/, "")
20
+ @title = title.gsub(/"/, "") if title
21
21
  end
22
22
 
23
23
  # Returns an array with cast members
@@ -87,6 +87,11 @@ module Imdb
87
87
  get("http://www.imdb.com/title/tt#{imdb_id}/")
88
88
  end
89
89
 
90
+ # Convenience method for search
91
+ def self.search(query)
92
+ Imdb::Search.new(query)
93
+ end
94
+
90
95
  end # Movie
91
96
 
92
- end # Imdb
97
+ end # Imdb
@@ -4,6 +4,8 @@ module Imdb
4
4
  class Search
5
5
  include HTTParty
6
6
 
7
+ attr_reader :query
8
+
7
9
  # Initialize a new IMDB search with the specified query
8
10
  #
9
11
  # search = Imdb::Search.new("Star Trek")
@@ -65,4 +67,4 @@ module Imdb
65
67
  end
66
68
 
67
69
  end # Search
68
- end # Imdb
70
+ end # Imdb
@@ -1,12 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- ### WARNING: This spec uses live data!
4
- #
5
- # Many may object to testing against a live website, and for good reason.
6
- # However, the IMDB interface changes over time, and to guarantee the parser
7
- # works with the currently available IMDB website, tests are run against
8
- # IMDB.com instead.
9
- #
10
3
  # This test uses "Die hard (1988)" as a testing sample:
11
4
  #
12
5
  # http://www.imdb.com/title/tt0095016/
@@ -84,5 +77,13 @@ describe "Imdb::Movie" do
84
77
  movie.director.should include("Andy Wachowski")
85
78
  end
86
79
  end
80
+
81
+ describe "search" do
82
+ it "should provide a convenience method to search" do
83
+ search = Imdb::Movie.search("Star Trek")
84
+ search.should respond_to(:movies)
85
+ search.query.should == "Star Trek"
86
+ end
87
+ end
87
88
 
88
- end
89
+ end
@@ -1,20 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- ### WARNING: This spec uses live data!
4
- #
5
- # Many may object to testing against a live website, and for good reason.
6
- # However, the IMDB interface changes over time, and to guarantee the parser
7
- # works with the currently available IMDB website, tests are run against
8
- # IMDB.com instead.
9
- #
10
- # This test searches for "Star Trek"
11
- #
12
3
  describe "Imdb::Search with multiple search results" do
13
4
 
14
5
  before(:each) do
15
- # Search for "Star Trek"
16
6
  @search = Imdb::Search.new("Star Trek")
17
7
  end
8
+
9
+ it "should remember the query" do
10
+ @search.query.should == "Star Trek"
11
+ end
18
12
 
19
13
  it "should find > 10 results" do
20
14
  @search.movies.size.should > 10
@@ -33,7 +27,6 @@ end
33
27
  describe "Imdb::Search with an exact match" do
34
28
 
35
29
  before(:each) do
36
- # Search for "Star Trek"
37
30
  @search = Imdb::Search.new("Matrix Revolutions")
38
31
  end
39
32
 
@@ -44,4 +37,4 @@ describe "Imdb::Search with an exact match" do
44
37
  it "should have the corrected title" do
45
38
  @search.movies.first.title.should =~ /The Matrix Revolutions/i
46
39
  end
47
- end
40
+ end
@@ -1,3 +1,13 @@
1
+ # By default if you have the FakeWeb gem installed when the specs are
2
+ # run they will hit recorded responses. However, if you don't have
3
+ # the FakeWeb gem installed or you set the environment variable
4
+ # LIVE_TEST then the tests will hit the live site IMDB.com.
5
+ ###
6
+ # Having both methods available for testing allows you to quickly
7
+ # refactor and add features, while also being able to make sure that
8
+ # no changes to the IMDB.com interface have affected the parser.
9
+ ###
10
+
1
11
  begin
2
12
  require 'spec'
3
13
  rescue LoadError
@@ -8,3 +18,28 @@ end
8
18
 
9
19
  $:.unshift(File.dirname(__FILE__) + '/../lib')
10
20
  require 'imdb'
21
+
22
+ def read_fixture(path)
23
+ File.read(File.expand_path(File.join(File.dirname(__FILE__), "fixtures", path)))
24
+ end
25
+
26
+ unless ENV['LIVE_TEST']
27
+ begin
28
+ require 'rubygems'
29
+ require 'fakeweb'
30
+
31
+ FakeWeb.allow_net_connect = false
32
+ { "http://www.imdb.com:80/find?q=Matrix+Revolutions;s=tt" => "search_matrix_revolutions",
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
+ }.each do |url, response|
39
+ FakeWeb.register_uri(:get, url, :response => read_fixture(response))
40
+ end
41
+ rescue LoadError
42
+ puts "Could not load FakeWeb, these tests will hit IMDB.com"
43
+ puts "You can run `gem install fakeweb` to stub out the responses."
44
+ end
45
+ 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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom