mmapi 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/mmapi.rb +48 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 977c8aff6b2caee192c86ec8f2493827aa0a8247
4
+ data.tar.gz: 245eb087117ef6245aa91bb6533062f1bdf55f4a
5
+ SHA512:
6
+ metadata.gz: dd7fa28250c1d0a424b41837bc3288c7dac3cf2b58ebfa508943f1f00379c589fbc4040e366ba9ac74543fe3af172a018c1f2bde5064addd89a67fe31af05303
7
+ data.tar.gz: 20754d787ffb76503d32136fed599ac7e2a8ba730516306a852cf95815d63f085d22150fcfc89d9080e827396d6574d8fa2da970b1d941fa8e885f604d98a2d3
data/lib/mmapi.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+
4
+ class MovieAPI
5
+
6
+ API_URL = 'http://mymovieapi.com/'
7
+
8
+ # @todo Add search by ID
9
+ def self.search_by_id(options = {})
10
+
11
+ end
12
+
13
+ # Queries the API for a movie title
14
+ #
15
+ # @param [String] title The title of the movie
16
+ #
17
+ # @param [Hash] options The options to create a search query
18
+ # @option options [Integer] :year (2013) The year you wish to search for - defaults to current year
19
+ # @option options [Integer] :yg (0) When this paramter is 0, the year parameter is disabled
20
+ # @option options [String] :mt ('none') The movie type you wish to search for
21
+ # @option options [String] :plot ('simple') The plot type you with the API to return
22
+ # @option options [Integer] :episode (1) When the parameter is 0, "episodes" is not included in the result
23
+ # @option options [Integer] :offset (0) Paging offset
24
+ # @option options [Integer] :limit (1) The maximum number of records to return
25
+ # @option options [String] :lang ('en-US') The data language you wish to return
26
+ # @option options [String] :aka ('simple') The aka type you with to return
27
+ # @option options [String] :release ('simple') The release date type you with to return
28
+ # @option options [Integer] :business (0) Include the business field
29
+ # @option options [Integer] :tech (0) Include the technical field
30
+ #
31
+ # @return [Array] Returns an array of hashes.
32
+ def self.search_by_title(title, options = {})
33
+
34
+ params = options ? options.collect {|key, value| "#{key}=#{URI::encode(value)}"}.join('&') : ''
35
+
36
+
37
+ uri = "http://mymovieapi.com?q=#{URI::encode(title)}" + params
38
+
39
+ p uri
40
+
41
+ response = open("http://mymovieapi.com?q=#{URI::encode(title)}&" + params).read
42
+ data = JSON.parse(response)
43
+
44
+ return data
45
+
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mmapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: mymovieapi.com
14
+ email: tyebud@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/mmapi.rb
20
+ homepage: http://rubygems.org/gems/mmapi
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: My Movie API Wrapper!
44
+ test_files: []
45
+ has_rdoc: