gracenote-on_connect 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed12edc51ed63b4403527bd2074112f5839a11b8
4
+ data.tar.gz: b46577b9640ed5ab3c85048e6879a653197bb337
5
+ SHA512:
6
+ metadata.gz: 99f4266af84143c39c42c6937c366517ff8bd018657371e8700db1def544d7f5c6fffee6a81ca934e233ac97f767258ef5fa7cd32fc1bf9d4d78cff2e92393e5
7
+ data.tar.gz: 5ab09f330bb499bcd790f6818208a04dd024ffdfa8bf6dfc08df98e8c68a37962cec0d28592b69ec7b5de031692ac9d96846c1a4fb134988bbf64c643ddd1b47
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+
37
+ .config
38
+ .yardoc
39
+ Gemfile.lock
40
+ InstalledFiles
41
+ _yardoc
42
+ coverage
43
+ doc/
44
+ lib/bundler/man
45
+ pkg
46
+ rdoc
47
+ spec/reports
48
+ test/tmp
49
+ test/version_tmp
50
+ tmp
51
+ *.bundle
52
+ *.so
53
+ *.o
54
+ *.a
55
+ mkmf.log
56
+ .DS_Store
57
+ .envrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gracenote-on_connect.gemspec
4
+ gemspec
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'bundle exec rspec --color' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Matt Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Matt Morris
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Gracenote::OnConnect
2
+ A wrapper for Gracenote's OnConnect REST API
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ gem 'gracenote-on_connect', github: 'https://github.com/matt-morris/gracenote-on_connect'
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ ~~$ gem install gracenote-on_connect~~
17
+
18
+ ## Usage
19
+
20
+ TODO: Write usage instructions here
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it ( https://github.com/matt-morris/gracenote-on_connect/fork )
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gracenote/on_connect/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gracenote-on_connect"
8
+ spec.version = Gracenote::OnConnect::VERSION
9
+ spec.authors = ["Matt Morris"]
10
+ spec.email = ["double.emms@gmail.com"]
11
+ spec.summary = %q{A wrapper for Gracenote's OnConnect REST API.}
12
+ spec.description = %q{A convenient wrapper for Gracenote's OnConnect REST API.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard"
25
+ spec.add_development_dependency "guard-rspec"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "pry-nav"
28
+ end
@@ -0,0 +1,59 @@
1
+ require 'gracenote/on_connect/version'
2
+ require 'net/http'
3
+ require 'json'
4
+ require 'date'
5
+
6
+ module Gracenote
7
+ module OnConnect
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ class Configuration
13
+ attr_accessor :api_key, :base_url
14
+
15
+ def initialize
16
+ @api_key = ENV['ONCONNECT_API_KEY']
17
+ @base_url = 'http://data.tmsapi.com/v1.1'
18
+ end
19
+ end
20
+
21
+ def self.configure
22
+ self.configuration ||= Configuration.new
23
+ yield configuration
24
+ end
25
+
26
+ class Theater
27
+ def self.find_by_zip(zip)
28
+ params = { api_key: OnConnect.configuration.api_key, zip: zip }
29
+ self.get("theatres", params)
30
+ end
31
+
32
+ def self.showtimes(theater_id, start_date: Date.today.to_s, days: 1, size: nil)
33
+ params = {
34
+ api_key: OnConnect.configuration.api_key,
35
+ startDate: start_date,
36
+ numDays: days,
37
+ imageSize: size
38
+ }
39
+
40
+ params.select! { |k, v| k unless v.nil? }
41
+
42
+ self.get("theatres/#{theater_id}/showings", params)
43
+ end
44
+
45
+ private
46
+
47
+ def self.get(path, params = {})
48
+ uri = URI("#{OnConnect.configuration.base_url}/#{path}")
49
+ uri.query = URI.encode_www_form(params)
50
+ response = Net::HTTP.get_response(uri)
51
+ # binding.pry
52
+ JSON.parse(response.body)
53
+ rescue JSON::ParserError => e
54
+ # binding.pry
55
+ { errors: [e.message] }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Gracenote
2
+ module OnConnect
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gracenote::OnConnect do
4
+ describe '#setup' do
5
+ before do
6
+ Gracenote::OnConnect.configure do |config|
7
+ config.api_key = ENV['ONCONNECT_API_KEY']
8
+ end
9
+ end
10
+
11
+ it 'validates presence of credentials' do
12
+ expect(Gracenote::OnConnect.configuration.api_key).to_not be_nil
13
+ end
14
+ end
15
+
16
+ describe 'Theater' do
17
+ describe 'finds by zip' do
18
+ before do
19
+ @theaters = Gracenote::OnConnect::Theater.find_by_zip(44113)
20
+ end
21
+
22
+ it 'has results' do
23
+ expect(@theaters).to_not be_empty
24
+ end
25
+ end
26
+
27
+ describe 'finds showtimes' do
28
+ before do
29
+ @showtimes = Gracenote::OnConnect::Theater.showtimes(2279)
30
+ end
31
+
32
+ it 'has results' do
33
+ expect(@showtimes).to_not be_empty
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,2 @@
1
+ require 'pry'
2
+ require 'gracenote/on_connect'
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gracenote-on_connect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Matt Morris
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
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: pry-nav
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: A convenient wrapper for Gracenote's OnConnect REST API.
112
+ email:
113
+ - double.emms@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - Guardfile
121
+ - LICENSE
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - gracenote-on_connect.gemspec
126
+ - lib/gracenote/on_connect.rb
127
+ - lib/gracenote/on_connect/version.rb
128
+ - spec/gracenote/on_connect_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: ''
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.0.3
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: A wrapper for Gracenote's OnConnect REST API.
154
+ test_files:
155
+ - spec/gracenote/on_connect_spec.rb
156
+ - spec/spec_helper.rb
157
+ has_rdoc: