dota 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -32
- data/lib/dota.rb +2 -1
- data/lib/dota/api/client.rb +7 -0
- data/lib/dota/api/cosmetic/rarity.rb +31 -0
- data/lib/dota/api/match.rb +1 -1
- data/lib/dota/api/match/draft.rb +4 -0
- data/lib/dota/version.rb +1 -1
- data/spec/dota/api/cosmetic/rarity_spec.rb +12 -0
- data/spec/dota/api/match/draft_spec.rb +4 -0
- data/spec/dota/api/match_spec.rb +2 -2
- data/spec/dota_spec.rb +7 -0
- data/spec/fixtures/vcr_cassettes/GetRarities.yml +48 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75461cf111d77eeb914651d773cd93d245302b3d
|
4
|
+
data.tar.gz: 55187c81f399c51cad995c0dee7720ccf79bf394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3496ade2cde5f857dcd476cca08db4855fcc6b482faeb62e30c105141a2fb11bafc8c258283eaf87ac83667faccc3ece7096712da2448503c8339544ff7fc15
|
7
|
+
data.tar.gz: a3d2fe97b094882165ff0136498bd0a5fc6a65faed9a2504daa9729a9a6c5effd136e55c9de22ac9a339304114c4bf4c47600304d5c5e44531507caae6a5f650
|
data/README.md
CHANGED
@@ -1,9 +1,23 @@
|
|
1
1
|
# Dota [![Gem Version](https://badge.fury.io/rb/dota.svg)](http://badge.fury.io/rb/dota) [![Build Status](https://travis-ci.org/vinnicc/dota.svg?branch=master)](https://travis-ci.org/vinnicc/dota)
|
2
2
|
|
3
|
-
`dota` is a Ruby client for the [Dota 2 WebAPI](https://wiki.teamfortress.com/wiki/WebAPI#Dota_2). It provides an easy way to access matches, players, heroes, items, and other public Dota 2 objects in an opinionated manner.
|
3
|
+
`dota` is a Ruby client for the [Dota 2 WebAPI](https://wiki.teamfortress.com/wiki/WebAPI#Dota_2). It provides an easy way to access matches, players, heroes, items, and other public Dota 2 objects in an opinionated manner. Check out their [documentation](https://wiki.teamfortress.com/wiki/WebAPI#Dota_2) or [this post](http://dev.dota2.com/showthread.php?t=58317) to learn more.
|
4
|
+
|
5
|
+
Currently supported endpoints:
|
6
|
+
|
7
|
+
- [GetMatchDetails](https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails)
|
8
|
+
- [GetMatchHistory](https://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory)
|
4
9
|
|
5
10
|
This gem is in alpha, keep that in mind when upgrading.
|
6
11
|
|
12
|
+
## TODO
|
13
|
+
|
14
|
+
- Support for more endpoints
|
15
|
+
- Validations and error classes
|
16
|
+
- More configuration options
|
17
|
+
- Move API documentation to [readthedocs.org](https://readthedocs.org/) or somewhere else
|
18
|
+
- Better search filters
|
19
|
+
- Computed attributes such as win rates, hero usage, etc.
|
20
|
+
|
7
21
|
## Installation
|
8
22
|
|
9
23
|
Add this line to your application's Gemfile:
|
@@ -28,20 +42,22 @@ Dota.configure do |config|
|
|
28
42
|
end
|
29
43
|
```
|
30
44
|
|
31
|
-
Get your Steam API key [here](http://steamcommunity.com/dev/apikey).
|
45
|
+
Get your Steam API key [here](http://steamcommunity.com/dev/apikey).
|
32
46
|
|
33
47
|
```ruby
|
34
48
|
api = Dota.api
|
35
49
|
|
36
|
-
api.heroes(43) # A single hero
|
37
|
-
api.heroes # All heroes
|
50
|
+
api.heroes(43) # (Cached) A single hero - Death Prophet
|
51
|
+
api.heroes # (Cached) All heroes
|
38
52
|
|
39
|
-
api.items(114) # A single item
|
40
|
-
api.items # All items
|
53
|
+
api.items(114) # (Cached) A single item - Heart of Tarrasque
|
54
|
+
api.items # (Cached) All items
|
55
|
+
|
56
|
+
api.cosmetic_rarities # All cosmetic rarities
|
41
57
|
|
42
58
|
api.leagues # All leagues
|
43
59
|
|
44
|
-
api.matches(789645621) # A single match
|
60
|
+
api.matches(789645621) # A single match - Newbee vs Vici Gaming
|
45
61
|
api.matches # A list of matches
|
46
62
|
api.matches(hero_id: 43) # Allowed options:
|
47
63
|
#
|
@@ -58,11 +74,7 @@ api.matches(hero_id: 43) # Allowed options:
|
|
58
74
|
# :limit - Integer, Amount of matches to return (default is 100)
|
59
75
|
```
|
60
76
|
|
61
|
-
|
62
|
-
|
63
|
-
You won't need to instantiate on these classes directly and it's not advisable to do so as the API might change anytime. Starting with the call to `Dota.api` should be enough in most cases.
|
64
|
-
|
65
|
-
#### Dota::API::Hero
|
77
|
+
#### Heroes
|
66
78
|
|
67
79
|
```ruby
|
68
80
|
hero.id # => 43
|
@@ -70,7 +82,7 @@ hero.name # => "Death Prophet"
|
|
70
82
|
hero.image_url # => "http://cdn.dota2.com/apps/dota2/images/heroes/death_prophet_full.png"
|
71
83
|
```
|
72
84
|
|
73
|
-
####
|
85
|
+
#### Items
|
74
86
|
|
75
87
|
```ruby
|
76
88
|
item.id # => 114
|
@@ -78,7 +90,20 @@ item.name # => "Heart of Tarrasque"
|
|
78
90
|
item.image_url # => "http://cdn.dota2.com/apps/dota2/images/items/heart_lg.png"
|
79
91
|
```
|
80
92
|
|
81
|
-
####
|
93
|
+
#### Leagues
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
league.id # => 600
|
97
|
+
league.name # => "The International 2014"
|
98
|
+
league.description # => "The Aegis of Champions hangs in the balance. See the world's top teams battle in the International."
|
99
|
+
league.url # => "http://www.dota2.com/international/overview/"
|
100
|
+
```
|
101
|
+
|
102
|
+
#### Matches
|
103
|
+
|
104
|
+
Caveat: Getting a list of matches via `api.matches` will call [GetMatchHistory](https://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory) which has very few attributes for the matches returned (obviously for performance reasons), as opposed to getting info about a particular match via `api.matches(id)` which will instead call [GetMatchDetails](https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails). In both cases, the matches returned will be instances of `Dota::API::Match`. In the future, there will be subclasses to distinguish the two.
|
105
|
+
|
106
|
+
When an instance method in a `Dota::API::Match` class returns `nil`, it most likely means the endpoint called doesn't support the value required yet.
|
82
107
|
|
83
108
|
```ruby
|
84
109
|
match.id # => 789645621
|
@@ -97,7 +122,7 @@ match.first_blood # => 33
|
|
97
122
|
match.positive_votes # => 34701
|
98
123
|
match.negative_votes # => 13291
|
99
124
|
match.season # => nil
|
100
|
-
match.
|
125
|
+
match.players_count # => 10
|
101
126
|
match.cluster # => 111
|
102
127
|
match.radiant_tower_status # => 2039
|
103
128
|
match.dire_tower_status # => 1974
|
@@ -105,7 +130,7 @@ match.radiant_barracks_status # => 63
|
|
105
130
|
match.dire_barracks_status # => 63
|
106
131
|
```
|
107
132
|
|
108
|
-
####
|
133
|
+
#### Players
|
109
134
|
|
110
135
|
```ruby
|
111
136
|
player.id # => 98887913
|
@@ -128,32 +153,24 @@ player.tower_damage # => 153
|
|
128
153
|
player.hero_healing # => 526
|
129
154
|
```
|
130
155
|
|
131
|
-
####
|
156
|
+
#### Drafts
|
132
157
|
|
133
158
|
```ruby
|
134
|
-
draft.hero # => Dota::API::Hero
|
135
159
|
draft.order # => 1
|
136
160
|
draft.pick? # => true
|
161
|
+
draft.team # => :radiant
|
162
|
+
draft.hero # => Dota::API::Hero
|
137
163
|
```
|
138
164
|
|
139
|
-
####
|
165
|
+
#### Cosmetic Rarities
|
140
166
|
|
141
167
|
```ruby
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
168
|
+
rarity.id # => 1
|
169
|
+
rarity.order # => 0
|
170
|
+
rarity.color # => "#e4ae39"
|
171
|
+
rarity.name # => "Immortal"
|
146
172
|
```
|
147
173
|
|
148
|
-
## TODO
|
149
|
-
|
150
|
-
- Validations and error classes
|
151
|
-
- More configuration options
|
152
|
-
- Move API documentation to [readthedocs.org](https://readthedocs.org/) or somewhere else
|
153
|
-
- Implement all Dota 2 WebAPI methods
|
154
|
-
- Better search filters
|
155
|
-
- Computed attributes such as win rates, hero usage, etc.
|
156
|
-
|
157
174
|
## Contributing
|
158
175
|
|
159
176
|
1. [Fork it!](https://github.com/vinnicc/dota/fork)
|
data/lib/dota.rb
CHANGED
@@ -4,12 +4,13 @@ require 'dota/version'
|
|
4
4
|
require 'dota/utils/inspect'
|
5
5
|
|
6
6
|
require 'dota/api/client'
|
7
|
+
require 'dota/api/cosmetic/rarity'
|
7
8
|
require 'dota/api/hero'
|
8
9
|
require 'dota/api/item'
|
9
10
|
require 'dota/api/league'
|
10
11
|
require 'dota/api/match'
|
11
|
-
require 'dota/api/match/player'
|
12
12
|
require 'dota/api/match/draft'
|
13
|
+
require 'dota/api/match/player'
|
13
14
|
|
14
15
|
module Dota
|
15
16
|
class << self
|
data/lib/dota/api/client.rb
CHANGED
@@ -49,6 +49,13 @@ module Dota
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def cosmetic_rarities
|
53
|
+
response = do_request("GetRarities", { language: "en" }, "IEconDOTA2_570")["result"]
|
54
|
+
if response && (rarities = response["rarities"])
|
55
|
+
rarities.map { |rarity| Cosmetic::Rarity.new(rarity) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
52
59
|
private
|
53
60
|
|
54
61
|
def do_request(method, params = {}, interface = "IDOTA2Match_570", method_version = "V001")
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class Cosmetic
|
4
|
+
class Rarity
|
5
|
+
def initialize(raw)
|
6
|
+
@raw = raw
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
raw["id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def order
|
14
|
+
raw["order"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def color
|
18
|
+
raw["color"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
raw["localized_name"]
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :raw
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/dota/api/match.rb
CHANGED
data/lib/dota/api/match/draft.rb
CHANGED
data/lib/dota/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Dota::API::Cosmetic::Rarity do
|
2
|
+
let(:rarity) do
|
3
|
+
VCR.use_cassette("GetRarities") do
|
4
|
+
test_client.cosmetic_rarities.last
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
specify("#id") { expect(rarity.id).to eq 7 }
|
9
|
+
specify("#order") { expect(rarity.order).to eq 6 }
|
10
|
+
specify("#color") { expect(rarity.color).to eq "#e4ae39" }
|
11
|
+
specify("#name") { expect(rarity.name).to eq "Immortal" }
|
12
|
+
end
|
data/spec/dota/api/match_spec.rb
CHANGED
data/spec/dota_spec.rb
CHANGED
@@ -93,5 +93,12 @@ describe Dota do
|
|
93
93
|
expect(league).to be_a Dota::API::League
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
specify "#cosmetic_rarities" do
|
98
|
+
VCR.use_cassette("GetRarities") do
|
99
|
+
rarities = api.cosmetic_rarities
|
100
|
+
expect(rarities.first).to be_a Dota::API::Cosmetic::Rarity
|
101
|
+
end
|
102
|
+
end
|
96
103
|
end
|
97
104
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.steampowered.com/IEconDOTA2_570/GetRarities/V001/?key=2FBBA83745F494FAE688AFB8463CD4FC&language=en
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.9
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Expires:
|
22
|
+
- Thu, 20 Nov 2014 21:13:59 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=UTF-8
|
25
|
+
Content-Length:
|
26
|
+
- '907'
|
27
|
+
Date:
|
28
|
+
- Thu, 20 Nov 2014 21:13:59 GMT
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: "{\n\t\"result\": {\n\t\t\"count\": 8,\n\t\t\"rarities\": [\n\t\t\t{\n\t\t\t\t\"name\":
|
32
|
+
\"common\",\n\t\t\t\t\"id\": 1,\n\t\t\t\t\"order\": 0,\n\t\t\t\t\"color\":
|
33
|
+
\"#b0c3d9\",\n\t\t\t\t\"localized_name\": \"Common\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\":
|
34
|
+
\"uncommon\",\n\t\t\t\t\"id\": 2,\n\t\t\t\t\"order\": 1,\n\t\t\t\t\"color\":
|
35
|
+
\"#5e98d9\",\n\t\t\t\t\"localized_name\": \"Uncommon\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\":
|
36
|
+
\"rare\",\n\t\t\t\t\"id\": 3,\n\t\t\t\t\"order\": 2,\n\t\t\t\t\"color\": \"#4b69ff\",\n\t\t\t\t\"localized_name\":
|
37
|
+
\"Rare\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"mythical\",\n\t\t\t\t\"id\":
|
38
|
+
4,\n\t\t\t\t\"order\": 3,\n\t\t\t\t\"color\": \"#8847ff\",\n\t\t\t\t\"localized_name\":
|
39
|
+
\"Mythical\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"legendary\",\n\t\t\t\t\"id\":
|
40
|
+
5,\n\t\t\t\t\"order\": 4,\n\t\t\t\t\"color\": \"#d32ce6\",\n\t\t\t\t\"localized_name\":
|
41
|
+
\"Legendary\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"ancient\",\n\t\t\t\t\"id\":
|
42
|
+
6,\n\t\t\t\t\"order\": 5,\n\t\t\t\t\"color\": \"#eb4b4b\",\n\t\t\t\t\"localized_name\":
|
43
|
+
\"Ancient\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"immortal\",\n\t\t\t\t\"id\":
|
44
|
+
7,\n\t\t\t\t\"order\": 6,\n\t\t\t\t\"color\": \"#e4ae39\",\n\t\t\t\t\"localized_name\":
|
45
|
+
\"Immortal\"\n\t\t\t}\n\t\t]\n\t\t,\n\t\t\"status\": 200\n\t}\n}"
|
46
|
+
http_version:
|
47
|
+
recorded_at: Thu, 20 Nov 2014 21:13:59 GMT
|
48
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinni Carlo Caños
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- dota.gemspec
|
141
141
|
- lib/dota.rb
|
142
142
|
- lib/dota/api/client.rb
|
143
|
+
- lib/dota/api/cosmetic/rarity.rb
|
143
144
|
- lib/dota/api/hero.rb
|
144
145
|
- lib/dota/api/item.rb
|
145
146
|
- lib/dota/api/league.rb
|
@@ -149,6 +150,7 @@ files:
|
|
149
150
|
- lib/dota/configuration.rb
|
150
151
|
- lib/dota/utils/inspect.rb
|
151
152
|
- lib/dota/version.rb
|
153
|
+
- spec/dota/api/cosmetic/rarity_spec.rb
|
152
154
|
- spec/dota/api/hero_spec.rb
|
153
155
|
- spec/dota/api/item_spec.rb
|
154
156
|
- spec/dota/api/league_spec.rb
|
@@ -159,6 +161,7 @@ files:
|
|
159
161
|
- spec/fixtures/vcr_cassettes/GetLeagueListing.yml
|
160
162
|
- spec/fixtures/vcr_cassettes/GetMatchDetails.yml
|
161
163
|
- spec/fixtures/vcr_cassettes/GetMatchHistory.yml
|
164
|
+
- spec/fixtures/vcr_cassettes/GetRarities.yml
|
162
165
|
- spec/spec_helper.rb
|
163
166
|
- spec/support/vcr.rb
|
164
167
|
homepage: http://github.com/vinnicc/dota
|
@@ -186,6 +189,7 @@ signing_key:
|
|
186
189
|
specification_version: 4
|
187
190
|
summary: Ruby client for the Dota 2 WebAPI
|
188
191
|
test_files:
|
192
|
+
- spec/dota/api/cosmetic/rarity_spec.rb
|
189
193
|
- spec/dota/api/hero_spec.rb
|
190
194
|
- spec/dota/api/item_spec.rb
|
191
195
|
- spec/dota/api/league_spec.rb
|
@@ -196,5 +200,6 @@ test_files:
|
|
196
200
|
- spec/fixtures/vcr_cassettes/GetLeagueListing.yml
|
197
201
|
- spec/fixtures/vcr_cassettes/GetMatchDetails.yml
|
198
202
|
- spec/fixtures/vcr_cassettes/GetMatchHistory.yml
|
203
|
+
- spec/fixtures/vcr_cassettes/GetRarities.yml
|
199
204
|
- spec/spec_helper.rb
|
200
205
|
- spec/support/vcr.rb
|