tmdb_party 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -39,6 +39,8 @@ It's a movie database, kind of like IMDB except it's more of a community wiki. T
39
39
  == Contributors
40
40
  Jon Maddox (http://github.com/maddox)
41
41
  Magnus Bergmark (http://github.com/Mange)
42
+ Brian Lopez (https://github.com/brianmario)
43
+ Federico Ravasio (https://github.com/razielgn)
42
44
 
43
45
  == Copyright
44
46
 
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
+ :major: 0
3
+ :minor: 8
2
4
  :patch: 0
3
5
  :build:
4
- :major: 0
5
- :minor: 7
data/lib/tmdb_party.rb CHANGED
@@ -15,11 +15,11 @@ module TMDBParty
15
15
 
16
16
  def initialize(key, lang = 'en')
17
17
  @api_key = key
18
- @lang = lang
18
+ @default_lang = lang
19
19
  end
20
20
 
21
- def search(query)
22
- data = self.class.get(method_url('Movie.search', query)).parsed_response
21
+ def search(query, lang = @default_lang)
22
+ data = self.class.get(method_url('Movie.search', query, lang)).parsed_response
23
23
  if data.class != Array || data.first == "Nothing found."
24
24
  []
25
25
  else
@@ -27,8 +27,8 @@ module TMDBParty
27
27
  end
28
28
  end
29
29
 
30
- def search_person(query)
31
- data = self.class.get(method_url('Person.search', query)).parsed_response
30
+ def search_person(query, lang = @default_lang)
31
+ data = self.class.get(method_url('Person.search', query, lang)).parsed_response
32
32
  if data.class != Array || data.first == "Nothing found."
33
33
  []
34
34
  else
@@ -36,8 +36,8 @@ module TMDBParty
36
36
  end
37
37
  end
38
38
 
39
- def imdb_lookup(imdb_id)
40
- data = self.class.get(method_url('Movie.imdbLookup', imdb_id)).parsed_response
39
+ def imdb_lookup(imdb_id, lang = @default_lang)
40
+ data = self.class.get(method_url('Movie.imdbLookup', imdb_id, lang)).parsed_response
41
41
  if data.class != Array || data.first == "Nothing found."
42
42
  nil
43
43
  else
@@ -45,23 +45,30 @@ module TMDBParty
45
45
  end
46
46
  end
47
47
 
48
- def get_info(id)
49
- data = self.class.get(method_url('Movie.getInfo', id)).parsed_response
48
+ def get_info(id, lang = @default_lang)
49
+ data = self.class.get(method_url('Movie.getInfo', id, lang)).parsed_response
50
50
  Movie.new(data.first, self)
51
51
  end
52
52
 
53
- def get_person(id)
54
- data = self.class.get(method_url('Person.getInfo', id)).parsed_response
53
+ def get_person(id, lang = @default_lang)
54
+ data = self.class.get(method_url('Person.getInfo', id, lang)).parsed_response
55
55
  Person.new(data.first, self)
56
56
  end
57
57
 
58
+ def get_genres(lang = @default_lang)
59
+ data = self.class.get(method_url('Genres.getList', nil, lang)).parsed_response
60
+ data[1..-1].collect { |genre| Genre.new(genre) } # Skips the first, see spec/fixtures/genres_results.json
61
+ end
62
+
58
63
  private
59
64
  def default_path_items
60
- [@lang, 'json', @api_key]
65
+ ['json', @api_key]
61
66
  end
62
67
 
63
- def method_url(method, value)
64
- '/' + ([method] + default_path_items + [URI.escape(value.to_s)]).join('/')
68
+ def method_url(method, value, lang)
69
+ url = [method, lang, default_path_items]
70
+ url << URI.escape(value.to_s) if value
71
+ '/' + url.join('/')
65
72
  end
66
73
  end
67
74
  end
@@ -1,6 +1,7 @@
1
1
  module TMDBParty
2
2
  class Genre
3
3
  include Attributes
4
+ attributes :id, :type => Integer
4
5
  attributes :name, :url
5
6
 
6
7
  def initialize(values)
@@ -0,0 +1,168 @@
1
+ [{
2
+ "translated": true
3
+ },
4
+ {
5
+ "name": "Action",
6
+ "id": 28,
7
+ "url": "http://www.themoviedb.org/genre/action"
8
+ },
9
+ {
10
+ "name": "Adventure",
11
+ "id": 12,
12
+ "url": "http://www.themoviedb.org/genre/adventure"
13
+ },
14
+ {
15
+ "name": "Animation",
16
+ "id": 16,
17
+ "url": "http://www.themoviedb.org/genre/animation"
18
+ },
19
+ {
20
+ "name": "Comedy",
21
+ "id": 35,
22
+ "url": "http://www.themoviedb.org/genre/comedy"
23
+ },
24
+ {
25
+ "name": "Crime",
26
+ "id": 80,
27
+ "url": "http://www.themoviedb.org/genre/crime"
28
+ },
29
+ {
30
+ "name": "Disaster",
31
+ "id": 105,
32
+ "url": "http://www.themoviedb.org/genre/disaster"
33
+ },
34
+ {
35
+ "name": "Documentary",
36
+ "id": 99,
37
+ "url": "http://www.themoviedb.org/genre/documentary"
38
+ },
39
+ {
40
+ "name": "Drama",
41
+ "id": 18,
42
+ "url": "http://www.themoviedb.org/genre/drama"
43
+ },
44
+ {
45
+ "name": "Eastern",
46
+ "id": 82,
47
+ "url": "http://www.themoviedb.org/genre/eastern"
48
+ },
49
+ {
50
+ "name": "Erotic",
51
+ "id": 2916,
52
+ "url": "http://www.themoviedb.org/genre/erotic"
53
+ },
54
+ {
55
+ "name": "Family",
56
+ "id": 10751,
57
+ "url": "http://www.themoviedb.org/genre/family"
58
+ },
59
+ {
60
+ "name": "Fan Film",
61
+ "id": 10750,
62
+ "url": "http://www.themoviedb.org/genre/fan-film"
63
+ },
64
+ {
65
+ "name": "Fantasy",
66
+ "id": 14,
67
+ "url": "http://www.themoviedb.org/genre/fantasy"
68
+ },
69
+ {
70
+ "name": "Film Noir",
71
+ "id": 10753,
72
+ "url": "http://www.themoviedb.org/genre/film-noir"
73
+ },
74
+ {
75
+ "name": "History",
76
+ "id": 36,
77
+ "url": "http://www.themoviedb.org/genre/history"
78
+ },
79
+ {
80
+ "name": "Holiday",
81
+ "id": 10595,
82
+ "url": "http://www.themoviedb.org/genre/holiday"
83
+ },
84
+ {
85
+ "name": "Horror",
86
+ "id": 27,
87
+ "url": "http://www.themoviedb.org/genre/horror"
88
+ },
89
+ {
90
+ "name": "Indie",
91
+ "id": 10756,
92
+ "url": "http://www.themoviedb.org/genre/indie"
93
+ },
94
+ {
95
+ "name": "Music",
96
+ "id": 10402,
97
+ "url": "http://www.themoviedb.org/genre/music"
98
+ },
99
+ {
100
+ "name": "Musical",
101
+ "id": 22,
102
+ "url": "http://www.themoviedb.org/genre/musical"
103
+ },
104
+ {
105
+ "name": "Mystery",
106
+ "id": 9648,
107
+ "url": "http://www.themoviedb.org/genre/mystery"
108
+ },
109
+ {
110
+ "name": "Neo-noir",
111
+ "id": 10754,
112
+ "url": "http://www.themoviedb.org/genre/neo-noir"
113
+ },
114
+ {
115
+ "name": "Road Movie",
116
+ "id": 1115,
117
+ "url": "http://www.themoviedb.org/genre/road-movie"
118
+ },
119
+ {
120
+ "name": "Romance",
121
+ "id": 10749,
122
+ "url": "http://www.themoviedb.org/genre/romance"
123
+ },
124
+ {
125
+ "name": "Science Fiction",
126
+ "id": 878,
127
+ "url": "http://www.themoviedb.org/genre/science-fiction"
128
+ },
129
+ {
130
+ "name": "Short",
131
+ "id": 10755,
132
+ "url": "http://www.themoviedb.org/genre/short"
133
+ },
134
+ {
135
+ "name": "Sport",
136
+ "id": 9805,
137
+ "url": "http://www.themoviedb.org/genre/sport"
138
+ },
139
+ {
140
+ "name": "Sporting Event",
141
+ "id": 10758,
142
+ "url": "http://www.themoviedb.org/genre/sporting-event"
143
+ },
144
+ {
145
+ "name": "Sports Film",
146
+ "id": 10757,
147
+ "url": "http://www.themoviedb.org/genre/sports-film"
148
+ },
149
+ {
150
+ "name": "Suspense",
151
+ "id": 10748,
152
+ "url": "http://www.themoviedb.org/genre/suspense"
153
+ },
154
+ {
155
+ "name": "Thriller",
156
+ "id": 53,
157
+ "url": "http://www.themoviedb.org/genre/thriller"
158
+ },
159
+ {
160
+ "name": "War",
161
+ "id": 10752,
162
+ "url": "http://www.themoviedb.org/genre/war"
163
+ },
164
+ {
165
+ "name": "Western",
166
+ "id": 37,
167
+ "url": "http://www.themoviedb.org/genre/western"
168
+ }]
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDBParty::Genre do
4
+ let :genre do
5
+ { "name" => "Action", "id" => 28, "url" => "http://www.themoviedb.org/genre/action" }
6
+ end
7
+
8
+ it "should have a name" do
9
+ TMDBParty::Genre.new(genre).name.should == 'Action'
10
+ end
11
+
12
+ it "should have a url" do
13
+ TMDBParty::Genre.new(genre).url.should == 'http://www.themoviedb.org/genre/action'
14
+ end
15
+
16
+ it "should have an id" do
17
+ TMDBParty::Genre.new(genre).id.should == 28
18
+ end
19
+
20
+ it ".parse should return an array" do
21
+ TMDBParty::Genre.parse(genre).should be_instance_of(Array)
22
+ TMDBParty::Genre.parse(genre).first.should be_instance_of(TMDBParty::Genre)
23
+ end
24
+ end
@@ -29,7 +29,7 @@ describe TMDBParty::Base do
29
29
  stub_get('/Movie.search/en/json/key/Transformers', 'shitty_shit_result.json')
30
30
  stub_get('/Movie.search/sv/json/key/Transformers', 'search.json')
31
31
 
32
- TMDBParty::Base.new('key', 'sv').search('Transformers').should have(5).movies
32
+ tmdb.search('Transformers', 'sv').should have(5).movies
33
33
  end
34
34
  end
35
35
 
@@ -48,7 +48,7 @@ describe TMDBParty::Base do
48
48
  stub_get('/Movie.imdbLookup/en/json/key/tt0418279', 'shitty_shit_result.json')
49
49
  stub_get('/Movie.imdbLookup/sv/json/key/tt0418279', 'imdb_search.json')
50
50
 
51
- TMDBParty::Base.new('key', 'sv').imdb_lookup('tt0418279').should_not be_nil
51
+ tmdb.imdb_lookup('tt0418279', 'sv').should_not be_nil
52
52
  end
53
53
  end
54
54
 
@@ -62,7 +62,7 @@ describe TMDBParty::Base do
62
62
  stub_get('/Movie.getInfo/en/json/key/1858', 'shitty_shit_result.json')
63
63
  stub_get('/Movie.getInfo/sv/json/key/1858', 'transformers.json')
64
64
 
65
- TMDBParty::Base.new('key', 'sv').get_info(1858).should_not be_nil
65
+ tmdb.get_info(1858, 'sv').should_not be_nil
66
66
  end
67
67
  end
68
68
 
@@ -82,7 +82,7 @@ describe TMDBParty::Base do
82
82
  stub_get('/Person.search/en/json/key/Megan%20Fox', 'shitty_shit_result.json')
83
83
  stub_get('/Person.search/sv/json/key/Megan%20Fox', 'search_person.json')
84
84
 
85
- TMDBParty::Base.new('key', 'sv').search_person('Megan Fox').should have(1).movie
85
+ tmdb.search_person('Megan Fox', 'sv').should have(1).movie
86
86
  end
87
87
  end
88
88
 
@@ -96,8 +96,22 @@ describe TMDBParty::Base do
96
96
  stub_get('/Person.getInfo/en/json/key/19537', 'shitty_shit_result.json')
97
97
  stub_get('/Person.getInfo/sv/json/key/19537', 'megan_fox.json')
98
98
 
99
- TMDBParty::Base.new('key', 'sv').get_person(19537).name.should == 'Megan Fox'
99
+ tmdb.get_person(19537, 'sv').name.should == 'Megan Fox'
100
100
  end
101
101
  end
102
102
 
103
+ describe "#get_genres" do
104
+ it "should return instances of Genre" do
105
+ stub_get('/Genres.getList/en/json/key', 'genres_results.json')
106
+ tmdb.get_genres.should have(33).genre
107
+ tmdb.get_genres.first.should be_instance_of(TMDBParty::Genre)
108
+ end
109
+
110
+ it "should use the preferred language" do
111
+ stub_get('/Genres.getList/en/json/key', 'shitty_shit_result.json')
112
+ stub_get('/Genres.getList/sv/json/key', 'genres_results.json')
113
+
114
+ tmdb.get_genres('sv').first.name.should == 'Action'
115
+ end
116
+ end
103
117
  end
data/tmdb_party.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tmdb_party}
8
- s.version = "0.7.0"
8
+ s.version = "0.8.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Duff", "Jon Maddox"]
12
- s.date = %q{2011-01-15}
12
+ s.date = %q{2011-01-29}
13
13
  s.email = %q{duff.john@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "lib/tmdb_party/person.rb",
35
35
  "lib/tmdb_party/studio.rb",
36
36
  "lib/tmdb_party/video.rb",
37
+ "spec/fixtures/genres_results.json",
37
38
  "spec/fixtures/imdb_no_results.json",
38
39
  "spec/fixtures/imdb_search.json",
39
40
  "spec/fixtures/megan_fox.json",
@@ -47,6 +48,7 @@ Gem::Specification.new do |s|
47
48
  "spec/fixtures/transformers.json",
48
49
  "spec/lib/tmdb_party/cast_member_spec.rb",
49
50
  "spec/lib/tmdb_party/country_spec.rb",
51
+ "spec/lib/tmdb_party/genre_spec.rb",
50
52
  "spec/lib/tmdb_party/image_spec.rb",
51
53
  "spec/lib/tmdb_party/movie_spec.rb",
52
54
  "spec/lib/tmdb_party/person_spec.rb",
@@ -64,6 +66,7 @@ Gem::Specification.new do |s|
64
66
  s.test_files = [
65
67
  "spec/lib/tmdb_party/cast_member_spec.rb",
66
68
  "spec/lib/tmdb_party/country_spec.rb",
69
+ "spec/lib/tmdb_party/genre_spec.rb",
67
70
  "spec/lib/tmdb_party/image_spec.rb",
68
71
  "spec/lib/tmdb_party/movie_spec.rb",
69
72
  "spec/lib/tmdb_party/person_spec.rb",
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmdb_party
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 7
7
+ - 8
9
8
  - 0
10
- version: 0.7.0
9
+ version: 0.8.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - John Duff
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-01-15 00:00:00 -05:00
18
+ date: 2011-01-29 00:00:00 -05:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- hash: 5
31
29
  segments:
32
30
  - 0
33
31
  - 6
@@ -43,7 +41,6 @@ dependencies:
43
41
  requirements:
44
42
  - - ">="
45
43
  - !ruby/object:Gem::Version
46
- hash: 3
47
44
  segments:
48
45
  - 0
49
46
  version: "0"
@@ -57,7 +54,6 @@ dependencies:
57
54
  requirements:
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- hash: 3
61
57
  segments:
62
58
  - 0
63
59
  version: "0"
@@ -91,6 +87,7 @@ files:
91
87
  - lib/tmdb_party/person.rb
92
88
  - lib/tmdb_party/studio.rb
93
89
  - lib/tmdb_party/video.rb
90
+ - spec/fixtures/genres_results.json
94
91
  - spec/fixtures/imdb_no_results.json
95
92
  - spec/fixtures/imdb_search.json
96
93
  - spec/fixtures/megan_fox.json
@@ -104,6 +101,7 @@ files:
104
101
  - spec/fixtures/transformers.json
105
102
  - spec/lib/tmdb_party/cast_member_spec.rb
106
103
  - spec/lib/tmdb_party/country_spec.rb
104
+ - spec/lib/tmdb_party/genre_spec.rb
107
105
  - spec/lib/tmdb_party/image_spec.rb
108
106
  - spec/lib/tmdb_party/movie_spec.rb
109
107
  - spec/lib/tmdb_party/person_spec.rb
@@ -127,7 +125,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
125
  requirements:
128
126
  - - ">="
129
127
  - !ruby/object:Gem::Version
130
- hash: 3
131
128
  segments:
132
129
  - 0
133
130
  version: "0"
@@ -136,7 +133,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
133
  requirements:
137
134
  - - ">="
138
135
  - !ruby/object:Gem::Version
139
- hash: 3
140
136
  segments:
141
137
  - 0
142
138
  version: "0"
@@ -150,6 +146,7 @@ summary: Simple ruby wrapper to themoviedb.org (http://api.themoviedb.org/2.0/do
150
146
  test_files:
151
147
  - spec/lib/tmdb_party/cast_member_spec.rb
152
148
  - spec/lib/tmdb_party/country_spec.rb
149
+ - spec/lib/tmdb_party/genre_spec.rb
153
150
  - spec/lib/tmdb_party/image_spec.rb
154
151
  - spec/lib/tmdb_party/movie_spec.rb
155
152
  - spec/lib/tmdb_party/person_spec.rb