ruby-tmdb3 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -49,10 +49,11 @@ class Tmdb
49
49
  method, action = method.split '/'
50
50
 
51
51
  data = {
52
- api_key: Tmdb.api_key,
53
- language: language
52
+ :api_key => Tmdb.api_key
54
53
  }.merge(data)
55
54
 
55
+ data.merge!(:language => language) if language
56
+
56
57
  # Addressable can only handle hashes whose values respond to to_str, so lets be nice and convert things.
57
58
  query_values = {}
58
59
  data.each do |key,value|
@@ -71,7 +72,7 @@ class Tmdb
71
72
  # Construct URL other queries
72
73
  else
73
74
  query_values = {
74
- query: CGI::escape(data[:query])
75
+ :query => CGI::escape(data[:query])
75
76
  }.merge(query_values)
76
77
  uri.query_values = query_values
77
78
  end
@@ -115,7 +116,7 @@ class Tmdb
115
116
  image_array = Array object.send(image_array_name)
116
117
  single_name = image_array_name.slice 0..-2 # singularize name
117
118
  single_path = object.send "#{single_name}_path" # default poster/backdrop image
118
- image_array << object.send("#{image_array_name.slice 0..-2}=", DeepOpenStruct.load({file_path: single_path}))
119
+ image_array << object.send("#{image_array_name.slice 0..-2}=", DeepOpenStruct.load({:file_path => single_path}))
119
120
  # build a struct containing availables sizes with their urls
120
121
  image_array.each do |image|
121
122
  urls = CONFIGURATION.images.send("#{image_array_name}_sizes").inject({}) do |hash, size|
@@ -10,10 +10,10 @@ class TmdbCast
10
10
 
11
11
  results = []
12
12
  unless(options[:id].nil? || options[:id].to_s.empty?)
13
- results << Tmdb.api_call("person", {id: options[:id].to_s}, options[:language])
13
+ results << Tmdb.api_call("person", {:id => options[:id].to_s}, options[:language])
14
14
  end
15
15
  unless(options[:name].nil? || options[:name].to_s.empty?)
16
- api_return = Tmdb.api_call('search/person', {query: options[:name].to_s}, options[:language])
16
+ api_return = Tmdb.api_call('search/person', {:query => options[:name].to_s}, options[:language])
17
17
  results << api_return["results"] if api_return
18
18
  end
19
19
 
@@ -40,7 +40,7 @@ class TmdbCast
40
40
  # (as determined by checking for the 'birthday' property)
41
41
  if(expand_results && !raw_data.has_key?("birthday"))
42
42
  begin
43
- expanded_data = Tmdb.api_call("person", {id: raw_data["id"].to_s}, language)
43
+ expanded_data = Tmdb.api_call("person", {:id => raw_data["id"].to_s}, language)
44
44
  rescue RuntimeError => e
45
45
  raise ArgumentError, "Unable to fetch expanded info for Cast ID: '#{raw_data["id"]}'" if expanded_data.nil?
46
46
  end
@@ -10,14 +10,14 @@ class TmdbMovie
10
10
 
11
11
  results = []
12
12
  unless(options[:id].nil? || options[:id].to_s.empty?)
13
- results << Tmdb.api_call("movie", {id: options[:id].to_s}, options[:language])
13
+ results << Tmdb.api_call("movie", {:id => options[:id].to_s}, options[:language])
14
14
  end
15
15
  unless(options[:title].nil? || options[:title].to_s.empty?)
16
- api_return = Tmdb.api_call("search/movie", {query: options[:title].to_s}, options[:language])
16
+ api_return = Tmdb.api_call("search/movie", {:query => options[:title].to_s}, options[:language])
17
17
  results << api_return["results"] if api_return
18
18
  end
19
19
  unless(options[:imdb].nil? || options[:imdb].to_s.empty?)
20
- results << Tmdb.api_call("movie", {id: options[:imdb].to_s}, options[:language])
20
+ results << Tmdb.api_call("movie", {:id => options[:imdb].to_s}, options[:language])
21
21
  options[:expand_results] = true
22
22
  end
23
23
 
@@ -45,10 +45,10 @@ class TmdbMovie
45
45
  if(expand_results && (!raw_data.has_key?("posters") || !raw_data['releases'] || !raw_data['cast']))
46
46
  begin
47
47
  movie_id = raw_data['id']
48
- raw_data = Tmdb.api_call 'movie', { id: movie_id }, language
49
- @images_data = Tmdb.api_call("movie/images", {id: movie_id}, language)
50
- @releases_data = Tmdb.api_call('movie/releases', {id: movie_id}, language)
51
- @cast_data = Tmdb.api_call('movie/casts', {id: movie_id}, language)
48
+ raw_data = Tmdb.api_call 'movie', { :id => movie_id }, language
49
+ @images_data = Tmdb.api_call("movie/images", {:id => movie_id}, language)
50
+ @releases_data = Tmdb.api_call('movie/releases', {:id => movie_id}, language)
51
+ @cast_data = Tmdb.api_call('movie/casts', {:id => movie_id}, language)
52
52
  raw_data['posters'] = @images_data['posters']
53
53
  raw_data['backdrops'] = @images_data['backdrops']
54
54
  raw_data['releases'] = @releases_data['countries']
data/ruby-tmdb3.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-tmdb3"
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Irio Irineu Musskopf Junior", "Aaron Gough"]
12
- s.date = "2012-08-20"
12
+ s.date = "2012-09-15"
13
13
  s.description = "An ActiveRecord-style API wrapper for TheMovieDB.org"
14
14
  s.email = "iirineu@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -1,5 +1,5 @@
1
1
  begin
2
- file_path = File.absolute_path('tmdb_api_key.txt', File.dirname(__FILE__))
2
+ file_path = File.expand_path('tmdb_api_key.txt', File.dirname(__FILE__))
3
3
 
4
4
  File.open(file_path) do |file|
5
5
  Tmdb.api_key = file.read.chomp
@@ -87,20 +87,20 @@ class TmdbCastTest < Test::Unit::TestCase
87
87
 
88
88
  test "should pass default language to Tmdb.api_call if language is not supplied" do
89
89
  Tmdb.expects(:api_call).
90
- with("person", {id: "1"}, Tmdb.default_language).returns(nil)
90
+ with("person", {:id => "1"}, Tmdb.default_language).returns(nil)
91
91
  Tmdb.expects(:api_call).
92
- with("search/person", {query: "1"}, Tmdb.default_language).returns(nil)
92
+ with("search/person", {:query => "1"}, Tmdb.default_language).returns(nil)
93
93
  TmdbCast.find(:id => 1, :name => 1)
94
94
  end
95
95
 
96
96
  test "should pass through language to Tmdb.api_call when language is supplied" do
97
- Tmdb.expects(:api_call).with("person", {id: "1"}, "foo").returns(nil)
98
- Tmdb.expects(:api_call).with("search/person", {query: "1"}, "foo").returns(nil)
97
+ Tmdb.expects(:api_call).with("person", {:id => "1"}, "foo").returns(nil)
98
+ Tmdb.expects(:api_call).with("search/person", {:query => "1"}, "foo").returns(nil)
99
99
  TmdbCast.find(:id => 1, :name => 1, :language => "foo")
100
100
  end
101
101
 
102
102
  test "TmdbCast.new should raise error if supplied with raw data for cast member that doesn't exist" do
103
- Tmdb.expects(:api_call).with("person", {id: "999999999999"}, nil).returns(nil)
103
+ Tmdb.expects(:api_call).with("person", {:id => "999999999999"}, nil).returns(nil)
104
104
  assert_raise ArgumentError do
105
105
  TmdbCast.new({"id" => 999999999999}, true)
106
106
  end
@@ -109,7 +109,7 @@ class TmdbCastTest < Test::Unit::TestCase
109
109
  private
110
110
 
111
111
  def assert_cast_methodized(actor, cast_id)
112
- @cast_data = Tmdb.api_call("person", {id: cast_id.to_s}, Tmdb.default_language)
112
+ @cast_data = Tmdb.api_call("person", {:id => cast_id.to_s}, Tmdb.default_language)
113
113
  assert_equal @cast_data["adult"], actor.adult
114
114
  assert_equal @cast_data["also_known_as"], actor.also_known_as
115
115
  assert_equal @cast_data["biography"], actor.biography
@@ -93,22 +93,22 @@ class TmdbMovieTest < Test::Unit::TestCase
93
93
  end
94
94
 
95
95
  test "find should pass default language to Tmdb.api_call if language is not supplied" do
96
- Tmdb.expects(:api_call).with("movie", {id: "1"}, Tmdb.default_language).twice
97
- Tmdb.expects(:api_call).with("search/movie", {query: "1"}, Tmdb.default_language)
96
+ Tmdb.expects(:api_call).with("movie", {:id => "1"}, Tmdb.default_language).twice
97
+ Tmdb.expects(:api_call).with("search/movie", {:query => "1"}, Tmdb.default_language)
98
98
  TmdbMovie.find(:id => 1, :imdb => 1, :title => 1)
99
99
  end
100
100
 
101
101
  test "find should pass through language to Tmdb.api_call when language is supplied" do
102
- Tmdb.expects(:api_call).with("movie", {id: "1"}, "foo").twice
103
- Tmdb.expects(:api_call).with("search/movie", {query: "1"}, "foo")
102
+ Tmdb.expects(:api_call).with("movie", {:id => "1"}, "foo").twice
103
+ Tmdb.expects(:api_call).with("search/movie", {:query => "1"}, "foo")
104
104
  TmdbMovie.find(:id => 1, :imdb => 1, :title => 1, :language => "foo")
105
105
  end
106
106
 
107
107
  test "TmdbMovie.new should raise error if supplied with raw data for movie that doesn't exist" do
108
- Tmdb.expects(:api_call).with("movie", {id: 999999999999}, nil).returns(nil)
109
- Tmdb.expects(:api_call).with("movie/images", {id: 999999999999}, nil).returns(nil)
110
- Tmdb.expects(:api_call).with("movie/releases", {id: 999999999999}, nil).returns(nil)
111
- Tmdb.expects(:api_call).with("movie/casts", {id: 999999999999}, nil).returns(nil)
108
+ Tmdb.expects(:api_call).with("movie", {:id => 999999999999}, nil).returns(nil)
109
+ Tmdb.expects(:api_call).with("movie/images", {:id => 999999999999}, nil).returns(nil)
110
+ Tmdb.expects(:api_call).with("movie/releases", {:id => 999999999999}, nil).returns(nil)
111
+ Tmdb.expects(:api_call).with("movie/casts", {:id => 999999999999}, nil).returns(nil)
112
112
  assert_raise ArgumentError do
113
113
  TmdbMovie.new({"id" => 999999999999}, true)
114
114
  end
@@ -117,7 +117,7 @@ class TmdbMovieTest < Test::Unit::TestCase
117
117
  private
118
118
 
119
119
  def assert_movie_methodized(movie, movie_id)
120
- @movie_data = Tmdb.api_call("movie", {id: movie_id.to_s}, Tmdb.default_language)
120
+ @movie_data = Tmdb.api_call("movie", {:id => movie_id.to_s}, Tmdb.default_language)
121
121
  assert_equal @movie_data["adult"], movie.adult
122
122
  assert_equal @movie_data["budget"], movie.budget
123
123
  assert_equal @movie_data["homepage"], movie.homepage
@@ -51,7 +51,7 @@ class TmdbTest < Test::Unit::TestCase
51
51
  url = Tmdb.base_api_url + '/' + method + "?api_key=" + Tmdb.api_key + "&language=" + language + '&query=' + CGI::escape(data.to_s)
52
52
  mock_response = stub(:code => "200", :body => '{"page":1,"results":[],"total_pages":0,"total_results":0}')
53
53
  Tmdb.expects(:get_url).with(url).returns(mock_response)
54
- Tmdb.api_call(method, {query: data}, language)
54
+ Tmdb.api_call(method, {:query => data}, language)
55
55
  end
56
56
 
57
57
  test "api_call should raise exception if api_key is not set" do
@@ -64,7 +64,7 @@ class TmdbTest < Test::Unit::TestCase
64
64
  end
65
65
 
66
66
  test "should perform search/movie API call and return a Hash with an array of results" do
67
- movies = Tmdb.api_call("search/movie", {query: "Transformers"})
67
+ movies = Tmdb.api_call("search/movie", {:query => "Transformers"})
68
68
  assert_kind_of Hash, movies
69
69
  assert_kind_of Array, movies["results"]
70
70
  movies["results"].each do |movie|
@@ -76,7 +76,7 @@ class TmdbTest < Test::Unit::TestCase
76
76
  end
77
77
 
78
78
  test "should perform movie API call and return a single result" do
79
- result = Tmdb.api_call("movie", {id: "187"})
79
+ result = Tmdb.api_call("movie", {:id => "187"})
80
80
  assert_kind_of Hash, result
81
81
  %w(original_title id).each do |item|
82
82
  assert_not_nil result[item]
@@ -84,7 +84,7 @@ class TmdbTest < Test::Unit::TestCase
84
84
  end
85
85
 
86
86
  test "should perform movie API call with an action and return a single result" do
87
- result = Tmdb.api_call("movie/images", {id: "187"})
87
+ result = Tmdb.api_call("movie/images", {:id => "187"})
88
88
  assert_kind_of Hash, result
89
89
  %w(posters id).each do |item|
90
90
  assert_not_nil result[item]
@@ -92,7 +92,7 @@ class TmdbTest < Test::Unit::TestCase
92
92
  end
93
93
 
94
94
  test "should perform Movie.imdbLookup API call and return a single result" do
95
- result = Tmdb.api_call("movie", {id: "tt0401792"})
95
+ result = Tmdb.api_call("movie", {:id => "tt0401792"})
96
96
  assert_kind_of Hash, result
97
97
  %w(original_title id).each do |item|
98
98
  assert result[item]
@@ -100,7 +100,7 @@ class TmdbTest < Test::Unit::TestCase
100
100
  end
101
101
 
102
102
  test "should perform person API call and return a single result" do
103
- result = Tmdb.api_call("person", {id: 287})
103
+ result = Tmdb.api_call("person", {:id => 287})
104
104
  assert_kind_of Hash, result
105
105
  %w(homepage id name).each do |item|
106
106
  assert_not_nil result[item]
@@ -108,7 +108,7 @@ class TmdbTest < Test::Unit::TestCase
108
108
  end
109
109
 
110
110
  test "should perform search/person API call and return a Hash with an array of results" do
111
- people = Tmdb.api_call("search/person", {query: "vince"})
111
+ people = Tmdb.api_call("search/person", {:query => "vince"})
112
112
  assert_kind_of Array, people["results"]
113
113
  people["results"].each do |person|
114
114
  assert_kind_of Hash, person
@@ -125,15 +125,15 @@ class TmdbTest < Test::Unit::TestCase
125
125
  end
126
126
 
127
127
  test "API call that finds no results should return nil" do
128
- movies = Tmdb.api_call('search/movie', {query: "item_not_found"})
128
+ movies = Tmdb.api_call('search/movie', {:query => "item_not_found"})
129
129
  assert_nil movies
130
130
  end
131
131
 
132
132
  test "API call cache should not be changed when data altered in the receiving method" do
133
- person = Tmdb.api_call("person", {id: 287})
133
+ person = Tmdb.api_call("person", {:id => 287})
134
134
  assert_not_nil person[person.keys[0]]
135
135
  person[person.keys[0]] = nil
136
- person = Tmdb.api_call("person", {id: 287})
136
+ person = Tmdb.api_call("person", {:id => 287})
137
137
  assert_not_nil person[person.keys[0]]
138
138
  end
139
139
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-tmdb3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-20 00:00:00.000000000 Z
13
+ date: 2012-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: deepopenstruct