tmdb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +90 -0
- data/LICENSE.txt +20 -0
- data/README.md +25 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/tmdb.rb +4 -0
- data/lib/tmdb/movie.rb +1 -0
- data/lib/tmdb/search.rb +36 -0
- data/test/test_helper.rb +7 -0
- data/test/tmdb/test_search.rb +27 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01440f480d5d59d3a926a014875476e7ed2a0708
|
4
|
+
data.tar.gz: f33a7e8b365fae03a22f46a50243cba23654d4aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b7f57f891fa8dbf1cbf7e02f177ef5bda77dd5f3f19f44f57d257d622d04a2033adcbe2aed314d4d0e28755f6384c355041528de3055b243ab8e806a112b26f
|
7
|
+
data.tar.gz: 0e9aadd45398561d9cc7122d6826c4dd50220dd65f8c95403d9444605246e6bf6e991618abe55f23469747aced74792f1299ab0493331eca7a9eb1e7aa4b25ff
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
|
4
|
+
gem 'httparty'
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
gem 'rake-notes' # allows usage of 'rake notes' to find all todos, etc.
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.1.0)
|
5
|
+
i18n (~> 0.6, >= 0.6.9)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.6)
|
11
|
+
builder (3.2.2)
|
12
|
+
colored (1.2)
|
13
|
+
descendants_tracker (0.0.4)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
15
|
+
docile (1.1.3)
|
16
|
+
faraday (0.9.0)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
git (1.2.6)
|
19
|
+
github_api (0.11.3)
|
20
|
+
addressable (~> 2.3)
|
21
|
+
descendants_tracker (~> 0.0.1)
|
22
|
+
faraday (~> 0.8, < 0.10)
|
23
|
+
hashie (>= 1.2)
|
24
|
+
multi_json (>= 1.7.5, < 2.0)
|
25
|
+
nokogiri (~> 1.6.0)
|
26
|
+
oauth2
|
27
|
+
hashie (2.1.1)
|
28
|
+
highline (1.6.21)
|
29
|
+
httparty (0.13.1)
|
30
|
+
json (~> 1.8)
|
31
|
+
multi_xml (>= 0.5.2)
|
32
|
+
i18n (0.6.9)
|
33
|
+
jeweler (2.0.1)
|
34
|
+
builder
|
35
|
+
bundler (>= 1.0)
|
36
|
+
git (>= 1.2.5)
|
37
|
+
github_api
|
38
|
+
highline (>= 1.6.15)
|
39
|
+
nokogiri (>= 1.5.10)
|
40
|
+
rake
|
41
|
+
rdoc
|
42
|
+
json (1.8.1)
|
43
|
+
jwt (0.1.11)
|
44
|
+
multi_json (>= 1.5)
|
45
|
+
mini_portile (0.5.3)
|
46
|
+
minitest (5.3.2)
|
47
|
+
multi_json (1.9.2)
|
48
|
+
multi_xml (0.5.5)
|
49
|
+
multipart-post (2.0.0)
|
50
|
+
nokogiri (1.6.1)
|
51
|
+
mini_portile (~> 0.5.0)
|
52
|
+
oauth2 (0.9.3)
|
53
|
+
faraday (>= 0.8, < 0.10)
|
54
|
+
jwt (~> 0.1.8)
|
55
|
+
multi_json (~> 1.3)
|
56
|
+
multi_xml (~> 0.5)
|
57
|
+
rack (~> 1.2)
|
58
|
+
rack (1.5.2)
|
59
|
+
rake (10.2.2)
|
60
|
+
rake-notes (0.2.0)
|
61
|
+
colored
|
62
|
+
rake
|
63
|
+
rdoc (3.12.2)
|
64
|
+
json (~> 1.4)
|
65
|
+
shoulda (3.5.0)
|
66
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
67
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
68
|
+
shoulda-context (1.2.1)
|
69
|
+
shoulda-matchers (2.6.0)
|
70
|
+
activesupport (>= 3.0.0)
|
71
|
+
simplecov (0.8.2)
|
72
|
+
docile (~> 1.1.0)
|
73
|
+
multi_json
|
74
|
+
simplecov-html (~> 0.8.0)
|
75
|
+
simplecov-html (0.8.0)
|
76
|
+
thread_safe (0.3.3)
|
77
|
+
tzinfo (1.1.0)
|
78
|
+
thread_safe (~> 0.1)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
ruby
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
bundler (~> 1.0)
|
85
|
+
httparty
|
86
|
+
jeweler (~> 2.0.1)
|
87
|
+
rake-notes
|
88
|
+
rdoc (~> 3.12)
|
89
|
+
shoulda
|
90
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Cody Barr
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# tmdb
|
2
|
+
|
3
|
+
Simple ruby wrapper for _The MovieDB_ based on HTTParty
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
_TODO_
|
8
|
+
|
9
|
+
## Compatability
|
10
|
+
|
11
|
+
I wrote this gem while using ruby 2.0.0, I haven't tested compatability with other versions.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
_TODO_
|
16
|
+
|
17
|
+
## Testing
|
18
|
+
|
19
|
+
Make sure to create an 'api_key' file at 'test/api_key' in order to run the tests. I'll work offline testing into the gem later.
|
20
|
+
|
21
|
+
## Copyright
|
22
|
+
|
23
|
+
Copyright © 2014 Cody Barr. See LICENSE.txt for
|
24
|
+
further details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "tmdb"
|
18
|
+
gem.homepage = "http://github.com/codybarr/tmdb"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A simple ruby wrapper for _The MovieDB API_ based on HTTParty}
|
21
|
+
gem.description = %Q{tmdb is a simple ruby wrapper for The Movie Database. Exposes all TMDB API operations}
|
22
|
+
gem.email = "cody.barr@gmail.com"
|
23
|
+
gem.authors = ["Cody Barr"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "tmdb #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Other requires
|
54
|
+
|
55
|
+
require 'rake/notes/rake_task'
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/tmdb.rb
ADDED
data/lib/tmdb/movie.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# TODO: See about making this a deepopenstruct: https://github.com/aarongough/deepopenstruct
|
data/lib/tmdb/search.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
module TMDB
|
3
|
+
class Search
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
attr_accessor :api_key
|
7
|
+
|
8
|
+
base_uri 'http://api.themoviedb.org'
|
9
|
+
|
10
|
+
def initialize(api_key='')
|
11
|
+
@api_key = api_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
options = {api_key: self.api_key}
|
16
|
+
self.class.get("/3/configuration", query: options).parsed_response
|
17
|
+
# configuration['images']['base_url'] => "http://image.tmdb.org/t/p/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def movie_search(options = {})
|
21
|
+
# Accepted parameters:
|
22
|
+
# :page, :include_adult, :year
|
23
|
+
options.merge!(api_key: self.api_key)
|
24
|
+
self.class.get("/3/search/movie", query: options)['results']
|
25
|
+
end
|
26
|
+
|
27
|
+
def movie(movie_id)
|
28
|
+
options = {api_key: self.api_key}
|
29
|
+
self.class.get("/3/movie/#{movie_id}", query: options)
|
30
|
+
# movie['title'] = "Fight Club"
|
31
|
+
end
|
32
|
+
|
33
|
+
# TODO: tv_search(query, page), tv(id)
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
#TODO: rewrite tests using Minitest best practices ()
|
4
|
+
|
5
|
+
describe "TMDB::Search" do
|
6
|
+
# Create a 'test/api_key' file and paste in your API key to run the tests
|
7
|
+
# TODO: Work in 'gem webmock' for offline testing, review: http://code.tutsplus.com/articles/writing-an-api-wrapper-in-ruby-with-tdd--net-23875
|
8
|
+
API_KEY = File.open('test/api_key').read
|
9
|
+
|
10
|
+
let(:search) { TMDB::Search.new(API_KEY) }
|
11
|
+
|
12
|
+
# TMDB::Search#movie_search(query, page)
|
13
|
+
|
14
|
+
it "tmdb.movie_search('matrix') should return a page of matrix results" do
|
15
|
+
puts search
|
16
|
+
movies = search.movie_search(query: 'matrix')
|
17
|
+
movies.first['title'].must_equal "The Matrix"
|
18
|
+
end
|
19
|
+
|
20
|
+
# TMDB::Search#movie(movie_id)
|
21
|
+
|
22
|
+
it "tmdb.movie('550') should return the movie Fight Club" do
|
23
|
+
movie = search.movie('550')
|
24
|
+
movie['title'].must_equal "Fight Club"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tmdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cody Barr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shoulda
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake-notes
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: tmdb is a simple ruby wrapper for The Movie Database. Exposes all TMDB
|
112
|
+
API operations
|
113
|
+
email: cody.barr@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files:
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- VERSION
|
126
|
+
- lib/tmdb.rb
|
127
|
+
- lib/tmdb/movie.rb
|
128
|
+
- lib/tmdb/search.rb
|
129
|
+
- test/test_helper.rb
|
130
|
+
- test/tmdb/test_search.rb
|
131
|
+
homepage: http://github.com/codybarr/tmdb
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.2.2
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A simple ruby wrapper for _The MovieDB API_ based on HTTParty
|
155
|
+
test_files: []
|