gospotcheck 0.0.2
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.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +3 -0
- data/gospotcheck.gemspec +32 -0
- data/lib/gospotcheck/client.rb +67 -0
- data/lib/gospotcheck/configuration.rb +31 -0
- data/lib/gospotcheck/places.rb +19 -0
- data/lib/gospotcheck/version.rb +3 -0
- data/lib/gospotcheck.rb +10 -0
- data/spec/gospotcheck_spec.rb +22 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/faraday_mock_connection.rb +7 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9e0c98c5dfd48d69d85b79937bbf9f668d091e1
|
4
|
+
data.tar.gz: 295752754d92e7746427986ebead24ee1f7a788d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06a1d1bad7b0394b1b5a44cbafe3a0b6b50fac29ecd21c99cfdd6d8ff0664660cf48a4bb3b9841ef7693017920839d61f607f5afc313ff2435f4e59246acc9ea
|
7
|
+
data.tar.gz: 79eb1f64ef60fe059e6ac86d56f9ba0ee3efda53e9b12e4e3abf4444f7940d5c80026ea6fd7772411e438294cf45741c8baae54448f4d305d80f32a97668d052
|
data/.env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
OAUTH_TOKEN=INSERT_YOUR_OAUTH_TOKEN_HERE
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 McBainCO
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Gospotcheck
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
A gem to interact with the GoSpotCheck API. For more information on the GoSpotCheck API please see their [documentation](http://docs.gsc.apiary.io/).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
client = Twitter::REST::Client.new do |config|
|
13
|
+
config.consumer_key = "YOUR_CONSUMER_KEY"
|
14
|
+
config.consumer_secret = "YOUR_CONSUMER_SECRET"
|
15
|
+
config.access_token = "YOUR_ACCESS_TOKEN"
|
16
|
+
config.access_token_secret = "YOUR_ACCESS_SECRET"
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install gospotcheck
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### On a Rails project
|
31
|
+
|
32
|
+
Create a file in your config/intializers directory called gospotcheck.rb which includes the following code:
|
33
|
+
|
34
|
+
```
|
35
|
+
GoSpotCheck.client.configure do |config|
|
36
|
+
config.oauth_token = ENV['YOUR_GOSPOTCHECK_OAUTH_TOKEN']
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/[my-github-username]/gospotcheck/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/gospotcheck.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gospotcheck/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'gospotcheck'
|
8
|
+
spec.version = Gospotcheck::VERSION
|
9
|
+
spec.authors = ['McBainCO', 'lindsay-r', 'bscharm', 'lukemccomb']
|
10
|
+
spec.email = ["bscharm@gmail.com\n"]
|
11
|
+
spec.summary = 'Go Spot Check API gem'
|
12
|
+
spec.description = 'Ruby wrapper for the goSpotcheck API written by a couple of plucky gSchoolers'
|
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.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
24
|
+
spec.add_development_dependency 'pry'
|
25
|
+
spec.add_development_dependency 'pry-byebug'
|
26
|
+
spec.add_development_dependency 'dotenv'
|
27
|
+
|
28
|
+
spec.add_runtime_dependency 'faraday', '~> 0.9.0'
|
29
|
+
spec.add_runtime_dependency 'faraday_middleware', '~> 0.8'
|
30
|
+
spec.add_runtime_dependency 'simple_oauth', '~>0.2'
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'gospotcheck/configuration'
|
4
|
+
require 'gospotcheck/places'
|
5
|
+
|
6
|
+
module GoSpotCheck
|
7
|
+
|
8
|
+
class Client
|
9
|
+
# set the root host for the GoSpotCheck API
|
10
|
+
API_HOST = "https://review.gospotcheck.com"
|
11
|
+
|
12
|
+
attr_reader :configuration
|
13
|
+
attr_writer :connection
|
14
|
+
|
15
|
+
def initialize(options = nil)
|
16
|
+
@configuration = nil
|
17
|
+
|
18
|
+
unless options.nil?
|
19
|
+
@configuration = Configuration.new(options)
|
20
|
+
check_api_keys
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure
|
26
|
+
@configuration = Configuration.new
|
27
|
+
|
28
|
+
# yield to the configuration block in the Rails initializer
|
29
|
+
yield(@configuration)
|
30
|
+
|
31
|
+
check_api_keys
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_api_keys
|
35
|
+
# check for configuration, if it exists prevent further modification
|
36
|
+
if configuration.nil? || !configuration.valid?
|
37
|
+
@configuration = nil
|
38
|
+
else
|
39
|
+
@configuration.freeze
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def connection
|
44
|
+
return @connection if instance_variable_defined?(:@connection)
|
45
|
+
|
46
|
+
@connection = Faraday.new(API_HOST) do |conn|
|
47
|
+
|
48
|
+
# uses the default Net::HTTP adapter
|
49
|
+
conn.adapter Faraday.default_adapter
|
50
|
+
end
|
51
|
+
|
52
|
+
# set the Authorization header using the provided oauth token
|
53
|
+
@connection.headers["Authorization"] = "Bearer #{@configuration.auth_keys[:oauth_token]}"
|
54
|
+
@connection.headers["Content-Type"] = "application/json"
|
55
|
+
|
56
|
+
# return an instance of a connection with desired settings
|
57
|
+
@connection
|
58
|
+
end
|
59
|
+
|
60
|
+
def search(endpoint, params)
|
61
|
+
@places = GoSpotCheck::Places.new(connection)
|
62
|
+
@places.search(endpoint, params)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GoSpotCheck
|
2
|
+
|
3
|
+
class Configuration
|
4
|
+
|
5
|
+
AUTH_KEYS = [:oauth_token]
|
6
|
+
|
7
|
+
attr_accessor *AUTH_KEYS
|
8
|
+
|
9
|
+
def initialize(config_hash = nil)
|
10
|
+
if config_hash.is_a?(Hash)
|
11
|
+
config_hash.each do |config_name, config_value|
|
12
|
+
self.send("#{config_name}=", config_value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a hash of api keys and their values
|
18
|
+
def auth_keys
|
19
|
+
AUTH_KEYS.inject({}) do |keys_hash, key|
|
20
|
+
keys_hash[key] = send(key)
|
21
|
+
keys_hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid?
|
26
|
+
AUTH_KEYS.none?{ |key| send(key).nil? || send(key).empty? }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GoSpotCheck
|
2
|
+
|
3
|
+
class Places
|
4
|
+
|
5
|
+
# define the path for GoSpotCheck API places queries
|
6
|
+
# potential to further modify for use of different endpoints
|
7
|
+
PATH = "/external/v1/"
|
8
|
+
|
9
|
+
def initialize(connection)
|
10
|
+
@connection = connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def search(endpoint, params)
|
14
|
+
options = {endpoint: endpoint}
|
15
|
+
@connection.get PATH + options.fetch(:endpoint).to_s, params
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/gospotcheck.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoSpotCheck do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@client = GoSpotCheck::Client.new({oauth_token: 'test'})
|
7
|
+
@client.connection = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:status_code) {JSON.parse(@client.search(:places, {'name.eq' => ''}).body)['request']['status_code']}
|
11
|
+
|
12
|
+
it 'responds to search' do
|
13
|
+
expect(@client).to respond_to(:search)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns the correct response' do
|
17
|
+
expect(@client.search(:places, {'name.eq' => ''})).to be_an_instance_of(Faraday::Response)
|
18
|
+
expect(status_code).to eq(200)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gospotcheck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- McBainCO
|
8
|
+
- lindsay-r
|
9
|
+
- bscharm
|
10
|
+
- lukemccomb
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: bundler
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.7'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '10.0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '10.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rspec
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.0.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.0.0
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: pry
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: pry-byebug
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: dotenv
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: faraday
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.9.0
|
107
|
+
type: :runtime
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 0.9.0
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: faraday_middleware
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0.8'
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0.8'
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: simple_oauth
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - "~>"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0.2'
|
135
|
+
type: :runtime
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.2'
|
142
|
+
description: Ruby wrapper for the goSpotcheck API written by a couple of plucky gSchoolers
|
143
|
+
email:
|
144
|
+
- |
|
145
|
+
bscharm@gmail.com
|
146
|
+
executables: []
|
147
|
+
extensions: []
|
148
|
+
extra_rdoc_files: []
|
149
|
+
files:
|
150
|
+
- ".env.example"
|
151
|
+
- ".gitignore"
|
152
|
+
- ".rspec"
|
153
|
+
- Gemfile
|
154
|
+
- LICENSE.txt
|
155
|
+
- README.md
|
156
|
+
- Rakefile
|
157
|
+
- gospotcheck.gemspec
|
158
|
+
- lib/gospotcheck.rb
|
159
|
+
- lib/gospotcheck/client.rb
|
160
|
+
- lib/gospotcheck/configuration.rb
|
161
|
+
- lib/gospotcheck/places.rb
|
162
|
+
- lib/gospotcheck/version.rb
|
163
|
+
- spec/gospotcheck_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/faraday_mock_connection.rb
|
166
|
+
homepage: ''
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.2.2
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Go Spot Check API gem
|
190
|
+
test_files:
|
191
|
+
- spec/gospotcheck_spec.rb
|
192
|
+
- spec/spec_helper.rb
|
193
|
+
- spec/support/faraday_mock_connection.rb
|