pinnacle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +14 -0
- data/LICENSE +20 -0
- data/README.md +15 -0
- data/Rakefile +11 -0
- data/lib/pinnacle.rb +37 -0
- data/lib/pinnacle/api.rb +31 -0
- data/lib/pinnacle/error.rb +6 -0
- data/lib/pinnacle/version.rb +3 -0
- data/pinnacle.gemspec +31 -0
- data/test/factories/list_of_sports.rb +7 -0
- data/test/sports/sports_locator_test.rb +9 -0
- data/test/test_helper.rb +23 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76a70acebcc29ec2bff27e3543e52b2118febab4
|
4
|
+
data.tar.gz: a10c34b23b86426b4bbb6590353b2658ee12b729
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8aaa469534ce40ceef68b6a75d131eee070ee8b7a297dd7061b8745e2a177a4e5b1c12e7bfd2b3203667c1707fa88926727f4fa34f6da0da28c59050d24965cf
|
7
|
+
data.tar.gz: ad18f43155eb0123cc6db1b2f5507f9b44d939a0694b38726a9dfaf33e4bdcf45a0c571529d0b7dbb9517700442cbfd77ed5698b49407d9df37dc7539557e4bd
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Lexer
|
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,15 @@
|
|
1
|
+
# pinnacle
|
2
|
+
|
3
|
+
This is a Gem that allows communication witht the Pinnacle Sports API
|
4
|
+
|
5
|
+
# Tests
|
6
|
+
|
7
|
+
Run tests:
|
8
|
+
bundle exec rake test
|
9
|
+
|
10
|
+
# IRB
|
11
|
+
|
12
|
+
If you need to have a laugh and play around with gem:
|
13
|
+
irb -rubygems -I lib -r $PWD/lib/enrichment_db.rb
|
14
|
+
|
15
|
+
|
data/Rakefile
ADDED
data/lib/pinnacle.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'pinnacle/error'
|
2
|
+
require 'pinnacle/version'
|
3
|
+
|
4
|
+
module Pinnacle
|
5
|
+
module_function
|
6
|
+
|
7
|
+
class DatumModel
|
8
|
+
attr_accessor :attrs
|
9
|
+
alias :to_hash :attrs
|
10
|
+
|
11
|
+
# Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
|
12
|
+
#
|
13
|
+
# @overload self.lazy_attr_reader(attr)
|
14
|
+
# @param attr [Symbol]
|
15
|
+
# @overload self.lazy_attr_reader(attrs)
|
16
|
+
# @param attrs [Array<Symbol>]
|
17
|
+
def self.lazy_attr_reader(*attrs)
|
18
|
+
attrs.each do |attribute|
|
19
|
+
class_eval do
|
20
|
+
define_method attribute do
|
21
|
+
@attrs[attribute.to_s] || @attrs[attribute.to_sym]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Initializes a new Base object
|
28
|
+
#
|
29
|
+
# @param attrs [Hash]
|
30
|
+
# @return [DatumModel]
|
31
|
+
def initialize(attrs={})
|
32
|
+
@attrs = attrs.dup
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'api'
|
data/lib/pinnacle/api.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'httparty'
|
3
|
+
require 'addressable/uri'
|
4
|
+
|
5
|
+
module Pinnacle
|
6
|
+
BASE_URI = 'https://api.pinnaclesports.com/v1/'
|
7
|
+
|
8
|
+
def self.encode_basic(id, password)
|
9
|
+
str = "#{id}:#{password}"
|
10
|
+
Base64.encode(str)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.reset_connection
|
14
|
+
@__api_connection = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.generate_url(endpoint, parameters)
|
18
|
+
BASE_URI + endpoint + '?' + format_parameters(parameters)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.request(endpoint, parameters)
|
22
|
+
url = generate_url(endpoint, parameters)
|
23
|
+
HTTParty.get(url)
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_parameters(parameters)
|
27
|
+
uri = Addressable::URI.new
|
28
|
+
uri.query_values = parameters
|
29
|
+
uri.query
|
30
|
+
end
|
31
|
+
end
|
data/pinnacle.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'pinnacle/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'pinnacle'
|
7
|
+
s.version = Pinnacle::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.licenses = ['MIT']
|
10
|
+
s.authors = ['Sam Crouch']
|
11
|
+
s.email = 'crouch6@hotmail.com'
|
12
|
+
s.homepage = 'https://github.com/crouch6/pinnacle'
|
13
|
+
s.summary = 'Pinnacle API gem'
|
14
|
+
s.description = 'Access the Pinnacle Sport API.'
|
15
|
+
|
16
|
+
s.add_dependency 'multi_json', '~> 1.3'
|
17
|
+
s.add_dependency 'pg'
|
18
|
+
s.add_dependency 'pr_geohash'
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split($RS).reject do |file|
|
21
|
+
file =~ %r{^(?:
|
22
|
+
spec/.*
|
23
|
+
|Gemfile
|
24
|
+
|Rakefile
|
25
|
+
|\.gitignore
|
26
|
+
|\.rubocop.yml
|
27
|
+
)$}x
|
28
|
+
end
|
29
|
+
s.test_files = `git ls-files`.split($RS)
|
30
|
+
s.require_paths = ['lib']
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/reporters'
|
5
|
+
require 'minitest/spec'
|
6
|
+
require 'webmock/minitest'
|
7
|
+
require 'faker'
|
8
|
+
require 'factory_girl'
|
9
|
+
|
10
|
+
MiniTest::Reporters.use! [Minitest::Reporters::SpecReporter.new, MiniTest::Reporters::JUnitReporter.new]
|
11
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'enrichment_db')
|
12
|
+
FactoryGirl.find_definitions
|
13
|
+
|
14
|
+
$should_stub = true
|
15
|
+
if $should_stub
|
16
|
+
WebMock.disable_net_connect!
|
17
|
+
else
|
18
|
+
WebMock.allow_net_connect!
|
19
|
+
end
|
20
|
+
|
21
|
+
def stub_get(path)
|
22
|
+
WebMock::API.stub_http_request(:get, request_path(path))
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pinnacle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Crouch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pg
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: pr_geohash
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Access the Pinnacle Sport API.
|
56
|
+
email: crouch6@hotmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- Gemfile
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- lib/pinnacle.rb
|
66
|
+
- lib/pinnacle/api.rb
|
67
|
+
- lib/pinnacle/error.rb
|
68
|
+
- lib/pinnacle/version.rb
|
69
|
+
- pinnacle.gemspec
|
70
|
+
- test/factories/list_of_sports.rb
|
71
|
+
- test/sports/sports_locator_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
homepage: https://github.com/crouch6/pinnacle
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Pinnacle API gem
|
97
|
+
test_files:
|
98
|
+
- Gemfile
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- lib/pinnacle.rb
|
103
|
+
- lib/pinnacle/api.rb
|
104
|
+
- lib/pinnacle/error.rb
|
105
|
+
- lib/pinnacle/version.rb
|
106
|
+
- pinnacle.gemspec
|
107
|
+
- test/factories/list_of_sports.rb
|
108
|
+
- test/sports/sports_locator_test.rb
|
109
|
+
- test/test_helper.rb
|