maksar-imdb_party 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
data/lib/imdb_party.rb CHANGED
@@ -5,4 +5,5 @@ directory = File.expand_path(File.dirname(__FILE__))
5
5
  require File.join(directory, 'imdb_party', 'httparty_icebox')
6
6
  require File.join(directory, 'imdb_party', 'imdb')
7
7
  require File.join(directory, 'imdb_party', 'movie')
8
+ require File.join(directory, 'imdb_party', 'search_result')
8
9
  require File.join(directory, 'imdb_party', 'person')
@@ -41,7 +41,7 @@ module ImdbParty
41
41
  next unless r["tconst"] && r["title"]
42
42
  h = {:title => r["title"], :year => r["year"], :imdb_id => r["tconst"], :kind => r["type"]}
43
43
  h.merge!(:poster_url => r["image"]["url"]) if r["image"] && r["image"]["url"]
44
- movie_results << h
44
+ movie_results << SearchResult.new(h)
45
45
  end
46
46
  end
47
47
  end
@@ -60,14 +60,14 @@ module ImdbParty
60
60
  url = build_url('/chart/top')
61
61
 
62
62
  results = self.class.get(url).parsed_response
63
- results["data"]["list"]["list"].map { |r| {:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)} }
63
+ results["data"]["list"]["list"].map { |r| SearchResult.new({:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)}) }
64
64
  end
65
65
 
66
66
  def popular_shows
67
67
  url = build_url('/chart/tv')
68
68
 
69
69
  results = self.class.get(url).parsed_response
70
- results["data"]["list"].map { |r| {:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)} }
70
+ results["data"]["list"].map { |r| SearchResult.new({:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)}) }
71
71
  end
72
72
 
73
73
  end
@@ -34,5 +34,9 @@ module ImdbParty
34
34
  end
35
35
 
36
36
  end
37
+
38
+ def icon(size)
39
+ SearchResult.new({:poster_url => @poster_url}).icon(size)
40
+ end
37
41
  end
38
42
  end
@@ -0,0 +1,17 @@
1
+ require 'delegate'
2
+ module ImdbParty
3
+ class SearchResult < DelegateClass(Hash)
4
+
5
+ def initialize(options)
6
+ super(options)
7
+ end
8
+
9
+ def icon(size = 256)
10
+ return nil unless self[:poster_url]
11
+
12
+ self[:poster_url].gsub(/^(.*)(_V1_)(.*)$/, "\\1\\2SY#{size}\\3")
13
+ end
14
+
15
+ end
16
+ end
17
+
data/test/movie_test.rb CHANGED
@@ -34,7 +34,11 @@ class MovieTest < Test::Unit::TestCase
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
+ should "have a icon with exact size" do
39
+ assert_match /http:\/\/ia.media-imdb.com\/images\/.*/, @movie.icon(128)
40
+ end
41
+
38
42
  should "have a release date" do
39
43
  assert_equal DateTime.parse("2007-06-29"), @movie.release_date
40
44
  end
@@ -45,7 +49,7 @@ class MovieTest < Test::Unit::TestCase
45
49
 
46
50
  should "have trailers" do
47
51
  assert_equal Hash, @movie.trailers.class
48
- assert_equal 2, @movie.trailers.keys.size
52
+ assert_equal 1, @movie.trailers.keys.size
49
53
  assert_equal "http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e27826&bitrateid=461&vendorid=102&type=.mp4", @movie.trailers[@movie.trailers.keys.first]
50
54
  end
51
55
 
data/test/search_test.rb CHANGED
@@ -53,7 +53,7 @@ class SearchTest < Test::Unit::TestCase
53
53
 
54
54
  should "be an Array of Hashes" do
55
55
  assert_equal Array, @movies.class
56
- assert_equal Hash, @movies.first.class
56
+ assert_equal ImdbParty::SearchResult, @movies.first.class
57
57
  end
58
58
  end
59
59
 
@@ -64,7 +64,7 @@ class SearchTest < Test::Unit::TestCase
64
64
 
65
65
  should "be an Array of Hashes" do
66
66
  assert_equal Array, @shows.class
67
- assert_equal Hash, @shows.first.class
67
+ assert_equal ImdbParty::SearchResult, @shows.first.class
68
68
  end
69
69
  end
70
70
 
@@ -82,7 +82,7 @@ class SearchTest < Test::Unit::TestCase
82
82
 
83
83
  should "be an Array of Hashes" do
84
84
  assert_equal Array, @shows.class
85
- assert_equal Hash, @shows.first.class
85
+ assert_equal ImdbParty::SearchResult, @shows.first.class
86
86
  end
87
87
  end
88
88
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: maksar-imdb_party
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.2
5
+ version: 0.6.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jon Maddox
@@ -55,6 +55,7 @@ files:
55
55
  - lib/imdb_party/imdb.rb
56
56
  - lib/imdb_party/movie.rb
57
57
  - lib/imdb_party/person.rb
58
+ - lib/imdb_party/search_result.rb
58
59
  - maksar-imdb_party.gemspec
59
60
  - test/movie_test.rb
60
61
  - test/person_test.rb