imdb_party 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/README.md CHANGED
@@ -5,6 +5,9 @@
5
5
  ### Create an instance
6
6
 
7
7
  imdb = ImdbParty::Imdb.new
8
+ imdb = ImdbParty::Imdb.new(:anonymize => true) # this will anonymize your requests to prevent getting your ip banned
9
+
10
+
8
11
  ### Search for a movie by title
9
12
 
10
13
  imdb.find_by_title("The Dark Knight") => [{:title => "The Dark Knight", :year => "2008", :imdb_id => "tt0468569"}, {:title => "Batman Unmasked", ...}]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/imdb_party.gemspec CHANGED
@@ -1,51 +1,52 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{imdb_party}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jon Maddox"]
12
- s.date = %q{2011-01-04}
12
+ s.date = %q{2011-04-26}
13
13
  s.description = %q{IMDB client using the IMDB API that their iPhone app uses}
14
14
  s.email = %q{jon@mustacheinc.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- "LICENSE",
22
- "README.md",
23
- "Rakefile",
24
- "VERSION",
25
- "imdb_party.gemspec",
26
- "lib/imdb_party.rb",
27
- "lib/imdb_party/httparty_icebox.rb",
28
- "lib/imdb_party/imdb.rb",
29
- "lib/imdb_party/movie.rb",
30
- "lib/imdb_party/person.rb",
31
- "test/movie_test.rb",
32
- "test/person_test.rb",
33
- "test/search_test.rb",
34
- "test/test_helper.rb"
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "imdb_party.gemspec",
27
+ "lib/imdb_party.rb",
28
+ "lib/imdb_party/httparty_icebox.rb",
29
+ "lib/imdb_party/imdb.rb",
30
+ "lib/imdb_party/movie.rb",
31
+ "lib/imdb_party/person.rb",
32
+ "test/movie_test.rb",
33
+ "test/person_test.rb",
34
+ "test/search_test.rb",
35
+ "test/test_helper.rb"
35
36
  ]
36
37
  s.homepage = %q{http://github.com/maddox/imdb_party}
38
+ s.rdoc_options = ["--charset=UTF-8"]
37
39
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.7}
40
+ s.rubygems_version = %q{1.4.2}
39
41
  s.summary = %q{IMDB client using the IMDB API that their iPhone app uses}
40
42
  s.test_files = [
41
43
  "test/movie_test.rb",
42
- "test/person_test.rb",
43
- "test/search_test.rb",
44
- "test/test_helper.rb"
44
+ "test/person_test.rb",
45
+ "test/search_test.rb",
46
+ "test/test_helper.rb"
45
47
  ]
46
48
 
47
49
  if s.respond_to? :specification_version then
48
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
50
  s.specification_version = 3
50
51
 
51
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -60,4 +61,3 @@ Gem::Specification.new do |s|
60
61
  s.add_dependency(%q<httparty>, [">= 0"])
61
62
  end
62
63
  end
63
-
data/lib/imdb_party.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'httparty'
2
3
 
3
4
  directory = File.expand_path(File.dirname(__FILE__))
@@ -5,4 +6,3 @@ require File.join(directory, 'imdb_party', 'httparty_icebox')
5
6
  require File.join(directory, 'imdb_party', 'imdb')
6
7
  require File.join(directory, 'imdb_party', 'movie')
7
8
  require File.join(directory, 'imdb_party', 'person')
8
-
@@ -207,11 +207,11 @@ module HTTParty #:nodoc:
207
207
  end
208
208
  def set(key, value)
209
209
  Cache.logger.info("Cache: set (#{key})")
210
- File.open( @path.join(key), 'w' ) { |file| file << Marshal.dump(value) }
210
+ File.open( @path.join(key), 'w' ) { |file| Marshal.dump(value, file) }
211
211
  true
212
212
  end
213
213
  def get(key)
214
- data = Marshal.load(File.read( @path.join(key)))
214
+ data = Marshal.load(File.new(@path.join(key)))
215
215
  Cache.logger.info("Cache: #{data.nil? ? "miss" : "hit"} (#{key})")
216
216
  data
217
217
  end
@@ -5,8 +5,11 @@ module ImdbParty
5
5
  cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
6
6
 
7
7
  base_uri 'app.imdb.com'
8
- default_params = {"api" => "v1", "appid" => "iphone1", "locale" => "en_US", "timestamp" => Time.now.to_i, "sig" => "heres my signature"}
8
+ default_params = {"api" => "v1", "appid" => "iphone1_1", "apiPolicy" => "app1_1", "apiKey" => "2wex6aeu6a8q9e49k7sfvufd6rhh0n", "locale" => "en_US", "timestamp" => Time.now.to_i, "sig" => "heres my signature"}
9
9
 
10
+ def initialize(options={})
11
+ self.class.base_uri 'http://anonymouse.org/cgi-bin/anon-www.cgi/http://app.imdb.com' if options[:anonymize]
12
+ end
10
13
 
11
14
  def find_by_title(title)
12
15
  movie_results = []
data/test/movie_test.rb CHANGED
@@ -6,68 +6,80 @@ class MovieTest < Test::Unit::TestCase
6
6
  @imdb = ImdbParty::Imdb.new
7
7
  @movie = @imdb.find_movie_by_id("tt0382932")
8
8
  end
9
-
9
+
10
10
  should "have a title" do
11
11
  assert_equal "Ratatouille", @movie.title
12
12
  end
13
-
13
+
14
14
  should "have an imdb_id" do
15
15
  assert_equal "tt0382932", @movie.imdb_id
16
16
  end
17
-
17
+
18
18
  should "have a tagline" do
19
19
  assert_equal "Dinner is served... Summer 2007", @movie.tagline
20
20
  end
21
-
21
+
22
22
  should "have a plot" do
23
23
  assert_equal "Remy is a young rat in the French countryside who arrives in Paris, only to find out that his cooking idol is dead. When he makes an unusual alliance with a restaurant's new garbage boy, the culinary and personal adventures begin despite Remy's family's skepticism and the rat-hating world of humans.", @movie.plot
24
24
  end
25
-
25
+
26
26
  should "have a runtime" do
27
27
  assert_equal "111 min", @movie.runtime
28
28
  end
29
-
29
+
30
30
  should "have a rating" do
31
31
  assert_equal 8.1, @movie.rating
32
32
  end
33
-
33
+
34
34
  should "have a poster_url" do
35
35
  assert_match /http:\/\/ia.media-imdb.com\/images\/.*/, @movie.poster_url
36
36
  end
37
-
37
+
38
38
  should "have a release date" do
39
39
  assert_equal DateTime.parse("2007-06-29"), @movie.release_date
40
40
  end
41
-
41
+
42
42
  should "have a certification" do
43
43
  assert_equal "G", @movie.certification
44
44
  end
45
-
45
+
46
46
  should "have trailers" do
47
47
  assert_equal Hash, @movie.trailers.class
48
48
  assert_equal 4, @movie.trailers.keys.size
49
49
  assert_equal "http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e27826&bitrateid=461&vendorid=102&type=.mp4", @movie.trailers[@movie.trailers.keys.first]
50
50
  end
51
-
51
+
52
52
  should "have genres" do
53
53
  assert_equal Array, @movie.genres.class
54
54
  assert_equal 4, @movie.genres.size
55
55
  end
56
-
56
+
57
57
  should "have actors" do
58
58
  assert_equal Array, @movie.actors.class
59
59
  assert_equal 4, @movie.actors.size
60
60
  end
61
-
61
+
62
62
  should "have directors" do
63
63
  assert_equal Array, @movie.directors.class
64
64
  assert_equal 2, @movie.directors.size
65
65
  end
66
-
66
+
67
67
  should "have writers" do
68
68
  assert_equal Array, @movie.writers.class
69
69
  assert_equal 2, @movie.writers.size
70
70
  end
71
+
72
+ end
73
+
74
+ context "a movie while anonymized" do
75
+ setup do
76
+ @imdb = ImdbParty::Imdb.new(:anonymize => true)
77
+ @movie = @imdb.find_movie_by_id("tt0382932")
78
+ end
71
79
 
80
+ should "have a title" do
81
+ assert_equal "Ratatouille", @movie.title
82
+ end
72
83
  end
84
+
73
85
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imdb_party
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Maddox
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-04 00:00:00 -05:00
18
+ date: 2011-04-26 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,7 @@ extra_rdoc_files:
57
57
  - README.md
58
58
  files:
59
59
  - .document
60
+ - .gitignore
60
61
  - LICENSE
61
62
  - README.md
62
63
  - Rakefile
@@ -76,8 +77,8 @@ homepage: http://github.com/maddox/imdb_party
76
77
  licenses: []
77
78
 
78
79
  post_install_message:
79
- rdoc_options: []
80
-
80
+ rdoc_options:
81
+ - --charset=UTF-8
81
82
  require_paths:
82
83
  - lib
83
84
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  requirements: []
102
103
 
103
104
  rubyforge_project:
104
- rubygems_version: 1.3.7
105
+ rubygems_version: 1.4.2
105
106
  signing_key:
106
107
  specification_version: 3
107
108
  summary: IMDB client using the IMDB API that their iPhone app uses