tmdb-api 0.0.2 → 0.0.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -20
  3. data/lib/{tmdb.rb → tmdb-api.rb} +6 -5
  4. data/lib/tmdb-api/base.rb +43 -0
  5. data/lib/tmdb-api/changes.rb +21 -0
  6. data/lib/tmdb-api/httparty.rb +10 -0
  7. data/lib/{tmdb → tmdb-api}/movie.rb +35 -39
  8. data/lib/{tmdb → tmdb-api}/searchable.rb +12 -10
  9. data/lib/tmdb-api/version.rb +3 -0
  10. data/spec/fixtures/changes/{movie_changes.json → movies.json} +0 -0
  11. data/spec/fixtures/{alternative_titles.json → movie/alternative_titles.json} +0 -0
  12. data/spec/fixtures/{find_movie_by_id.json → movie/find.json} +0 -0
  13. data/spec/fixtures/{movie_images.json → movie/images.json} +0 -0
  14. data/spec/fixtures/{movie_keywords.json → movie/keywords.json} +0 -0
  15. data/spec/fixtures/{movie_releases.json → movie/releases.json} +0 -0
  16. data/spec/spec_helper.rb +1 -1
  17. data/spec/tmdb-api/change_spec.rb +26 -0
  18. data/spec/tmdb-api/movie_spec.rb +312 -0
  19. data/spec/tmdb-api/searchable_spec.rb +33 -0
  20. data/spec/{tmdb → tmdb-api}/tmdb_spec.rb +0 -0
  21. data/{tmdb.gemspec → tmdb-api.gemspec} +4 -4
  22. metadata +34 -58
  23. data/lib/tmdb/changes.rb +0 -22
  24. data/lib/tmdb/fetcher.rb +0 -30
  25. data/lib/tmdb/version.rb +0 -3
  26. data/spec/fixtures/alternative_titles_by_country.json +0 -9
  27. data/spec/fixtures/changes/movie_changes_page_2.json +0 -407
  28. data/spec/fixtures/changes/movie_changes_start_date.json +0 -407
  29. data/spec/fixtures/find_movie.json +0 -19
  30. data/spec/fixtures/find_movie_by_id_and_language.json +0 -66
  31. data/spec/fixtures/invalid_id.json +0 -4
  32. data/spec/fixtures/movie/upcoming_page_2.json +0 -251
  33. data/spec/fixtures/movie_images_by_language.json +0 -42
  34. data/spec/fixtures/no_results.json +0 -6
  35. data/spec/fixtures/search_movie_by_name_and_adult_filter.json +0 -55
  36. data/spec/fixtures/search_movie_by_name_and_page.json +0 -247
  37. data/spec/fixtures/search_movie_by_name_and_year.json +0 -19
  38. data/spec/tmdb/changes_spec.rb +0 -52
  39. data/spec/tmdb/movie/upcoming_spec.rb +0 -28
  40. data/spec/tmdb/movie_spec.rb +0 -473
  41. data/spec/tmdb/searchable_spec.rb +0 -9
@@ -1,4 +1,4 @@
1
- require 'tmdb'
1
+ require 'tmdb-api'
2
2
  require 'rspec'
3
3
  require 'webmock/rspec'
4
4
 
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDb::Changes do
4
+ describe '.movies' do
5
+ it 'returns the changed movies' do
6
+ stub_get('/movie/changes').to_return(json_response('changes/movies.json'))
7
+
8
+ changes = TMDb::Changes.movies
9
+
10
+ expect(changes['results']).to have(100).items
11
+ expect(changes['total_results']).to eql(4645)
12
+ expect(changes['total_pages']).to eql(47)
13
+ expect(changes['page']).to eql(1)
14
+ expect(changes['results'].first).to eql({
15
+ 'id' => 128149,
16
+ 'adult' => false
17
+ })
18
+ end
19
+
20
+ it 'raises with a bad request' do
21
+ stub_get('/movie/changes').to_return(status: 404)
22
+
23
+ expect { TMDb::Changes.movies }.to raise_error ArgumentError
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,312 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDb::Movie do
4
+ describe '.find' do
5
+ it 'find a movie given your ID' do
6
+ stub_get('/movie/24').to_return(json_response('movie/find.json'))
7
+
8
+ movie = TMDb::Movie.find(24)
9
+
10
+ expect(movie.adult).to eq(false)
11
+ expect(movie.backdrop_path).to eq('/hSaH9tt67bozo9K50sbH0s4YjEc.jpg')
12
+ expect(movie.belongs_to_collection).to eq(nil)
13
+ expect(movie.budget).to eq(3300000)
14
+ expect(movie.genres).to eq([
15
+ {
16
+ 'id' => 28,
17
+ 'name' => 'Action'
18
+ },
19
+ {
20
+ 'id' => 80,
21
+ 'name' => 'Crime'
22
+ },
23
+ {
24
+ 'id' => 18,
25
+ 'name' => 'Drama'
26
+ },
27
+ {
28
+ 'id' => 10769,
29
+ 'name' => 'Foreign'
30
+ }
31
+ ])
32
+ expect(movie.homepage).to eq('http://cidadededeus.globo.com/')
33
+ expect(movie.id).to eq(598)
34
+ expect(movie.imdb_id).to eq('tt0317248')
35
+ expect(movie.original_title).to eq('Cidade de Deus')
36
+ expect(movie.overview).to eq('City of God depicts the raw violence in the ghettos of Rio de Janeiro. In the 1970’s that kids are carrying guns and joining gangs when they should be playing hide-and-seek.')
37
+ expect(movie.popularity).to eq(1.3497251049225558)
38
+ expect(movie.poster_path).to eq('/mwDnSQR1CkxuDjSKfgiNT0sIOjM.jpg')
39
+ expect(movie.production_companies).to eq([
40
+ {
41
+ 'name' => 'O2 Filmes',
42
+ 'id' => 345
43
+ },
44
+ {
45
+ 'name' => 'VideoFilmes',
46
+ 'id' => 346
47
+ },
48
+ {
49
+ 'name' => 'Globo filmes',
50
+ 'id' => 10954
51
+ },
52
+ {
53
+ 'name' => 'Lumiere',
54
+ 'id' => 11444
55
+ },
56
+ {
57
+ 'name' => 'Wild Bunch',
58
+ 'id' => 856
59
+ },
60
+ {
61
+ 'name' => 'Hank Levine Film',
62
+ 'id' => 11445
63
+ },
64
+ {
65
+ 'name' => 'Lereby Productions',
66
+ 'id' => 11446
67
+ }
68
+ ])
69
+ expect(movie.production_countries).to eq([
70
+ {
71
+ 'iso_3166_1' => 'BR',
72
+ 'name' => 'Brazil'
73
+ },
74
+ {
75
+ 'iso_3166_1' => 'FR',
76
+ 'name' => 'France'
77
+ }
78
+ ])
79
+ expect(movie.release_date).to eq('2002-08-31')
80
+ expect(movie.revenue).to eq(27387381)
81
+ expect(movie.runtime).to eq(130)
82
+ expect(movie.spoken_languages).to eq([
83
+ {
84
+ 'iso_639_1' => 'pt',
85
+ 'name' => 'Português'
86
+ }
87
+ ])
88
+ expect(movie.status).to eq('Released')
89
+ expect(movie.tagline).to eq('If you run you\'re dead...if you stay, you\'re dead again. Period.')
90
+ expect(movie.title).to eq('City of God')
91
+ expect(movie.vote_average).to eq(8.2)
92
+ expect(movie.vote_count).to eq(52)
93
+ end
94
+
95
+ it 'raises with a bad request' do
96
+ stub_get('/movie/1234').to_return(status: 404)
97
+
98
+ expect { TMDb::Movie.find(1234) }.to raise_error(ArgumentError)
99
+ end
100
+ end
101
+
102
+ describe '.alternative_titles' do
103
+ it 'returns the alternative titles for a specific movie' do
104
+ stub_get('/movie/598/alternative_titles')
105
+ .to_return(json_response('movie/alternative_titles.json'))
106
+
107
+ alternative_titles = TMDb::Movie.alternative_titles(598)
108
+
109
+ expect(alternative_titles).to match_array([
110
+ {
111
+ 'iso_3166_1' => 'RU',
112
+ 'title' => 'Город бога'
113
+ },
114
+ {
115
+ 'iso_3166_1' => 'IT',
116
+ 'title' => 'City of God - La città di Dio'
117
+ },
118
+ {
119
+ 'iso_3166_1' => 'BR',
120
+ 'title' => 'Cidade de Deus'
121
+ },
122
+ {
123
+ 'iso_3166_1' => 'FR',
124
+ 'title' => 'La cité de Dieu'
125
+ },
126
+ {
127
+ 'iso_3166_1' => 'DE',
128
+ 'title' => 'City of God'
129
+ },
130
+ {
131
+ 'iso_3166_1' => 'CN',
132
+ 'title' => '上帝之城'
133
+ },
134
+ {
135
+ 'iso_3166_1' => 'HK',
136
+ 'title' => '无主之城'
137
+ },
138
+ {
139
+ 'iso_3166_1' => 'US',
140
+ 'title' => 'City of God'
141
+ },
142
+ {
143
+ 'iso_3166_1' => 'TW',
144
+ 'title' => '無法無天'
145
+ }
146
+ ])
147
+ end
148
+
149
+ it 'raises with a bad request' do
150
+ stub_get('/movie/invalid-id/alternative_titles').to_return(status: 404)
151
+
152
+ expect { TMDb::Movie.alternative_titles('invalid-id') }
153
+ .to raise_error ArgumentError
154
+ end
155
+ end
156
+
157
+ describe '.images' do
158
+ it 'returns the images (posters and backdrops) for a specific movie ID' do
159
+ stub_get('/movie/598/images')
160
+ .to_return(json_response('movie/images.json'))
161
+
162
+ images = TMDb::Movie.images(598)
163
+
164
+ expect(images['backdrops']).to have(7).items
165
+ expect(images['posters']).to have(16).items
166
+
167
+ expect(images['backdrops'].first).to eq(
168
+ {
169
+ "file_path" => "/hSaH9tt67bozo9K50sbH0s4YjEc.jpg",
170
+ "width" => 1532,
171
+ "height" => 862,
172
+ "iso_639_1" => nil,
173
+ "aspect_ratio" => 1.78,
174
+ "vote_average" => 5.4421768707483,
175
+ "vote_count" => 7
176
+ }
177
+ )
178
+
179
+ expect(images['posters'].first).to eq(
180
+ {
181
+ "file_path" => "/mwDnSQR1CkxuDjSKfgiNT0sIOjM.jpg",
182
+ "width" => 1000,
183
+ "height" => 1500,
184
+ "iso_639_1" => "en",
185
+ "aspect_ratio" => 0.67,
186
+ "vote_average" => 5.384615384615385,
187
+ "vote_count" => 2
188
+ }
189
+ )
190
+ end
191
+
192
+ it 'raises with a bad request' do
193
+ stub_get('/movie/598/images').to_return(status: 404)
194
+
195
+ expect { TMDb::Movie.images(598) }.to raise_error ArgumentError
196
+ end
197
+ end
198
+
199
+ describe '.keywords' do
200
+ it 'return the plot keywords for a specific movie id' do
201
+ stub_get('/movie/598/keywords').to_return(json_response('movie/keywords.json'))
202
+
203
+ keywords = TMDb::Movie.keywords(598)
204
+
205
+ expect(keywords).to have(7).items
206
+
207
+ expect(keywords).to match_array([
208
+ {
209
+ "id" => 542,
210
+ "name" => "street gang"
211
+ },
212
+ {
213
+ "id" => 983,
214
+ "name" => "brazilian"
215
+ },
216
+ {
217
+ "id" => 1228,
218
+ "name" => "seventies"
219
+ },
220
+ {
221
+ "id" => 1525,
222
+ "name" => "puberty"
223
+ },
224
+ {
225
+ "id" => 1687,
226
+ "name" => "80s"
227
+ },
228
+ {
229
+ "id" => 2394,
230
+ "name" => "ghetto"
231
+ },
232
+ {
233
+ "id" => 2987,
234
+ "name" => "gang war"
235
+ }
236
+ ])
237
+ end
238
+
239
+ it 'raises with a bad request' do
240
+ stub_get('/movie/598/keywords').to_return(status: 404)
241
+
242
+ expect { TMDb::Movie.keywords(598) }.to raise_error ArgumentError
243
+ end
244
+ end
245
+
246
+ describe '.releases' do
247
+ it 'returns the release for a specific movie' do
248
+ stub_get('/movie/598/releases').to_return(json_response('movie/releases.json'))
249
+
250
+ releases = TMDb::Movie.releases(598)
251
+
252
+ expect(releases).to have(6).items
253
+
254
+ expect(releases).to match_array([
255
+ {
256
+ "iso_3166_1" => "RU",
257
+ "certification" => "",
258
+ "release_date" => "2002-02-05"
259
+ },
260
+ {
261
+ "iso_3166_1" => "US",
262
+ "certification" => "R",
263
+ "release_date" => "2002-08-31"
264
+ },
265
+ {
266
+ "iso_3166_1" => "BR",
267
+ "certification" => "",
268
+ "release_date" => "2002-08-30"
269
+ },
270
+ {
271
+ "iso_3166_1" => "CA",
272
+ "certification" => "",
273
+ "release_date" => "2002-09-06"
274
+ },
275
+ {
276
+ "iso_3166_1" => "GB",
277
+ "certification" => "18",
278
+ "release_date" => "2002-11-08"
279
+ },
280
+ {
281
+ "iso_3166_1" => "DE",
282
+ "certification" => "16",
283
+ "release_date" => "2003-05-08"
284
+ }
285
+ ])
286
+ end
287
+
288
+ it 'raises with a bad request' do
289
+ stub_get('/movie/598/releases').to_return(status: 404)
290
+
291
+ expect { TMDb::Movie.releases(598) }.to raise_error ArgumentError
292
+ end
293
+ end
294
+
295
+ describe '.upcoming' do
296
+ it 'returns the upcoming movies' do
297
+ stub_get('/movie/upcoming').to_return(json_response('movie/upcoming.json'))
298
+
299
+ upcoming = TMDb::Movie.upcoming
300
+
301
+ expect(upcoming).to have(20).movies
302
+ expect(upcoming.first.id).to eql(68726)
303
+ expect(upcoming.first.title).to eql('Pacific Rim')
304
+ end
305
+
306
+ it 'raises with a bad request' do
307
+ stub_get('/movie/upcoming').to_return(status: 404)
308
+
309
+ expect { TMDb::Movie.upcoming }.to raise_error ArgumentError
310
+ end
311
+ end
312
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDb::Searchable do
4
+ describe ".search" do
5
+ it "searches movies given only the movie name" do
6
+ stub_get('/search/movie').with(query: { query: 'The Lord of the Rings' })
7
+ .to_return(json_response('search_movie_by_name.json'))
8
+
9
+ movies = TMDb::Movie.search("The Lord of the Rings")
10
+
11
+ expect(movies).to have(7).items
12
+
13
+ expect(movies.first.adult).to eq(false)
14
+ expect(movies.first.backdrop_path).to eq("/pIUvQ9Ed35wlWhY2oU6OmwEsmzG.jpg")
15
+ expect(movies.first.id).to eq(120)
16
+ expect(movies.first.original_title).to eq("The Lord of the Rings: The Fellowship of the Ring")
17
+ expect(movies.first.release_date).to eq("2001-12-19")
18
+ expect(movies.first.poster_path).to eq("/9HG6pINW1KoFTAKY3LdybkoOKAm.jpg")
19
+ expect(movies.first.popularity).to eq(10.895025450078979)
20
+ expect(movies.first.title).to eq("The Lord of the Rings: The Fellowship of the Ring")
21
+ expect(movies.first.vote_average).to eq(8.3)
22
+ expect(movies.first.vote_count).to eq(187)
23
+ end
24
+
25
+ it 'raises with a bad request' do
26
+ stub_get('/search/movie').with(query: { query: 'Iron Man' })
27
+ .to_return(status: 404)
28
+
29
+ expect { TMDb::Movie.search("Iron Man") }.to raise_error ArgumentError
30
+ end
31
+ end
32
+ end
33
+
File without changes
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'tmdb/version'
4
+ require 'tmdb-api/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "tmdb-api"
8
8
  spec.version = TMDb::VERSION
9
9
  spec.authors = ["Andriel Nuernberg"]
10
10
  spec.email = ["andrielfn@gmail.com"]
11
- spec.description = "The Movie Database API"
12
- spec.summary = "The Mobie Database API"
13
- spec.homepage = ""
11
+ spec.description = "The Movie Database API v3"
12
+ spec.summary = "The Mobie Database API v3"
13
+ spec.homepage = "https://github.com/andrielfn/tmdb-api"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmdb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andriel Nuernberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-06 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: The Movie Database API
97
+ description: The Movie Database API v3
98
98
  email:
99
99
  - andrielfn@gmail.com
100
100
  executables: []
@@ -107,41 +107,29 @@ files:
107
107
  - LICENSE.txt
108
108
  - README.md
109
109
  - Rakefile
110
- - lib/tmdb.rb
111
- - lib/tmdb/changes.rb
112
- - lib/tmdb/fetcher.rb
113
- - lib/tmdb/movie.rb
114
- - lib/tmdb/searchable.rb
115
- - lib/tmdb/version.rb
116
- - spec/fixtures/alternative_titles.json
117
- - spec/fixtures/alternative_titles_by_country.json
118
- - spec/fixtures/changes/movie_changes.json
119
- - spec/fixtures/changes/movie_changes_page_2.json
120
- - spec/fixtures/changes/movie_changes_start_date.json
121
- - spec/fixtures/find_movie.json
122
- - spec/fixtures/find_movie_by_id.json
123
- - spec/fixtures/find_movie_by_id_and_language.json
124
- - spec/fixtures/invalid_id.json
110
+ - lib/tmdb-api.rb
111
+ - lib/tmdb-api/base.rb
112
+ - lib/tmdb-api/changes.rb
113
+ - lib/tmdb-api/httparty.rb
114
+ - lib/tmdb-api/movie.rb
115
+ - lib/tmdb-api/searchable.rb
116
+ - lib/tmdb-api/version.rb
117
+ - spec/fixtures/changes/movies.json
118
+ - spec/fixtures/movie/alternative_titles.json
119
+ - spec/fixtures/movie/find.json
120
+ - spec/fixtures/movie/images.json
121
+ - spec/fixtures/movie/keywords.json
122
+ - spec/fixtures/movie/releases.json
125
123
  - spec/fixtures/movie/upcoming.json
126
- - spec/fixtures/movie/upcoming_page_2.json
127
- - spec/fixtures/movie_images.json
128
- - spec/fixtures/movie_images_by_language.json
129
- - spec/fixtures/movie_keywords.json
130
- - spec/fixtures/movie_releases.json
131
- - spec/fixtures/no_results.json
132
124
  - spec/fixtures/search_movie_by_name.json
133
- - spec/fixtures/search_movie_by_name_and_adult_filter.json
134
- - spec/fixtures/search_movie_by_name_and_page.json
135
- - spec/fixtures/search_movie_by_name_and_year.json
136
125
  - spec/spec_helper.rb
137
126
  - spec/support/stubber.rb
138
- - spec/tmdb/changes_spec.rb
139
- - spec/tmdb/movie/upcoming_spec.rb
140
- - spec/tmdb/movie_spec.rb
141
- - spec/tmdb/searchable_spec.rb
142
- - spec/tmdb/tmdb_spec.rb
143
- - tmdb.gemspec
144
- homepage: ''
127
+ - spec/tmdb-api/change_spec.rb
128
+ - spec/tmdb-api/movie_spec.rb
129
+ - spec/tmdb-api/searchable_spec.rb
130
+ - spec/tmdb-api/tmdb_spec.rb
131
+ - tmdb-api.gemspec
132
+ homepage: https://github.com/andrielfn/tmdb-api
145
133
  licenses:
146
134
  - MIT
147
135
  metadata: {}
@@ -164,32 +152,20 @@ rubyforge_project:
164
152
  rubygems_version: 2.0.2
165
153
  signing_key:
166
154
  specification_version: 4
167
- summary: The Mobie Database API
155
+ summary: The Mobie Database API v3
168
156
  test_files:
169
- - spec/fixtures/alternative_titles.json
170
- - spec/fixtures/alternative_titles_by_country.json
171
- - spec/fixtures/changes/movie_changes.json
172
- - spec/fixtures/changes/movie_changes_page_2.json
173
- - spec/fixtures/changes/movie_changes_start_date.json
174
- - spec/fixtures/find_movie.json
175
- - spec/fixtures/find_movie_by_id.json
176
- - spec/fixtures/find_movie_by_id_and_language.json
177
- - spec/fixtures/invalid_id.json
157
+ - spec/fixtures/changes/movies.json
158
+ - spec/fixtures/movie/alternative_titles.json
159
+ - spec/fixtures/movie/find.json
160
+ - spec/fixtures/movie/images.json
161
+ - spec/fixtures/movie/keywords.json
162
+ - spec/fixtures/movie/releases.json
178
163
  - spec/fixtures/movie/upcoming.json
179
- - spec/fixtures/movie/upcoming_page_2.json
180
- - spec/fixtures/movie_images.json
181
- - spec/fixtures/movie_images_by_language.json
182
- - spec/fixtures/movie_keywords.json
183
- - spec/fixtures/movie_releases.json
184
- - spec/fixtures/no_results.json
185
164
  - spec/fixtures/search_movie_by_name.json
186
- - spec/fixtures/search_movie_by_name_and_adult_filter.json
187
- - spec/fixtures/search_movie_by_name_and_page.json
188
- - spec/fixtures/search_movie_by_name_and_year.json
189
165
  - spec/spec_helper.rb
190
166
  - spec/support/stubber.rb
191
- - spec/tmdb/changes_spec.rb
192
- - spec/tmdb/movie/upcoming_spec.rb
193
- - spec/tmdb/movie_spec.rb
194
- - spec/tmdb/searchable_spec.rb
195
- - spec/tmdb/tmdb_spec.rb
167
+ - spec/tmdb-api/change_spec.rb
168
+ - spec/tmdb-api/movie_spec.rb
169
+ - spec/tmdb-api/searchable_spec.rb
170
+ - spec/tmdb-api/tmdb_spec.rb
171
+ has_rdoc: