overwatch_api 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd7728541afb8148e274b711c92d6d0239481045
4
+ data.tar.gz: 2cb7aa105c8f04971d4fc28c656f3bc4c81b005b
5
+ SHA512:
6
+ metadata.gz: 18e01ef4d7b9fd77b9b5a4474622fc340a5bc3d833575876e875250e6126d69470ab0f906d13109a8b79c812091cd2040abc8c331bf747d773f7e789f66ab944
7
+ data.tar.gz: e22ef14cecfe867a8c95cc6b18179ff249e3bb9e5a61d3b5786913e05fbf27ae1386957a7fa6199a8f84ef9605f10222cea8bc5a877c17e0d58ece1772712134
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ *.swo
17
+ *.swp
18
+ .DS_Store
19
+ .env
20
+ *.gem
21
+ .byebug_history
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015, 2016 Bryan Mytko
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,65 @@
1
+ ![logo](http://i.imgur.com/uHMulGP.jpg)
2
+
3
+ # OverwatchApi
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/overwatch_api.svg)](https://badge.fury.io/rb/overwatch_api)
6
+
7
+ _This is a work in progress, namely because the Overwatch API isn't publicly exposed yet :P_
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'overwatch_api'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install overwatch_api
24
+
25
+ Create a .env file and add your [API Key]()
26
+
27
+ $ touch .env
28
+
29
+ **In the .env file:**
30
+
31
+ OVERWATCH_API_KEY=xxxxxxxxxxxxxxxxxxxx
32
+
33
+ ## Endpoints
34
+
35
+ All endpoints available via @TODO
36
+
37
+ 1. [Placeholder](#placeholder)
38
+
39
+ Examples:
40
+
41
+ #### Placeholder
42
+
43
+ ```ruby
44
+ OverwatchApi::Placeholder.method(arguments)
45
+
46
+ => {"Response"=>[],
47
+ "Data"=>
48
+ [{"More Data"=>"Value",
49
+ "Even More Data"=>"Value",
50
+ [...]
51
+ ```
52
+
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it ( https://github.com/[my-github-username]/overwatch_api/fork )
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create a new Pull Request
61
+
62
+ ## Development
63
+
64
+ gem build overwatch_api.gemspec
65
+ gem install ./overwatch_api-0.0.1.gem
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,16 @@
1
+ require "httparty"
2
+ require "dotenv"
3
+
4
+ Dotenv.load
5
+
6
+ require "overwatch_api/base_model"
7
+ require "overwatch_api/configuration"
8
+ require "overwatch_api/connection"
9
+ require "overwatch_api/exceptions"
10
+ require "overwatch_api/request"
11
+ require "overwatch_api/version"
12
+
13
+ module OverwatchApi
14
+ include HTTParty
15
+ extend Configuration
16
+ end
@@ -0,0 +1,21 @@
1
+ module OverwatchApi
2
+ require "overwatch_api/request"
3
+
4
+ class BaseModel
5
+ class << self
6
+ include Request
7
+
8
+ private
9
+
10
+ def endpoint
11
+ OverwatchApi.endpoint
12
+ end
13
+ end
14
+
15
+ class ::String
16
+ def capitalize_all
17
+ split.map(&:capitalize).join(" ")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module OverwatchApi
2
+ module Configuration
3
+ attr_accessor :endpoint
4
+ attr_accessor :api_key
5
+
6
+ DEFAULT_ENDPOINT = "" # @TODO TBD
7
+ DEFAULT_API_KEY = ENV["OVERWATCH_API_KEY"]
8
+
9
+ def self.extended(base)
10
+ base.reset
11
+ end
12
+
13
+ def reset
14
+ self.endpoint = DEFAULT_ENDPOINT
15
+ self.api_key = DEFAULT_API_KEY
16
+ end
17
+
18
+ def configure
19
+ yield self
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module OverwatchApi
2
+ module Connection
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module OverwatchApi
2
+ class Error < StandardError; end
3
+ class ResponseError < Error; end
4
+ class UnsupportedMethodError < Error; end
5
+ class NoApiKeyError < Error; end
6
+ end
@@ -0,0 +1,35 @@
1
+ module OverwatchApi
2
+ module Request
3
+ require "uri"
4
+
5
+ def get(path, options = {})
6
+ response = request(:get, path, options)
7
+ raise OverwatchApi::ResponseError.new(response["message"]) unless response.code == 200
8
+ return response
9
+ end
10
+
11
+ private
12
+
13
+ def headers
14
+ raise OverwatchApi::NoApiKeyError
15
+ .new("No API key set.") unless OverwatchApi.api_key
16
+
17
+ { "X-Mashape-Key" => OverwatchApi.api_key } # @TODO if not on mashape...
18
+ end
19
+
20
+ def request(method, path, options = {})
21
+ # @TODO probably only GET requests, but to be determined
22
+ case method
23
+ when :get
24
+ options = { headers: headers, query: options }
25
+
26
+ response = OverwatchApi.get(
27
+ URI.encode(endpoint + path),
28
+ options
29
+ )
30
+ else
31
+ raise OverwatchApi::UnsupportedMethodError.new
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module OverwatchApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'overwatch_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "overwatch_api"
8
+ spec.version = OverwatchApi::VERSION
9
+ spec.authors = ["Bryan Mytko"]
10
+ spec.email = ["bryanmytko@gmail.com"]
11
+ spec.summary = %q{API Wrapper for overwatchapi.com}
12
+ spec.description = <<-EOF
13
+ A wrapper for the Overwatch API found at https://dev.battle.net/docs
14
+ EOF
15
+ spec.homepage = "https://github.com/bryanmytko/overwatch_api"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake", "~> 10"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.3"
27
+ spec.add_development_dependency "vcr", "~> 2.9"
28
+ spec.add_development_dependency "webmock", "~> 1.8"
29
+ spec.add_development_dependency "byebug", '~> 8.2', '>= 8.2.4'
30
+
31
+ spec.add_dependency "httparty", "~> 0.13"
32
+ spec.add_dependency "json", "~> 1.8"
33
+ spec.add_dependency "dotenv", "~>2.0"
34
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe OverwatchApi do
4
+ it "is a module" do
5
+ expect(described_class).to be_a_kind_of(Module)
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require "overwatch_api"
2
+ require "rspec"
3
+ require "vcr"
4
+ require "byebug"
5
+ require "dotenv"
6
+
7
+ VCR.configure do |c|
8
+ c.cassette_library_dir = "spec/support/vcr_cassettes"
9
+ c.hook_into :webmock
10
+ c.configure_rspec_metadata!
11
+ c.allow_http_connections_when_no_cassette = false
12
+ c.default_cassette_options = {:record => :new_episodes}
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ Dotenv.load
17
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: overwatch_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Mytko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-10 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: '10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '8.2'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 8.2.4
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '8.2'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 8.2.4
103
+ - !ruby/object:Gem::Dependency
104
+ name: httparty
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.13'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.13'
117
+ - !ruby/object:Gem::Dependency
118
+ name: json
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.8'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.8'
131
+ - !ruby/object:Gem::Dependency
132
+ name: dotenv
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '2.0'
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '2.0'
145
+ description: |2
146
+ A wrapper for the Overwatch API found at https://dev.battle.net/docs
147
+ email:
148
+ - bryanmytko@gmail.com
149
+ executables: []
150
+ extensions: []
151
+ extra_rdoc_files: []
152
+ files:
153
+ - ".gitignore"
154
+ - Gemfile
155
+ - LICENSE.txt
156
+ - README.md
157
+ - Rakefile
158
+ - lib/overwatch_api.rb
159
+ - lib/overwatch_api/base_model.rb
160
+ - lib/overwatch_api/configuration.rb
161
+ - lib/overwatch_api/connection.rb
162
+ - lib/overwatch_api/exceptions.rb
163
+ - lib/overwatch_api/request.rb
164
+ - lib/overwatch_api/version.rb
165
+ - overwatch_api.gemspec
166
+ - spec/overwatch_api/overwatch_api_spec.rb
167
+ - spec/spec_helper.rb
168
+ homepage: https://github.com/bryanmytko/overwatch_api
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.4.5.1
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: API Wrapper for overwatchapi.com
192
+ test_files:
193
+ - spec/overwatch_api/overwatch_api_spec.rb
194
+ - spec/spec_helper.rb