dota 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/dota.rb +1 -0
- data/lib/dota/api/basic_player.rb +1 -1
- data/lib/dota/api/client.rb +5 -4
- data/lib/dota/api/hero.rb +5 -0
- data/lib/dota/api/match.rb +1 -1
- data/lib/dota/api/match/player.rb +6 -2
- data/lib/dota/api/missing_hero.rb +13 -0
- data/lib/dota/configuration.rb +7 -2
- data/lib/dota/version.rb +1 -1
- data/spec/dota/api/hero_spec.rb +6 -0
- data/spec/dota/api/live_match/player_spec.rb +1 -0
- data/spec/dota/api/match/player_spec.rb +1 -0
- data/spec/dota/api/match_spec.rb +11 -4
- data/spec/dota/api/missing_hero_spec.rb +16 -0
- data/spec/dota_spec.rb +18 -4
- data/spec/fixtures/vcr_cassettes/GetFriendList.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetLeagueListing.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetLiveLeagueGames.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetMatchDetails.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetMatchHistory.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetRarities.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetScheduledLeagueGames.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetTeamInfoByTeamID.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetTeamInfoByTeamID_many.yml +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96a945aaf9d39392aa65f1bc19051304bbdd143
|
4
|
+
data.tar.gz: d7ac4845c2627e16fa887f91404ca1dc1886caaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49d7105f8d74f307580dc5f2a162ffa5c6fdd61130783603ecfeed8a222ca5b27b2c43fb97d1446ced0f30f6dc4104c6a19e0a7dd87d68ef676e5d904769267
|
7
|
+
data.tar.gz: 4e52f0ed5b26aa31f2fc8ef2ce943305b26b82ca0fe3a0b0a670404ef5a8ccf72711b085529e86e427b0f384cda4997a634bafca83d87753756ebe91c400b98d
|
data/README.md
CHANGED
@@ -42,6 +42,9 @@ Get your Steam API key [here](http://steamcommunity.com/dev/apikey) and make sur
|
|
42
42
|
```ruby
|
43
43
|
Dota.configure do |config|
|
44
44
|
config.api_key = ENV.fetch("STEAM_API_KEY")
|
45
|
+
|
46
|
+
# Set API version (defaults to "v1")
|
47
|
+
# config.api_version = "v1"
|
45
48
|
end
|
46
49
|
```
|
47
50
|
|
@@ -74,7 +77,7 @@ api.matches(789645621) # => A single match - "Newbee vs Vici Gaming"
|
|
74
77
|
api.matches # => A list of matches
|
75
78
|
api.matches(hero_id: 43) # Allowed options:
|
76
79
|
#
|
77
|
-
# :hero_id - Integer, With this hero. See Dota::API::Hero
|
80
|
+
# :hero_id - Integer, With this hero. See Dota::API::Hero.mapping
|
78
81
|
# :after - Integer, With match IDs equal or greater than this
|
79
82
|
# :player_id - Integer, With this player (32-bit Steam ID)
|
80
83
|
# :league_id - Integer, In this league. Use Dota.leagues to get a list of leagues
|
@@ -109,6 +112,12 @@ For the unsupported endpoints, you can use `api.get`. For example, the following
|
|
109
112
|
api.get("IDOTA2Match_570", "GetMatchDetails", match_id: 789645621)
|
110
113
|
```
|
111
114
|
|
115
|
+
Setting `api_version` here also overrides the current configuration:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
api.get("IDOTA2Match_570", "GetMatchDetails", match_id: 789645621, api_version: "v1")
|
119
|
+
```
|
120
|
+
|
112
121
|
### API Objects
|
113
122
|
|
114
123
|
#### Heroes
|
@@ -185,7 +194,7 @@ match.drafts # Array[Dota::API::Match::Draft], Picks and bans in the mat
|
|
185
194
|
draft.order # Integer, 1-20
|
186
195
|
draft.pick? # Boolean, true if the draft is a pick, and not a ban
|
187
196
|
draft.team # Symbol, :radiant or :dire
|
188
|
-
draft.hero # Dota::API::Hero, Picked or banned hero
|
197
|
+
draft.hero # Dota::API::Hero || Dota::API::MissingHero, Picked or banned hero
|
189
198
|
```
|
190
199
|
|
191
200
|
#### Live Matches
|
@@ -239,7 +248,7 @@ radiant.series_wins # Integer, Number of wins in the series so far
|
|
239
248
|
|
240
249
|
```ruby
|
241
250
|
player.id # Integer, 32-bit Steam ID
|
242
|
-
player.hero # Dota::API::Hero, Player's hero
|
251
|
+
player.hero # Dota::API::Hero || Dota::API::MissingHero, Player's hero
|
243
252
|
player.items # Array[Dota::API::Item], Player's inventory (6 items)
|
244
253
|
player.slot # Integer, (1-5)
|
245
254
|
player.level # Integer, The player's level at match end
|
data/lib/dota.rb
CHANGED
@@ -27,6 +27,7 @@ require 'dota/api/match/player'
|
|
27
27
|
require 'dota/api/match/side'
|
28
28
|
require 'dota/api/match/unit'
|
29
29
|
require 'dota/api/match/ability_upgrade'
|
30
|
+
require 'dota/api/missing_hero'
|
30
31
|
require 'dota/api/scheduled_match'
|
31
32
|
require 'dota/api/team'
|
32
33
|
require 'dota/api/ability'
|
data/lib/dota/api/client.rb
CHANGED
@@ -13,7 +13,7 @@ module Dota
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def heroes(id = nil)
|
16
|
-
id ? Hero.
|
16
|
+
id ? Hero.find(id) : Hero.all
|
17
17
|
end
|
18
18
|
|
19
19
|
def items(id = nil)
|
@@ -100,13 +100,14 @@ module Dota
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
def get(interface, method, params = {}
|
104
|
-
do_request(method, params, interface
|
103
|
+
def get(interface, method, params = {})
|
104
|
+
do_request(method, params, interface)
|
105
105
|
end
|
106
106
|
|
107
107
|
private
|
108
108
|
|
109
|
-
def do_request(method, params, interface = "IDOTA2Match_570"
|
109
|
+
def do_request(method, params, interface = "IDOTA2Match_570")
|
110
|
+
method_version = params.delete(:api_version) || configuration.api_version
|
110
111
|
url = "https://api.steampowered.com/#{interface}/#{method}/#{method_version}/"
|
111
112
|
|
112
113
|
@faraday = Faraday.new(url) do |faraday|
|
data/lib/dota/api/hero.rb
CHANGED
data/lib/dota/api/match.rb
CHANGED
@@ -36,11 +36,15 @@ module Dota
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def additional_units
|
39
|
-
raw["additional_units"]
|
39
|
+
raw["additional_units"] ?
|
40
|
+
raw["additional_units"].map { |unit| Unit.new(unit["unitname"], extract_items_from(unit)) } :
|
41
|
+
[]
|
40
42
|
end
|
41
43
|
|
42
44
|
def ability_upgrades
|
43
|
-
raw["ability_upgrades"]
|
45
|
+
raw["ability_upgrades"] ?
|
46
|
+
raw["ability_upgrades"].map { |ability_upgrade| AbilityUpgrade.new(ability_upgrade) } :
|
47
|
+
[]
|
44
48
|
end
|
45
49
|
|
46
50
|
def items
|
data/lib/dota/configuration.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
module Dota
|
2
2
|
class Configuration
|
3
|
-
|
3
|
+
DEFAULT_API_VERSION = "v1"
|
4
|
+
OPTIONS = [:api_key, :api_version].freeze
|
4
5
|
|
5
|
-
attr_accessor :api_key
|
6
|
+
attr_accessor :api_key, :api_version
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@api_version = DEFAULT_API_VERSION
|
10
|
+
end
|
6
11
|
end
|
7
12
|
end
|
data/lib/dota/version.rb
CHANGED
data/spec/dota/api/hero_spec.rb
CHANGED
@@ -7,6 +7,12 @@ RSpec.describe Dota::API::Hero do
|
|
7
7
|
expect(heroes.count).to eq 110
|
8
8
|
end
|
9
9
|
|
10
|
+
specify ".find" do
|
11
|
+
expect(described_class.find(69)).to be_a Dota::API::Hero
|
12
|
+
expect(described_class.find(nil)).to be_a Dota::API::MissingHero
|
13
|
+
expect(described_class.find("abc")).to be_a Dota::API::MissingHero
|
14
|
+
end
|
15
|
+
|
10
16
|
specify "#id" do
|
11
17
|
expect(hero.id).to eq 69
|
12
18
|
end
|
data/spec/dota/api/match_spec.rb
CHANGED
@@ -29,10 +29,17 @@ RSpec.describe Dota::API::Match do
|
|
29
29
|
expect(match.mode_id).to eq 2
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
describe "#drafts" do
|
33
|
+
specify "match with drafts" do
|
34
|
+
drafts = match.drafts
|
35
|
+
expect(drafts.count).to eq 20
|
36
|
+
expect(drafts.first).to be_a Dota::API::Match::Draft
|
37
|
+
end
|
38
|
+
|
39
|
+
specify "match without drafts" do
|
40
|
+
expect(match.raw).to receive(:[]).with("picks_bans") { nil }
|
41
|
+
expect(match.drafts).to eq []
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
specify "#sequence" do
|
@@ -0,0 +1,16 @@
|
|
1
|
+
RSpec.describe Dota::API::MissingHero do
|
2
|
+
let(:hero) { described_class.new(nil) }
|
3
|
+
|
4
|
+
specify "#id" do
|
5
|
+
expect(hero.id).to eq nil
|
6
|
+
end
|
7
|
+
|
8
|
+
specify "#name" do
|
9
|
+
expect(hero.name).to eq nil
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "#image_url" do
|
13
|
+
expect(hero.image_url).to eq nil
|
14
|
+
expect(hero.image_url(:something)).to eq nil
|
15
|
+
end
|
16
|
+
end
|
data/spec/dota_spec.rb
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
RSpec.describe Dota do
|
2
2
|
describe "configuration" do
|
3
3
|
it "accepts an api key" do
|
4
|
-
|
4
|
+
api_key = SecureRandom.hex
|
5
5
|
Dota.configure do |config|
|
6
|
-
config.api_key =
|
6
|
+
config.api_key = api_key
|
7
7
|
end
|
8
8
|
|
9
|
-
expect(Dota.configuration.api_key).to eq
|
9
|
+
expect(Dota.configuration.api_key).to eq api_key
|
10
|
+
end
|
11
|
+
|
12
|
+
it "accepts an api version" do
|
13
|
+
expect(Dota.configuration.api_version).to eq "v1"
|
14
|
+
|
15
|
+
Dota.configure do |config|
|
16
|
+
config.api_version = "v2"
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(Dota.configuration.api_version).to eq "v2"
|
10
20
|
end
|
11
21
|
end
|
12
22
|
|
@@ -207,7 +217,11 @@ RSpec.describe Dota do
|
|
207
217
|
describe "#get" do
|
208
218
|
it "allows custom API requests" do
|
209
219
|
VCR.use_cassette("GetRarities") do
|
210
|
-
|
220
|
+
# Expect api_version override to work
|
221
|
+
api.configuration.api_version = "v99999"
|
222
|
+
expect(Faraday).to receive(:new).with(/\/v1/).and_call_original
|
223
|
+
|
224
|
+
response = api.get("IEconDOTA2_570", "GetRarities", { api_version: "v1", language: "en" })
|
211
225
|
expect(response["result"]["count"]).to eq 8
|
212
226
|
end
|
213
227
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/ISteamUser/GetFriendList/
|
5
|
+
uri: https://api.steampowered.com/ISteamUser/GetFriendList/v1/?key=<STEAM_API_KEY>&steamid=76561198052976237
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetLeagueListing/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetLeagueListing/v1/?key=<STEAM_API_KEY>&language=en
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetLiveLeagueGames/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetLiveLeagueGames/v1/?key=<STEAM_API_KEY>
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/v1/?key=<STEAM_API_KEY>&match_id=1430857330
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=<STEAM_API_KEY>
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IEconDOTA2_570/GetRarities/
|
5
|
+
uri: https://api.steampowered.com/IEconDOTA2_570/GetRarities/v1/?key=<STEAM_API_KEY>&language=en
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetScheduledLeagueGames/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetScheduledLeagueGames/v1/?key=<STEAM_API_KEY>
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v1/?key=<STEAM_API_KEY>&start_at_team_id=1375614&teams_requested=1
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/
|
5
|
+
uri: https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v1/?key=<STEAM_API_KEY>
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dota
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinni Carlo Caños
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- lib/dota/api/match/player.rb
|
206
206
|
- lib/dota/api/match/side.rb
|
207
207
|
- lib/dota/api/match/unit.rb
|
208
|
+
- lib/dota/api/missing_hero.rb
|
208
209
|
- lib/dota/api/scheduled_match.rb
|
209
210
|
- lib/dota/api/team.rb
|
210
211
|
- lib/dota/configuration.rb
|
@@ -226,6 +227,7 @@ files:
|
|
226
227
|
- spec/dota/api/match/side_spec.rb
|
227
228
|
- spec/dota/api/match/unit_spec.rb
|
228
229
|
- spec/dota/api/match_spec.rb
|
230
|
+
- spec/dota/api/missing_hero_spec.rb
|
229
231
|
- spec/dota/api/scheduled_match_spec.rb
|
230
232
|
- spec/dota/api/team_spec.rb
|
231
233
|
- spec/dota_spec.rb
|
@@ -280,6 +282,7 @@ test_files:
|
|
280
282
|
- spec/dota/api/match/side_spec.rb
|
281
283
|
- spec/dota/api/match/unit_spec.rb
|
282
284
|
- spec/dota/api/match_spec.rb
|
285
|
+
- spec/dota/api/missing_hero_spec.rb
|
283
286
|
- spec/dota/api/scheduled_match_spec.rb
|
284
287
|
- spec/dota/api/team_spec.rb
|
285
288
|
- spec/dota_spec.rb
|