neo-tmdb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Andrew Smith
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,39 @@
1
+ # Neo TMDb
2
+
3
+ Neo TMDb is a Ruby wrapper for the v3 [TMDb API][api] from www.themoviedb.org.
4
+
5
+ [api]: http://help.themoviedb.org/kb/api/about-3
6
+
7
+ ## Use
8
+
9
+ Currently you can only search for people by name and discover their id. Only
10
+ the first 20 results for searches are returned.
11
+
12
+ require 'neo-tmdb'
13
+
14
+ ```ruby
15
+ TMDb.configure do |config|
16
+ # You must configure this library with a TMDb API key before you can use it.
17
+ config.api_key = 'my-tmdb-api-key-here'
18
+ end
19
+
20
+ people = TMDb::Person.where(:name => "Reeves")
21
+ people.each do |person|
22
+ puts "#{person.name} has TMDb id #{person.id}"
23
+ end
24
+ ```
25
+
26
+ ## Contribute
27
+
28
+ * Source hosted on [GitHub][].
29
+ * Report issues on [GitHub Issues][].
30
+ * Pull requests are very welcome! Please include spec coverage for every patch
31
+ and create a topic branch for every separate change you make.
32
+
33
+ [GitHub]: https://github.com/andrewdsmith/neo-tmdb
34
+ [GitHub Issues]: https://github.com/andrewdsmith/neo-tmdb/issues
35
+
36
+ ## Copyright
37
+
38
+ See LICENSE for details.
39
+
data/lib/neo-tmdb.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'json'
2
+ require 'faraday'
3
+
4
+ require 'tmdb'
5
+ require 'tmdb/configuration'
6
+ require 'tmdb/person'
@@ -0,0 +1,5 @@
1
+ module TMDb
2
+ class Configuration
3
+ attr_accessor :api_key
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ module TMDb
2
+ class Person
3
+ attr_reader :id, :name
4
+
5
+ def initialize(args)
6
+ @id = args["id"]
7
+ @name = args["name"]
8
+ end
9
+
10
+ # Returns an enumerable containing all the people matching the
11
+ # condition hash. Currently the only condition that can be specified
12
+ # is name, e.g.
13
+ #
14
+ # people = Person.where(:name => "Reeves")
15
+ #
16
+ # Only the first page of results (20 people) are returned.
17
+ #
18
+ def self.where(args)
19
+ connection = Faraday.new(:url => 'http://api.themoviedb.org/3/') do |builder|
20
+ builder.request :url_encoded
21
+ builder.adapter :net_http
22
+ end
23
+ response = connection.get(
24
+ "search/person",
25
+ :query => args[:name],
26
+ :api_key => TMDb.configuration.api_key
27
+ )
28
+ body = JSON.parse(response.body)
29
+ body["results"].map {|attrs| new(attrs) }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module TMDb
2
+ VERSION = '0.1.0'
3
+ end
data/lib/tmdb.rb ADDED
@@ -0,0 +1,13 @@
1
+ module TMDb
2
+ extend self
3
+
4
+ # Returns the global TMDb configuration.
5
+ def configuration
6
+ @configuration ||= Configuration.new
7
+ end
8
+
9
+ # Configure TMDb by calling this method.
10
+ def configure
11
+ yield configuration
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neo-tmdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Smith
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.10'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.10'
46
+ - !ruby/object:Gem::Dependency
47
+ name: vcr
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.2'
62
+ description:
63
+ email:
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - lib/tmdb.rb
69
+ - lib/tmdb/configuration.rb
70
+ - lib/tmdb/person.rb
71
+ - lib/tmdb/version.rb
72
+ - lib/neo-tmdb.rb
73
+ - LICENSE
74
+ - README.markdown
75
+ homepage: https://github.com/andrewdsmith/neo-tmdb
76
+ licenses:
77
+ - MIT
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.24
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: A wrapper for the v3 TMDb API from www.themoviedb.org
100
+ test_files: []