tmdb 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 678de152342dbba606943c4f53472b9ec6c8d2dc
4
- data.tar.gz: 7edf17f383e4107622148fa4afaab0c55082b834
3
+ metadata.gz: c4fe9618ff4b7152cac2978ed46e57e79c861bdc
4
+ data.tar.gz: 00d95a2699ad05c7a4e143d81a0ae765c2b45898
5
5
  SHA512:
6
- metadata.gz: 3262141e5f7a197a3e1ca46873a3f2fdad3cf3434e27896339cb35699fbfe1f2882e3eb4f83f81d722330cddf1f6f2a3e4238720cb22104b0706a4b7d7a0e1f7
7
- data.tar.gz: fd3ecc4b4d828294af8887b8b53f941b31a08d02debc64b330ee4de35967b016022ce672c18f01c922a9b9478adfa3cff50d15bf8bafbcdc599cf94806ef1c7e
6
+ metadata.gz: 172caf23043eeee0a89f45700f9f0b4e4b0347ca0fc1e4b50080b082b770c7c576add80d595d18f30de48adf6b065a586a0d55e6272b0bde6df928aac6307f17
7
+ data.tar.gz: be36f75874a01e9134b336b693909947a32c34b82cf9225312c5eebe497cc4b291686967f3c56a92ad81754a0ead3c0468455e0ad1bd124e6d70657384cdf11b
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/tmdb.svg)](http://badge.fury.io/rb/tmdb)
4
4
 
5
- Simple ruby wrapper for _The MovieDB_ based on HTTParty
5
+ Simple ruby wrapper for _The MovieDB_ based on HTTParty (starting to transform into more of an abstraction than a wrapper: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper)
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,10 +22,12 @@ Current available:
22
22
  * ::config
23
23
  * ::genres(source)
24
24
  * [Movie](#movies)
25
- * ::title_search
26
25
  * ::search
26
+ * ::advanced_search
27
27
  * ::id
28
28
  * ::popular
29
+ * #poster(size)
30
+ * #backdrop(size)
29
31
  * [TV](#tv)
30
32
  * ::search
31
33
  * ::id
@@ -64,10 +66,14 @@ TMDB::API.genres("tv")
64
66
 
65
67
  ### Movies
66
68
 
69
+ #### Class Methods
70
+
71
+ ##### ::search
72
+
67
73
  ```ruby
68
- # To search for movies by title (returns an array of Hashie::Mash objects)
69
- movies = TMDB::Movie.title_search(query: 'the matrix')
70
- # => <Hashie::Mash "adult"=>false,
74
+ # To search for movies by title (returns an array of TMDB:Movie objects)
75
+ movies = TMDB::Movie.search('the matrix')
76
+ # => <TMDB::Movie "adult"=>false,
71
77
  "backdrop_path"=>"/7u3pxc0K1wx32IleAkLv78MKgrw.jpg",
72
78
  "id"=>603,
73
79
  "original_title"=>"The Matrix",
@@ -81,14 +87,21 @@ movies = TMDB::Movie.title_search(query: 'the matrix')
81
87
  # Then you can pull the data from the results, ie.
82
88
  movies.first.title
83
89
  # => "The Matrix"
90
+ ```
91
+
92
+ ##### ::advanced_search
84
93
 
85
- # Use .search to find by various parameters (ie. release date)
86
- movies = TMDB::Movie.search('release_date.gte' => '2014-01-01',
94
+ ```ruby
95
+ # Use .advanced_search to find by various parameters (ie. release date)
96
+ movies = TMDB::Movie.advanced_search('release_date.gte' => '2014-01-01',
87
97
  'release_date.lte' => (Time.now.strftime("%Y-%m-%d")),
88
98
  primary_release_year: 2014)
89
- # => Array of <Hashie::Mash> movies
99
+ # => Array of <TMDB::Movie>s
100
+ ```
90
101
 
102
+ ##### ::id
91
103
 
104
+ ```ruby
92
105
  # To pull all the information for a particular movie, run an id search:
93
106
  movie = TMDB::Movie.id(550)
94
107
  # => <Hashie::Mash "adult"=>false,
@@ -105,14 +118,42 @@ movie = TMDB::Movie.id(550)
105
118
  "original_title"=>"Fight Club",
106
119
  "overview"=>
107
120
  "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on, with underground \"fight clubs\" forming in every town, until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion."...>
121
+ ```
108
122
 
123
+ ##### ::popular
124
+
125
+ ```ruby
109
126
  # Use .popular to final recent popular movies (according to The Movie Database)
110
127
  movies = TMDB::Movie.popular
111
128
  # => Array of <Hashie::Mash> movies
112
129
  ```
113
130
 
131
+ #### Instance Methods
132
+
133
+ ##### #poster
134
+
135
+ ```ruby
136
+ # Use .poster to return a particular TMDB::Movie's poster path, default is 'original'
137
+ # Poster Sizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"]
138
+ TMDB::Movie.id(550).poster
139
+ # => http://image.tmdb.org/t/p/original/2lECpi35Hnbpa4y46JX0aY3AWTy.jpg
140
+ ```
141
+
142
+ ##### #backdrop
143
+
144
+ ```ruby
145
+ # Same as #poster but for backdrops
146
+ # Backdrop Sizes: ["w300", "w780", "w1280", "original"]
147
+ TMDB::Movie.id(550).backdrop('w300')
148
+ # => http://image.tmdb.org/t/p/w300/hNFMawyNDWZKKHU4GYCBz1krsRM.jpg
149
+ ```
150
+
114
151
  ### TV
115
152
 
153
+ #### Class Methods
154
+
155
+ ##### ::search
156
+
116
157
  ```ruby
117
158
  # Similar to Movies
118
159
  TMDB::TV.search(query: 'walking dead')
@@ -135,7 +176,7 @@ TMDB::TV.search(query: 'walking dead')
135
176
  "name"=>"The Walking Dead" ...>
136
177
  ```
137
178
 
138
- ### More Examples
179
+ ## More Examples
139
180
 
140
181
  You can look through the tests for more examples
141
182
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.6.0
@@ -2,22 +2,38 @@
2
2
  # TODO: Review http://ruby.learncodethehardway.org/book/ex44.html first, figure out if we ant to use inheritance or composition
3
3
 
4
4
  module TMDB
5
- class Movie
6
- def self.title_search(options = {})
5
+ class Movie < Hashie::Mash
6
+
7
+ def poster(size='original')
8
+ # Poster Sizes: ["w92", "w154", "w185", "w342", "w500", "w780", "original"]
9
+ # Find latest list at TMDB::API.config.poster_sizes
10
+ config = TMDB::API.config
11
+ config.images.base_url + size + self.poster_path
12
+ end
13
+
14
+ def backdrop(size='original')
15
+ # Backdrop Sizes: ["w300", "w780", "w1280", "original"]
16
+ # Find latest list at TMDB::API.config.backdrop_sizes
17
+ config = TMDB::API.config
18
+ config.images.base_url + size + self.backdrop_path
19
+ end
20
+
21
+ def self.search(title, options = {})
7
22
  # Accepted parameters:
8
23
  # :page, :include_adult (true / false), :year
9
- options.merge!(api_key: TMDB::API.api_key)
24
+ options.merge!(api_key: TMDB::API.api_key,
25
+ query: title)
10
26
  results = TMDB::API.get("/3/search/movie", query: options)['results']
11
27
  movies = []
12
28
  results.each do |result|
13
- movies.push(Hashie::Mash.new(result))
29
+ movies.push(TMDB::Movie.new(result))
14
30
  end
15
31
  return movies
16
32
  end
17
33
 
18
34
  # language (ISO_639_1: 'en')
19
35
  # country (ISO_3166_1: 'US')
20
- def self.search(options = {})
36
+ def self.advanced_search(options = {})
21
37
  # US-snobbish
22
38
  options.merge!(api_key: TMDB::API.api_key,
23
39
  language: 'en',
@@ -32,7 +48,7 @@ module TMDB
32
48
 
33
49
  def self.id(movie_id)
34
50
  options = { api_key: TMDB::API.api_key }
35
- Hashie::Mash.new(TMDB::API.get("/3/movie/#{movie_id}", query: options))
51
+ TMDB::Movie.new(TMDB::API.get("/3/movie/#{movie_id}", query: options))
36
52
  # movie.title = "Fight Club"
37
53
  end
38
54
 
@@ -41,7 +57,7 @@ module TMDB
41
57
  results = TMDB::API.get("/3/movie/popular", query: options)['results']
42
58
  movies = []
43
59
  results.each do |result|
44
- movies.push(Hashie::Mash.new(result))
60
+ movies.push(TMDB::Movie.new(result))
45
61
  end
46
62
  return movies
47
63
  end
@@ -8,19 +8,19 @@ describe TMDB::Movie do
8
8
  TMDB::API.api_key = API_KEY
9
9
 
10
10
  # TMDB::Movie::title_search(query, page, etc.)
11
- describe ".title_search" do
11
+ describe "::search" do
12
12
  it "should return correct results" do
13
- movies = TMDB::Movie.title_search(query: 'the matrix')
13
+ movies = TMDB::Movie.search('the matrix')
14
14
 
15
15
  movies.first.title.must_equal "The Matrix"
16
16
  end
17
17
  end
18
18
 
19
19
  # TMDB::Movie::search(release_date.gte, page, etc.)
20
- describe ".search('...')" do
20
+ describe "::advanced_search('...')" do
21
21
 
22
22
  it "should return recent results" do
23
- movies = TMDB::Movie.search('release_date.gte' => '2014-01-01',
23
+ movies = TMDB::Movie.advanced_search('release_date.gte' => '2014-01-01',
24
24
  'release_date.lte' => (Time.now.strftime("%Y-%m-%d")),
25
25
  primary_release_year: 2014)
26
26
 
@@ -33,7 +33,7 @@ describe TMDB::Movie do
33
33
  end
34
34
 
35
35
  # TMDB::Movie::id(movie_id)
36
- describe ".id" do
36
+ describe "::id" do
37
37
 
38
38
  let (:movie) { TMDB::Movie.id(550) }
39
39
 
@@ -49,11 +49,29 @@ describe TMDB::Movie do
49
49
  end
50
50
 
51
51
  # TMDB::Movie::popular
52
- describe ".popular" do
52
+ describe "::popular" do
53
53
  it "should return a list of popular results" do
54
54
  movies = TMDB::Movie.popular
55
55
  movies.must_be_instance_of Array
56
56
  end
57
57
  end
58
58
 
59
+ # TMDB::Movie#poster
60
+ describe "#poster" do
61
+ let (:movie) { TMDB::Movie.id(550) }
62
+
63
+ it "should return the poster URL" do
64
+ movie.poster.wont_be_nil
65
+ end
66
+ end
67
+
68
+ # TMDB::Movie#backdrop
69
+ describe "#backdrop" do
70
+ let (:movie) { TMDB::Movie.id(550) }
71
+
72
+ it "should return the poster URL" do
73
+ movie.backdrop('w300').wont_be_nil
74
+ end
75
+ end
76
+
59
77
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: tmdb 0.4.1 ruby lib
5
+ # stub: tmdb 0.6.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tmdb"
9
- s.version = "0.4.1"
9
+ s.version = "0.6.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Cody Barr"]
14
- s.date = "2014-07-25"
14
+ s.date = "2014-07-26"
15
15
  s.description = "tmdb is a simple ruby wrapper for The Movie Database. Exposes all TMDB API operations"
16
16
  s.email = "cody.barr@gmail.com"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Barr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty