vainglory-api 0.0.4 → 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 +4 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +30 -3
- data/Gemfile +1 -1
- data/README.md +28 -10
- data/lib/vainglory_api/client.rb +10 -1
- data/lib/vainglory_api/region.rb +125 -0
- data/lib/vainglory_api/version.rb +4 -1
- data/spec/lib/vainglory_api/client_spec.rb +17 -14
- data/spec/lib/vainglory_api/region_spec.rb +68 -0
- data/spec/lib/vainglory_api_spec.rb +2 -4
- data/spec/spec_helper.rb +1 -0
- data/spec/support/klasses.rb +18 -0
- data/vainglory_api.gemspec +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a0ec37c93f459878f197bea42a61daa99ce355e
|
4
|
+
data.tar.gz: 5ba5b4926902a7b78449a519efb35a40d486a135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5092d4f44ef16a1238a4a6da6158fed310eaf52c1de5a1375f349f1035d22f39215a30cec0c518d85f1790eabdb4ec86b5b4ecca382d096e62182d84eed110d
|
7
|
+
data.tar.gz: a3ee5bbe1b1b1fa6e3ebdb8561ee46cbd284086ef1a12dd299e3f8b2ef38d5ea0466c1702f50576ccccf5508d9b204aadbf488519382c4f7596dc67374babbf3
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,33 @@
|
|
1
|
-
### 0.0
|
1
|
+
### 0.1.0
|
2
|
+
_2017-06-16_
|
3
|
+
|
4
|
+
- Adds `VaingloryAPI::Region` object
|
5
|
+
- Validates `VaingloryAPI::Client` region at instantiation
|
6
|
+
- Moves Gem date to `VaingloryAPI::RELEASE_DATE`
|
7
|
+
- Adds shared RSpec example group for all lib specs
|
8
|
+
- Changes default RSpec format to "documentation"
|
9
|
+
- Updates README
|
10
|
+
|
11
|
+
### 0.0.4
|
12
|
+
_2017-06-23_
|
13
|
+
|
14
|
+
- Adds a `CHANGELOG.md` to the repository
|
15
|
+
- Adds Rubocop configurations
|
16
|
+
- Adds YARD documentation
|
17
|
+
- Removes and ignores `Gemfile.lock`
|
18
|
+
- - Refreshes stored VCR cassettes
|
19
|
+
- Splits `VaingloryAPI` and `VaingloryAPI::Client` specs
|
20
|
+
|
21
|
+
#### Fixes
|
22
|
+
- Fixes bug where where some match data was missing (see: https://github.com/cbortz/vainglory-api-ruby/issues/7)
|
23
|
+
|
24
|
+
### 0.0.3
|
25
|
+
_2017-03-28_
|
2
26
|
- Ruby version >= 2.0 is required
|
3
27
|
|
4
|
-
### 0.0.2
|
28
|
+
### 0.0.2
|
29
|
+
_2017-03-28_
|
30
|
+
|
31
|
+
### 0.0.1
|
32
|
+
_2017-03-28_
|
5
33
|
|
6
|
-
### 0.0.1 - 2017-03-28
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/README.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
|
-
# vainglory-api
|
2
|
-
[](https://badge.fury.io/rb/vainglory-api)
|
3
1
|
[](https://travis-ci.org/cbortz/vainglory-api-ruby)
|
4
2
|
[](https://codeclimate.com/github/cbortz/vainglory-api-ruby)
|
5
3
|
[](https://codeclimate.com/github/cbortz/vainglory-api-ruby/coverage)
|
4
|
+
[](https://rubygems.org/gems/vainglory-api)
|
6
5
|
[](http://inch-ci.org/github/cbortz/vainglory-api-ruby)
|
6
|
+
[](https://github.com/cbortz/vainglory-api-ruby/blob/master/LICENSE)
|
7
|
+
|
8
|
+
# vainglory-api
|
9
|
+
|
10
|
+
A Ruby libary wrapper for the Vainglory API
|
11
|
+
|
12
|
+
- [Getting Started](https://github.com/cbortz/vainglory-api-ruby#getting-started)
|
13
|
+
- [Installation](https://github.com/cbortz/vainglory-api-ruby#installation)
|
14
|
+
- [Usage](https://github.com/cbortz/vainglory-api-ruby#usage)
|
15
|
+
- [Contributing](https://github.com/cbortz/vainglory-api-ruby#contributing)
|
16
|
+
- [License](https://github.com/cbortz/vainglory-api-ruby#license)
|
7
17
|
|
8
|
-
|
9
|
-
- [Official Vainglory API Documentation](https://developer.vainglorygame.com/docs)
|
18
|
+
See also: [YARD Documentation](http://www.rubydoc.info/github/cbortz/vainglory-api-ruby), [Official Vainglory API Documentation](https://developer.vainglorygame.com/docs)
|
10
19
|
|
11
20
|
---
|
12
21
|
|
@@ -14,7 +23,7 @@
|
|
14
23
|
|
15
24
|
VaingloryAPI works with Ruby 2.0 onwards. Please refer to the [YARD Documentation](http://www.rubydoc.info/github/cbortz/vainglory-api-ruby) for a better understanding of how everything works.
|
16
25
|
|
17
|
-
|
26
|
+
## Installation
|
18
27
|
|
19
28
|
You can add it to your Gemfile with:
|
20
29
|
|
@@ -30,7 +39,7 @@ You can also install it manually with:
|
|
30
39
|
gem install vainglory-api
|
31
40
|
```
|
32
41
|
|
33
|
-
|
42
|
+
## Usage
|
34
43
|
|
35
44
|
You can create an instance of the API client by initializing with your API key and [specified region](https://developer.vainglorygame.com/docs#regions) (`na` is the default):
|
36
45
|
|
@@ -38,7 +47,11 @@ You can create an instance of the API client by initializing with your API key a
|
|
38
47
|
client = VaingloryAPI.new('YOUR_API_KEY', 'na')
|
39
48
|
```
|
40
49
|
|
41
|
-
|
50
|
+
### Region Errors
|
51
|
+
|
52
|
+
A valid region short name is required when instantiating a client. Providing an invalid region short name will raise `VaingloryAPI::RegionNameError`.
|
53
|
+
|
54
|
+
### Helper Attributes
|
42
55
|
|
43
56
|
All client methods return an `OpenStruct` object containing the response attributes with some additional helper attributes.
|
44
57
|
|
@@ -50,7 +63,7 @@ response.success? # Returns true if the response code is less than 300
|
|
50
63
|
response.raw # The complete HTTP response
|
51
64
|
```
|
52
65
|
|
53
|
-
|
66
|
+
### Rate Limits
|
54
67
|
|
55
68
|
Each request will return data about your rate limits.
|
56
69
|
|
@@ -62,7 +75,7 @@ response.rate_reset # The remaining window before the rate limit is refilled
|
|
62
75
|
|
63
76
|
More information: https://developer.vainglorygame.com/docs#rate-limits
|
64
77
|
|
65
|
-
|
78
|
+
### Filtering
|
66
79
|
|
67
80
|
Currently, filters are supported by these client methods:
|
68
81
|
|
@@ -76,7 +89,7 @@ You can pass filters in as a hash using the exact Query Parameter key names outl
|
|
76
89
|
client.matches('filter[playerNames]' => 'boombastic04,IHaveNoIdea')
|
77
90
|
```
|
78
91
|
|
79
|
-
|
92
|
+
### Methods
|
80
93
|
|
81
94
|
To get __multiple matches__:
|
82
95
|
|
@@ -108,5 +121,10 @@ To get __Telemetry__ data, you must provide the data URL:
|
|
108
121
|
client.telemetry('https://gl-prod-us-east-1.s3.amazonaws.com/assets/semc-vainglory/na/2017/03/28/03/07/b0bb7faf-1363-11e7-b11e-0242ac110006-telemetry.json')
|
109
122
|
```
|
110
123
|
|
124
|
+
## Contributing
|
125
|
+
|
126
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cbortz/vainglory-api-ruby.
|
127
|
+
|
111
128
|
## License
|
129
|
+
|
112
130
|
[MIT License](LICENSE). Copyright 2017 Chet Bortz
|
data/lib/vainglory_api/client.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'ostruct'
|
3
3
|
require 'openssl'
|
4
4
|
require 'net/http'
|
5
|
+
require 'vainglory_api/region'
|
5
6
|
|
6
7
|
module VaingloryAPI
|
7
8
|
# Used to interface with the official Vainglory API
|
@@ -20,9 +21,13 @@ module VaingloryAPI
|
|
20
21
|
# @example Initialize a new client
|
21
22
|
# client = VaingloryAPI::Client.new('API_KEY', 'na')
|
22
23
|
# @return [Client] a new instance of the client
|
24
|
+
# @note Requires a valid region short name.
|
25
|
+
# @see VaingloryAPI::Region::SHORT_NAMES
|
23
26
|
def initialize(api_key, region = 'na')
|
24
27
|
@api_key = api_key
|
25
28
|
@region = region
|
29
|
+
|
30
|
+
validate_region
|
26
31
|
end
|
27
32
|
|
28
33
|
# Gets batches of random match data
|
@@ -73,11 +78,11 @@ module VaingloryAPI
|
|
73
78
|
end
|
74
79
|
|
75
80
|
# Gets data for a single match
|
81
|
+
#
|
76
82
|
# @param [String] match_id the ID of the requested match
|
77
83
|
# @example Get a single match
|
78
84
|
# client = VaingloryAPI::Client.new('API_KEY', 'na')
|
79
85
|
# client.match('MATCH_ID')
|
80
|
-
#
|
81
86
|
# @return [OpenStruct] the response and metadata
|
82
87
|
# @see https://developer.vainglorygame.com/docs#get-a-single-match Vainglory API "Get a single Match"
|
83
88
|
# @see https://developer.vainglorygame.com/docs#rosters Vainglory API "Rosters"
|
@@ -168,6 +173,10 @@ module VaingloryAPI
|
|
168
173
|
|
169
174
|
private
|
170
175
|
|
176
|
+
def validate_region
|
177
|
+
VaingloryAPI::Region.validate_short_name! @region
|
178
|
+
end
|
179
|
+
|
171
180
|
def get_request_without_headers(uri)
|
172
181
|
get_request(uri, false)
|
173
182
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module VaingloryAPI
|
4
|
+
# Helper class for metadata pertaining to regions
|
5
|
+
#
|
6
|
+
# @see https://developer.vainglorygame.com/docs#regions Vainglory API "Regions"
|
7
|
+
class Region
|
8
|
+
# Arrays of metadata about each region
|
9
|
+
DB = [
|
10
|
+
['general', 'na', 'North America'],
|
11
|
+
['general', 'eu', 'Europe'],
|
12
|
+
['general', 'sa', 'South America'],
|
13
|
+
['general', 'ea', 'East Asia'],
|
14
|
+
['general', 'sg', 'Southeast Asia (SEA)'],
|
15
|
+
['tournament', 'tournament-na', 'North America Tournaments'],
|
16
|
+
['tournament', 'tournament-eu', 'Europe Tournaments'],
|
17
|
+
['tournament', 'tournament-sa', 'South America Tournaments'],
|
18
|
+
['tournament', 'tournament-ea', 'East Asia Tournaments'],
|
19
|
+
['tournament', 'tournament-sg', 'Southeast Asia Tournaments']
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
# Unique Region types (general, tournament, etc...) extracted from DB metadata
|
23
|
+
TYPES = DB.map { |region_data| region_data[0] }.uniq.freeze
|
24
|
+
|
25
|
+
# Valid short names (na, eu, etc...) extracted from DB metadata
|
26
|
+
SHORT_NAMES = DB.map { |region_data| region_data[1] }.freeze
|
27
|
+
|
28
|
+
# @return [String] the name of the region
|
29
|
+
attr_reader :name
|
30
|
+
|
31
|
+
# @return [String] the short name of the region
|
32
|
+
attr_reader :short_name
|
33
|
+
|
34
|
+
# @return [String] the type of region
|
35
|
+
attr_reader :type
|
36
|
+
|
37
|
+
# A new instance of Region.
|
38
|
+
#
|
39
|
+
# @param (String) type the type of region (general, tournament, etc...)
|
40
|
+
# @param (String) short_name the short name of the region
|
41
|
+
# @param (String) name the name of the region
|
42
|
+
# @return [Region] a new instance of a Region
|
43
|
+
# @note Instantiation is private
|
44
|
+
def initialize(type, short_name, name)
|
45
|
+
@type = type
|
46
|
+
@short_name = short_name
|
47
|
+
@name = name
|
48
|
+
end
|
49
|
+
|
50
|
+
# Alias method for short name
|
51
|
+
#
|
52
|
+
# @return [String] the "short name" of the region
|
53
|
+
def abbreviation
|
54
|
+
@short_name
|
55
|
+
end
|
56
|
+
|
57
|
+
# Compares region to another region.
|
58
|
+
#
|
59
|
+
# @example Compare two regions
|
60
|
+
# VaingloryAPI::Region['na'].eql? VaingloryAPI::Region['na'] # => true
|
61
|
+
# VaingloryAPI::Region['na'].eql? VaingloryAPI::Region['sg'] # => false
|
62
|
+
# @param [VaingloryAPU::Region] other another region to compare for quality
|
63
|
+
# @return [Boolean] whether all attributes match
|
64
|
+
def eql?(other)
|
65
|
+
%i(name short_name type).all? { |a| send(a) == other.send(a) }
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
# Makes the contructor private
|
70
|
+
private :new
|
71
|
+
|
72
|
+
# Find a region by name or abbreviation ("short name")
|
73
|
+
#
|
74
|
+
# @example Finding a region
|
75
|
+
# VaingloryAPI::Region.find('eu')
|
76
|
+
# @example Finding a region (alternative syntax)
|
77
|
+
# VaingloryAPI::Region['eu'] # => <VaingloryAPI::Region ...>
|
78
|
+
# @param [String] identifier the target name or abbreviation of the region
|
79
|
+
# @return [Region] if the identifier is found
|
80
|
+
# @raise [VaingloryAPI::RegionNameError] if the identifier is not found
|
81
|
+
# @see DB
|
82
|
+
# @see SHORT_NAMES
|
83
|
+
def find(identifier)
|
84
|
+
new(*find_region_data(identifier)) rescue name_error(identifier)
|
85
|
+
end
|
86
|
+
alias [] find
|
87
|
+
|
88
|
+
# Checks if short name is known
|
89
|
+
#
|
90
|
+
# @example Checking if a short name is valid
|
91
|
+
# VaingloryAPI::Region.valid_short_name?('na') # => true
|
92
|
+
# VaingloryAPI::Region.valid_short_name?('QQ') # => false
|
93
|
+
# @param [String] short_name the short name of a desired region
|
94
|
+
# @return [Boolean] whether the short name is known
|
95
|
+
def valid_short_name?(short_name)
|
96
|
+
SHORT_NAMES.include?(short_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Validates a short name
|
100
|
+
#
|
101
|
+
# @example Validating a short name
|
102
|
+
# VaingloryAPI::Region.validate_short_name!('na') # => true
|
103
|
+
# VaingloryAPI::Region.validate_short_name!('QQ') # VaingloryAPI::RegionNameError
|
104
|
+
# @param [String] short_name the short name of a desired region
|
105
|
+
# @return [True] if the short name is valid
|
106
|
+
# @raise [VaingloryAPI::RegionNameError] if the short name is invalid
|
107
|
+
def validate_short_name!(short_name)
|
108
|
+
valid_short_name?(short_name) or name_error(short_name)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def find_region_data(identifier)
|
114
|
+
DB.detect { |data| data[1, 2].include?(identifier) }
|
115
|
+
end
|
116
|
+
|
117
|
+
def name_error(identifier)
|
118
|
+
raise(RegionNameError, "Couldn't find region for '#{identifier}'")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Helper exception class used to notify user of invalid names
|
124
|
+
class RegionNameError < ArgumentError; end
|
125
|
+
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe VaingloryAPI::Client, vcr: true do
|
4
|
-
subject(:klass) { Object.const_get(self.class.top_level_description) }
|
5
4
|
let(:valid_api_key) { 'valid_api_key' }
|
6
|
-
let(:client) {
|
5
|
+
let(:client) { subject.new(valid_api_key) }
|
7
6
|
let(:cached_matches) { let_cassette('matches') { client.matches } }
|
8
7
|
let(:cached_players) { cached_matches.included.select { |i| i.type == 'player' }}
|
9
8
|
|
10
|
-
|
9
|
+
it 'validates the region' do
|
10
|
+
expect { subject.new('API KEY', 'QQ') }.to raise_error VaingloryAPI::RegionNameError
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'metadata' do
|
11
14
|
it 'returns an error with an invalid API key' do
|
12
15
|
VCR.use_cassette('api_key', record: :new_episodes) do
|
13
|
-
response =
|
16
|
+
response = subject.new('invalid-api-key').samples
|
14
17
|
expects_error_response(response, 401)
|
15
18
|
end
|
16
19
|
end
|
@@ -30,14 +33,14 @@ describe VaingloryAPI::Client, vcr: true do
|
|
30
33
|
it 'supports multiple regions' do
|
31
34
|
VCR.use_cassette('samples', record: :new_episodes) do
|
32
35
|
%w(eu sa ea sg).each do |region|
|
33
|
-
response =
|
36
|
+
response = subject.new(valid_api_key, region).samples
|
34
37
|
expects_success_response(response)
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
40
|
-
|
43
|
+
describe '#status' do
|
41
44
|
it 'returns a status object' do
|
42
45
|
VCR.use_cassette('status') do
|
43
46
|
response = client.status
|
@@ -52,7 +55,7 @@ describe VaingloryAPI::Client, vcr: true do
|
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
|
-
|
58
|
+
describe '#players' do
|
56
59
|
it 'returns an array of players with a valid name' do
|
57
60
|
VCR.use_cassette('players', record: :new_episodes) do
|
58
61
|
valid_names = cached_players[0, 2].map { |p| p.attributes.name }
|
@@ -73,7 +76,7 @@ describe VaingloryAPI::Client, vcr: true do
|
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
76
|
-
|
79
|
+
describe '#player' do
|
77
80
|
it 'returns a player with a valid ID' do
|
78
81
|
VCR.use_cassette('player', record: :new_episodes) do
|
79
82
|
cached_player_id = cached_players.first.id
|
@@ -109,7 +112,7 @@ describe VaingloryAPI::Client, vcr: true do
|
|
109
112
|
end
|
110
113
|
end
|
111
114
|
|
112
|
-
|
115
|
+
describe '#matches' do
|
113
116
|
it 'returns an array of matches' do
|
114
117
|
VCR.use_cassette('matches', record: :new_episodes) do
|
115
118
|
response = client.matches
|
@@ -152,7 +155,7 @@ describe VaingloryAPI::Client, vcr: true do
|
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
155
|
-
|
158
|
+
describe '#match' do
|
156
159
|
it 'returns a match with a valid ID' do
|
157
160
|
VCR.use_cassette('match', record: :new_episodes) do
|
158
161
|
cached_match_id = cached_matches.data.first.id
|
@@ -189,7 +192,7 @@ describe VaingloryAPI::Client, vcr: true do
|
|
189
192
|
end
|
190
193
|
end
|
191
194
|
|
192
|
-
|
195
|
+
describe '#telemetry' do
|
193
196
|
it 'returns telemetry data for a valid URL' do
|
194
197
|
VCR.use_cassette('telemetry', record: :new_episodes) do
|
195
198
|
response = client.telemetry('https://gl-prod-us-east-1.s3.amazonaws.com/assets/semc-vainglory/na/2017/03/28/03/07/b0bb7faf-1363-11e7-b11e-0242ac110006-telemetry.json')
|
@@ -204,19 +207,19 @@ describe VaingloryAPI::Client, vcr: true do
|
|
204
207
|
end
|
205
208
|
end
|
206
209
|
|
207
|
-
|
210
|
+
describe '#teams' do
|
208
211
|
it 'raises error' do
|
209
212
|
expect { client.teams }.to raise_error(NotImplementedError)
|
210
213
|
end
|
211
214
|
end
|
212
215
|
|
213
|
-
|
216
|
+
describe '#team' do
|
214
217
|
it 'raises error' do
|
215
218
|
expect { client.team('team_id') }.to raise_error(NotImplementedError)
|
216
219
|
end
|
217
220
|
end
|
218
221
|
|
219
|
-
|
222
|
+
describe '#link' do
|
220
223
|
it 'raises error' do
|
221
224
|
expect { client.link('link_id') }.to raise_error(NotImplementedError)
|
222
225
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VaingloryAPI::Region do
|
4
|
+
describe '#abbreviation' do
|
5
|
+
it 'returns the short name' do
|
6
|
+
region = subject.find('ea')
|
7
|
+
expect(region.abbreviation).to eq region.short_name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#eql?' do
|
12
|
+
let(:region) { VaingloryAPI::Region['na'] }
|
13
|
+
|
14
|
+
it 'returns TRUE when all attributes match' do
|
15
|
+
expect(region.eql?(VaingloryAPI::Region.find('na'))).to be true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns FALSE when any attribute does not match' do
|
19
|
+
expect(region.eql?(VaingloryAPI::Region.find('eu'))).to be false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.new' do
|
24
|
+
it 'does not allow instantiation publicly' do
|
25
|
+
expect { subject.new(nil, nil, nil) }.to raise_error NoMethodError
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.find' do
|
30
|
+
it 'finds a region by name' do
|
31
|
+
expect(subject.find('North America')).to be_an_instance_of(subject)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'find a region by short name (abbreviation)' do
|
35
|
+
expect(subject.find('eu')).to be_an_instance_of(subject)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises an error when region not found' do
|
39
|
+
expect { subject.find('QQ') }.to raise_error VaingloryAPI::RegionNameError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.[]' do
|
44
|
+
it 'aliases .find' do
|
45
|
+
expect(subject['na']).to eql subject.find('na')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.valid_short_name?' do
|
50
|
+
it 'returns TRUE when the short name is found' do
|
51
|
+
expect(subject.valid_short_name?('tournament-sa')).to be true
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns FALSE when the short name is not found' do
|
55
|
+
expect(subject.valid_short_name?('QQ')).to be false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '.validate_short_name!' do
|
60
|
+
it 'returns TRUE when the short name is found' do
|
61
|
+
expect(subject.validate_short_name!('tournament-sg')).to be true
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'raises an error when the short name is not found' do
|
65
|
+
expect { subject.validate_short_name!('QQ') }.to raise_error VaingloryAPI::RegionNameError
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe VaingloryAPI do
|
4
|
-
subject(:klass) { Object.const_get(self.class.top_level_description) }
|
5
|
-
|
6
4
|
it 'allows instantiation of a Client' do
|
7
|
-
client =
|
8
|
-
expect(client).to be_an_instance_of(
|
5
|
+
client = subject.new('API_KEY')
|
6
|
+
expect(client).to be_an_instance_of(subject::Client)
|
9
7
|
end
|
10
8
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module KlassExampleGroup
|
2
|
+
def self.included(base)
|
3
|
+
base.instance_eval do
|
4
|
+
# Make the class available as `subject` in your examples:
|
5
|
+
subject { Object.const_get(self.class.top_level_description) }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
# Tag service specs with `:service` metadata or put them in the spec/services dir
|
13
|
+
config.define_derived_metadata(:file_path => %r{/spec/lib/}) do |metadata|
|
14
|
+
metadata[:type] = :klass
|
15
|
+
end
|
16
|
+
|
17
|
+
config.include KlassExampleGroup, type: :klass
|
18
|
+
end
|
data/vainglory_api.gemspec
CHANGED
@@ -4,8 +4,8 @@ require 'vainglory_api/version'
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'vainglory-api'
|
6
6
|
s.version = VaingloryAPI::VERSION.dup
|
7
|
+
s.date = VaingloryAPI::RELEASE_DATE.dup
|
7
8
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.date = '2017-03-28'
|
9
9
|
s.summary = 'Vainglory API'
|
10
10
|
s.description = 'A Ruby libary wrapper for the Vainglory API'
|
11
11
|
s.authors = ['Chet Bortz']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vainglory-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chet Bortz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- lib/vainglory_api.rb
|
98
98
|
- lib/vainglory_api/client.rb
|
99
|
+
- lib/vainglory_api/region.rb
|
99
100
|
- lib/vainglory_api/version.rb
|
100
101
|
- spec/cassettes/api_key.yml
|
101
102
|
- spec/cassettes/match.yml
|
@@ -106,8 +107,10 @@ files:
|
|
106
107
|
- spec/cassettes/status.yml
|
107
108
|
- spec/cassettes/telemetry.yml
|
108
109
|
- spec/lib/vainglory_api/client_spec.rb
|
110
|
+
- spec/lib/vainglory_api/region_spec.rb
|
109
111
|
- spec/lib/vainglory_api_spec.rb
|
110
112
|
- spec/spec_helper.rb
|
113
|
+
- spec/support/klasses.rb
|
111
114
|
- vainglory_api.gemspec
|
112
115
|
homepage: https://github.com/cbortz/vainglory-api-ruby
|
113
116
|
licenses:
|
@@ -143,5 +146,7 @@ test_files:
|
|
143
146
|
- spec/cassettes/status.yml
|
144
147
|
- spec/cassettes/telemetry.yml
|
145
148
|
- spec/lib/vainglory_api/client_spec.rb
|
149
|
+
- spec/lib/vainglory_api/region_spec.rb
|
146
150
|
- spec/lib/vainglory_api_spec.rb
|
147
151
|
- spec/spec_helper.rb
|
152
|
+
- spec/support/klasses.rb
|