dota 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/Guardfile +1 -1
- data/README.md +12 -11
- data/dota.gemspec +1 -2
- data/lib/dota/api/client.rb +8 -0
- data/lib/dota/api/hero.rb +4 -0
- data/lib/dota/api/item.rb +249 -239
- data/lib/dota/api/match.rb +58 -20
- data/lib/dota/version.rb +1 -1
- data/spec/dota/api/hero_spec.rb +10 -4
- data/spec/dota/api/item_spec.rb +7 -1
- data/spec/dota/api/match_spec.rb +32 -24
- data/spec/dota_spec.rb +14 -4
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11288c0fc061bc33de74cf9379a13804e8bcd107
|
4
|
+
data.tar.gz: 8b5d300d111c113ad9dfd47b81049a09255fcca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e922c63323700c2ee13150a6c15f3b180fab00ea3be03b180b251537a3816771c6b5f618b28dcb4d1cc88f998bddf6692af70973e38b0cc4dae64e32dd19a6
|
7
|
+
data.tar.gz: 986209bba2d1454a4ab413d19727f0e8c02da98996e72a344920ad8de8de84705dbdf34655ddf9edbaaff2efa063327b3d14e0b231f4356cab31187cb7bdba00
|
data/.travis.yml
ADDED
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Dota
|
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
|
-
|
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.
|
4
4
|
|
5
|
-
This gem is in alpha, keep that in mind when upgrading.
|
5
|
+
This gem is in alpha, keep that in mind when upgrading.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -64,6 +64,10 @@ item.image_url # => "http://cdn.dota2.com/apps/dota2/images/items/heart_lg.png"
|
|
64
64
|
```ruby
|
65
65
|
match.id # => 789645621
|
66
66
|
match.league_id # => 600
|
67
|
+
match.type # => "Tournament"
|
68
|
+
match.type_id # => 2
|
69
|
+
match.mode # => "Captain's Mode"
|
70
|
+
match.mode_id # => 2
|
67
71
|
match.drafts # => [Dota::API::Match::Draft, ...]
|
68
72
|
match.players # => [Dota::API::Match::Player, ...]
|
69
73
|
match.sequence # => 709365483
|
@@ -76,8 +80,6 @@ match.negative_votes # => 13291
|
|
76
80
|
match.season # => nil
|
77
81
|
match.human_players # => 10
|
78
82
|
match.cluster # => 111
|
79
|
-
match.mode # => 2
|
80
|
-
match.lobby # => 2
|
81
83
|
match.radiant_tower_status # => 2039
|
82
84
|
match.dire_tower_status # => 1974
|
83
85
|
match.radiant_barracks_status # => 63
|
@@ -110,9 +112,9 @@ player.hero_healing # => 526
|
|
110
112
|
#### Dota::API::Match::Draft
|
111
113
|
|
112
114
|
```ruby
|
113
|
-
|
114
|
-
|
115
|
-
|
115
|
+
draft.hero # => Dota::API::Hero
|
116
|
+
draft.order # => 1
|
117
|
+
draft.pick? # => true
|
116
118
|
```
|
117
119
|
|
118
120
|
#### Dota::API::League
|
@@ -128,15 +130,14 @@ league.url # => "http://www.dota2.com/international/overview/"
|
|
128
130
|
|
129
131
|
- Validations and error classes
|
130
132
|
- More configuration options
|
131
|
-
- Move API documentation to https://readthedocs.org/ or somewhere else
|
133
|
+
- Move API documentation to [readthedocs.org](https://readthedocs.org/) or somewhere else
|
132
134
|
- Implement all Dota 2 WebAPI methods
|
133
135
|
- Better search filters
|
134
136
|
- Computed attributes such as win rates, hero usage, etc.
|
135
|
-
- ???
|
136
137
|
|
137
138
|
## Contributing
|
138
139
|
|
139
|
-
1. [Fork
|
140
|
+
1. [Fork it!](https://github.com/vinnicc/dota/fork)
|
140
141
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
141
142
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
142
143
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/dota.gemspec
CHANGED
@@ -21,8 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "faraday", "~> 0.9.0"
|
22
22
|
spec.add_dependency "faraday_middleware", "~> 0.9.1"
|
23
23
|
|
24
|
-
spec.add_development_dependency "
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rake"
|
26
25
|
spec.add_development_dependency "rspec"
|
27
26
|
spec.add_development_dependency "guard-rspec"
|
28
27
|
spec.add_development_dependency "pry"
|
data/lib/dota/api/client.rb
CHANGED
@@ -16,10 +16,18 @@ module Dota
|
|
16
16
|
Hero.new(id)
|
17
17
|
end
|
18
18
|
|
19
|
+
def heroes
|
20
|
+
Hero.all
|
21
|
+
end
|
22
|
+
|
19
23
|
def item(id)
|
20
24
|
Item.new(id)
|
21
25
|
end
|
22
26
|
|
27
|
+
def items
|
28
|
+
Item.all
|
29
|
+
end
|
30
|
+
|
23
31
|
def match(id)
|
24
32
|
response = do_request("GetMatchDetails", match_id: id)["result"]
|
25
33
|
Match.new(response) if response
|
data/lib/dota/api/hero.rb
CHANGED
data/lib/dota/api/item.rb
CHANGED
@@ -2,255 +2,265 @@ module Dota
|
|
2
2
|
module API
|
3
3
|
class Item
|
4
4
|
MAPPING = {
|
5
|
-
0 => "empty",
|
6
|
-
1 => "blink",
|
7
|
-
2 => "blades_of_attack",
|
8
|
-
3 => "broadsword",
|
9
|
-
4 => "chainmail",
|
10
|
-
5 => "claymore",
|
11
|
-
6 => "helm_of_iron_will",
|
12
|
-
7 => "javelin",
|
13
|
-
8 => "mithril_hammer",
|
14
|
-
9 => "platemail",
|
15
|
-
10 => "quarterstaff",
|
16
|
-
11 => "quelling_blade",
|
17
|
-
12 => "ring_of_protection",
|
18
|
-
13 => "gauntlets",
|
19
|
-
14 => "slippers",
|
20
|
-
15 => "mantle",
|
21
|
-
16 => "branches",
|
22
|
-
17 => "belt_of_strength",
|
23
|
-
18 => "boots_of_elves",
|
24
|
-
19 => "robe",
|
25
|
-
20 => "circlet",
|
26
|
-
21 => "ogre_axe",
|
27
|
-
22 => "blade_of_alacrity",
|
28
|
-
23 => "staff_of_wizardry",
|
29
|
-
24 => "ultimate_orb",
|
30
|
-
25 => "gloves",
|
31
|
-
26 => "lifesteal",
|
32
|
-
27 => "ring_of_regen",
|
33
|
-
28 => "sobi_mask",
|
34
|
-
29 => "boots",
|
35
|
-
30 => "gem",
|
36
|
-
31 => "cloak",
|
37
|
-
32 => "talisman_of_evasion",
|
38
|
-
33 => "cheese",
|
39
|
-
34 => "magic_stick",
|
40
|
-
35 => "recipe_magic_wand",
|
41
|
-
36 => "magic_wand",
|
42
|
-
37 => "ghost",
|
43
|
-
38 => "clarity",
|
44
|
-
39 => "flask",
|
45
|
-
40 => "dust",
|
46
|
-
41 => "bottle",
|
47
|
-
42 => "ward_observer",
|
48
|
-
43 => "ward_sentry",
|
49
|
-
44 => "tango",
|
50
|
-
45 => "courier",
|
51
|
-
46 => "tpscroll",
|
52
|
-
47 => "recipe_travel_boots",
|
53
|
-
48 => "travel_boots",
|
54
|
-
49 => "recipe_phase_boots",
|
55
|
-
50 => "phase_boots",
|
56
|
-
51 => "demon_edge",
|
57
|
-
52 => "eagle",
|
58
|
-
53 => "reaver",
|
59
|
-
54 => "relic",
|
60
|
-
55 => "hyperstone",
|
61
|
-
56 => "ring_of_health",
|
62
|
-
57 => "void_stone",
|
63
|
-
58 => "mystic_staff",
|
64
|
-
59 => "energy_booster",
|
65
|
-
60 => "point_booster",
|
66
|
-
61 => "vitality_booster",
|
67
|
-
62 => "recipe_power_treads",
|
68
|
-
63 => "power_treads",
|
69
|
-
64 => "recipe_hand_of_midas",
|
70
|
-
65 => "hand_of_midas",
|
71
|
-
66 => "recipe_oblivion_staff",
|
72
|
-
67 => "oblivion_staff",
|
73
|
-
68 => "recipe_pers",
|
74
|
-
69 => "pers",
|
75
|
-
70 => "recipe_poor_mans_shield",
|
76
|
-
71 => "poor_mans_shield",
|
77
|
-
72 => "recipe_bracer",
|
78
|
-
73 => "bracer",
|
79
|
-
74 => "recipe_wraith_band",
|
80
|
-
75 => "wraith_band",
|
81
|
-
76 => "recipe_null_talisman",
|
82
|
-
77 => "null_talisman",
|
83
|
-
78 => "recipe_mekansm",
|
84
|
-
79 => "mekansm",
|
85
|
-
80 => "recipe_vladmir",
|
86
|
-
81 => "vladmir",
|
87
|
-
84 => "flying_courier",
|
88
|
-
85 => "recipe_buckler",
|
89
|
-
86 => "buckler",
|
90
|
-
87 => "recipe_ring_of_basilius",
|
91
|
-
88 => "ring_of_basilius",
|
92
|
-
89 => "recipe_pipe",
|
93
|
-
90 => "pipe",
|
94
|
-
91 => "recipe_urn_of_shadows",
|
95
|
-
92 => "urn_of_shadows",
|
96
|
-
93 => "recipe_headdress",
|
97
|
-
94 => "headdress",
|
98
|
-
95 => "recipe_sheepstick",
|
99
|
-
96 => "sheepstick",
|
100
|
-
97 => "recipe_orchid",
|
101
|
-
98 => "orchid",
|
102
|
-
99 => "recipe_cyclone",
|
103
|
-
100 => "cyclone",
|
104
|
-
101 => "recipe_force_staff",
|
105
|
-
102 => "force_staff",
|
106
|
-
103 => "recipe_dagon",
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
205 => "recipe_rod_of_atos",
|
209
|
-
206 => "rod_of_atos",
|
210
|
-
207 => "recipe_abyssal_blade",
|
211
|
-
208 => "abyssal_blade",
|
212
|
-
209 => "recipe_heavens_halberd",
|
213
|
-
210 => "heavens_halberd",
|
214
|
-
211 => "recipe_ring_of_aquila",
|
215
|
-
212 => "ring_of_aquila",
|
216
|
-
213 => "recipe_tranquil_boots",
|
217
|
-
214 => "tranquil_boots",
|
218
|
-
215 => "shadow_amulet",
|
219
|
-
216 => "halloween_candy_corn",
|
220
|
-
217 => "mystery_hook",
|
221
|
-
218 => "mystery_arrow",
|
222
|
-
219 => "mystery_missile",
|
223
|
-
220 => "mystery_toss",
|
224
|
-
221 => "mystery_vacuum",
|
225
|
-
226 => "halloween_rapier",
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
236 => "winter_kringle",
|
236
|
-
237 => "winter_mushroom",
|
237
|
-
238 => "winter_greevil_treat",
|
238
|
-
239 => "winter_greevil_garbage",
|
239
|
-
240 => "winter_greevil_chewy",
|
240
|
-
241 => "tango_single",
|
241
|
-
242 => "crimson_guard"
|
5
|
+
0 => ["empty", "Empty"],
|
6
|
+
1 => ["blink", "Blink Dagger"],
|
7
|
+
2 => ["blades_of_attack", "Blades of Attack"],
|
8
|
+
3 => ["broadsword", "Broadsword"],
|
9
|
+
4 => ["chainmail", "Chainmail"],
|
10
|
+
5 => ["claymore", "Claymore"],
|
11
|
+
6 => ["helm_of_iron_will", "Helm of Iron Will"],
|
12
|
+
7 => ["javelin", "Javelin"],
|
13
|
+
8 => ["mithril_hammer", "Mithril Hammer"],
|
14
|
+
9 => ["platemail", "Platemail"],
|
15
|
+
10 => ["quarterstaff", "Quarterstaff"],
|
16
|
+
11 => ["quelling_blade", "Quelling Blade"],
|
17
|
+
12 => ["ring_of_protection", "Ring of Protection"],
|
18
|
+
13 => ["gauntlets", "Gauntlets of Strength"],
|
19
|
+
14 => ["slippers", "Slippers of Agility"],
|
20
|
+
15 => ["mantle", "Mantle of Intelligence"],
|
21
|
+
16 => ["branches", "Iron Branch"],
|
22
|
+
17 => ["belt_of_strength", "Belt of Strength"],
|
23
|
+
18 => ["boots_of_elves", "Band of Elvenskin"],
|
24
|
+
19 => ["robe", "Robe of the Magi"],
|
25
|
+
20 => ["circlet", "Circlet"],
|
26
|
+
21 => ["ogre_axe", "Ogre Club"],
|
27
|
+
22 => ["blade_of_alacrity", "Blade of Alacrity"],
|
28
|
+
23 => ["staff_of_wizardry", "Staff of Wizardry"],
|
29
|
+
24 => ["ultimate_orb", "Ultimate Orb"],
|
30
|
+
25 => ["gloves", "Gloves of Haste"],
|
31
|
+
26 => ["lifesteal", "Morbid Mask"],
|
32
|
+
27 => ["ring_of_regen", "Ring of Regen"],
|
33
|
+
28 => ["sobi_mask", "Sage's Mask"],
|
34
|
+
29 => ["boots", "Boots of Speed"],
|
35
|
+
30 => ["gem", "Gem of True Sight"],
|
36
|
+
31 => ["cloak", "Cloak"],
|
37
|
+
32 => ["talisman_of_evasion", "Talisman of Evasion"],
|
38
|
+
33 => ["cheese", "Cheese"],
|
39
|
+
34 => ["magic_stick", "Magic Stick"],
|
40
|
+
35 => ["recipe_magic_wand", "Recipe: Magic Wand"],
|
41
|
+
36 => ["magic_wand", "Magic Wand"],
|
42
|
+
37 => ["ghost", "Ghost Scepter"],
|
43
|
+
38 => ["clarity", "Clarity"],
|
44
|
+
39 => ["flask", "Healing Salve"],
|
45
|
+
40 => ["dust", "Dust of Appearance"],
|
46
|
+
41 => ["bottle", "Bottle"],
|
47
|
+
42 => ["ward_observer", "Observer Ward"],
|
48
|
+
43 => ["ward_sentry", "Sentry Ward"],
|
49
|
+
44 => ["tango", "Tango"],
|
50
|
+
45 => ["courier", "Animal Courier"],
|
51
|
+
46 => ["tpscroll", "Town Portal Scroll"],
|
52
|
+
47 => ["recipe_travel_boots", "Recipe: Boots of Travel"],
|
53
|
+
48 => ["travel_boots", "Boots of Travel"],
|
54
|
+
49 => ["recipe_phase_boots", "Recipe: Phase Boots"],
|
55
|
+
50 => ["phase_boots", "Phase Boots"],
|
56
|
+
51 => ["demon_edge", "Demon Edge"],
|
57
|
+
52 => ["eagle", "Eaglesong"],
|
58
|
+
53 => ["reaver", "Reaver"],
|
59
|
+
54 => ["relic", "Sacred Relic"],
|
60
|
+
55 => ["hyperstone", "Hyperstone"],
|
61
|
+
56 => ["ring_of_health", "Ring of Health"],
|
62
|
+
57 => ["void_stone", "Void Stone"],
|
63
|
+
58 => ["mystic_staff", "Mystic Staff"],
|
64
|
+
59 => ["energy_booster", "Energy Booster"],
|
65
|
+
60 => ["point_booster", "Point Booster"],
|
66
|
+
61 => ["vitality_booster", "Vitality Booster"],
|
67
|
+
62 => ["recipe_power_treads", "Recipe: Power Treads"],
|
68
|
+
63 => ["power_treads", "Power Treads"],
|
69
|
+
64 => ["recipe_hand_of_midas", "Recipe: Hand of Midas"],
|
70
|
+
65 => ["hand_of_midas", "Hand of Midas"],
|
71
|
+
66 => ["recipe_oblivion_staff", "Recipe: Oblivion Staff"],
|
72
|
+
67 => ["oblivion_staff", "Oblivion Staff"],
|
73
|
+
68 => ["recipe_pers", "Recipe: Perseverance"],
|
74
|
+
69 => ["pers", "Perseverance"],
|
75
|
+
70 => ["recipe_poor_mans_shield", "Recipe: Poor Man's Shield"],
|
76
|
+
71 => ["poor_mans_shield", "Poor Man's Shield"],
|
77
|
+
72 => ["recipe_bracer", "Recipe: Bracer"],
|
78
|
+
73 => ["bracer", "Bracer"],
|
79
|
+
74 => ["recipe_wraith_band", "Recipe: Wraith Band"],
|
80
|
+
75 => ["wraith_band", "Wraith Band"],
|
81
|
+
76 => ["recipe_null_talisman", "Recipe: Null Talisman"],
|
82
|
+
77 => ["null_talisman", "Null Talisman"],
|
83
|
+
78 => ["recipe_mekansm", "Recipe: Mekansm"],
|
84
|
+
79 => ["mekansm", "Mekansm"],
|
85
|
+
80 => ["recipe_vladmir", "Recipe: Vladmir's Offering"],
|
86
|
+
81 => ["vladmir", "Vladmir's Offering"],
|
87
|
+
84 => ["flying_courier", "Flying Courier"],
|
88
|
+
85 => ["recipe_buckler", "Recipe: Buckler"],
|
89
|
+
86 => ["buckler", "Buckler"],
|
90
|
+
87 => ["recipe_ring_of_basilius", "Recipe: Ring of Basilius"],
|
91
|
+
88 => ["ring_of_basilius", "Ring of Basilius"],
|
92
|
+
89 => ["recipe_pipe", "Recipe: Pipe of Insight"],
|
93
|
+
90 => ["pipe", "Pipe of Insight"],
|
94
|
+
91 => ["recipe_urn_of_shadows", "Recipe: Urn of Shadows"],
|
95
|
+
92 => ["urn_of_shadows", "Urn of Shadows"],
|
96
|
+
93 => ["recipe_headdress", "Recipe: Headdress"],
|
97
|
+
94 => ["headdress", "Headdress"],
|
98
|
+
95 => ["recipe_sheepstick", "Recipe: Scythe of Vyse"],
|
99
|
+
96 => ["sheepstick", "Scythe of Vyse"],
|
100
|
+
97 => ["recipe_orchid", "Recipe: Orchid Malevolence"],
|
101
|
+
98 => ["orchid", "Orchid Malevolence"],
|
102
|
+
99 => ["recipe_cyclone", "Recipe: Eul's Scepter of Divinity"],
|
103
|
+
100 => ["cyclone", "Eul's Scepter of Divinity"],
|
104
|
+
101 => ["recipe_force_staff", "Recipe: Force Staff"],
|
105
|
+
102 => ["force_staff", "Force Staff"],
|
106
|
+
103 => ["recipe_dagon", "Recipe: Dagon"],
|
107
|
+
104 => ["dagon", "Dagon"],
|
108
|
+
105 => ["recipe_necronomicon", "Recipe: Necronomicon"],
|
109
|
+
106 => ["necronomicon", "Necronomicon"],
|
110
|
+
107 => ["recipe_ultimate_scepter", "Recipe: Aghanim's Scepter"],
|
111
|
+
108 => ["ultimate_scepter", "Aghanim's Scepter"],
|
112
|
+
109 => ["recipe_refresher", "Recipe: Refresher Orb"],
|
113
|
+
110 => ["refresher", "Refresher Orb"],
|
114
|
+
111 => ["recipe_assault", "Recipe: Assault Cuirass"],
|
115
|
+
112 => ["assault", "Assault Cuirass"],
|
116
|
+
113 => ["recipe_heart", "Recipe: Heart of Tarrasque"],
|
117
|
+
114 => ["heart", "Heart of Tarrasque"],
|
118
|
+
115 => ["recipe_black_king_bar", "Recipe: Black King Bar"],
|
119
|
+
116 => ["black_king_bar", "Black King Bar"],
|
120
|
+
117 => ["aegis", "Aegis of the Immortal"],
|
121
|
+
118 => ["recipe_shivas_guard", "Recipe: Shiva's Guard"],
|
122
|
+
119 => ["shivas_guard", "Shiva's Guard"],
|
123
|
+
120 => ["recipe_bloodstone", "Recipe: Bloodstone"],
|
124
|
+
121 => ["bloodstone", "Bloodstone"],
|
125
|
+
122 => ["recipe_sphere", "Recipe: Linken's Sphere"],
|
126
|
+
123 => ["sphere", "Linken's Sphere"],
|
127
|
+
124 => ["recipe_vanguard", "Recipe: Vanguard"],
|
128
|
+
125 => ["vanguard", "Vanguard"],
|
129
|
+
126 => ["recipe_blade_mail", "Recipe: Blade Mail"],
|
130
|
+
127 => ["blade_mail", "Blade Mail"],
|
131
|
+
128 => ["recipe_soul_booster", "Recipe: Soul Booster"],
|
132
|
+
129 => ["soul_booster", "Soul Booster"],
|
133
|
+
130 => ["recipe_hood_of_defiance", "Recipe: Hood of Defiance"],
|
134
|
+
131 => ["hood_of_defiance", "Hood of Defiance"],
|
135
|
+
132 => ["recipe_rapier", "Recipe: Divine Rapier"],
|
136
|
+
133 => ["rapier", "Divine Rapier"],
|
137
|
+
134 => ["recipe_monkey_king_bar", "Recipe: Monkey King Bar"],
|
138
|
+
135 => ["monkey_king_bar", "Monkey King Bar"],
|
139
|
+
136 => ["recipe_radiance", "Recipe: Radiance"],
|
140
|
+
137 => ["radiance", "Radiance"],
|
141
|
+
138 => ["recipe_butterfly", "Recipe: Butterfly"],
|
142
|
+
139 => ["butterfly", "Butterfly"],
|
143
|
+
140 => ["recipe_greater_crit", "Recipe: Daedalus"],
|
144
|
+
141 => ["greater_crit", "Daedalus"],
|
145
|
+
142 => ["recipe_basher", "Recipe: Skull Basher"],
|
146
|
+
143 => ["basher", "Skull Basher"],
|
147
|
+
144 => ["recipe_bfury", "Recipe: Battle Fury"],
|
148
|
+
145 => ["bfury", "Battle Fury"],
|
149
|
+
146 => ["recipe_manta", "Recipe: Manta Style"],
|
150
|
+
147 => ["manta", "Manta Style"],
|
151
|
+
148 => ["recipe_lesser_crit", "Recipe: Crystalys"],
|
152
|
+
149 => ["lesser_crit", "Crystalys"],
|
153
|
+
150 => ["recipe_armlet", "Recipe: Armlet of Mordiggian"],
|
154
|
+
151 => ["armlet", "Armlet of Mordiggian"],
|
155
|
+
152 => ["invis_sword", "Shadow Blade"],
|
156
|
+
153 => ["recipe_sange_and_yasha", "Recipe: Sange and Yasha"],
|
157
|
+
154 => ["sange_and_yasha", "Sange and Yasha"],
|
158
|
+
155 => ["recipe_satanic", "Recipe: Satanic"],
|
159
|
+
156 => ["satanic", "Satanic"],
|
160
|
+
157 => ["recipe_mjollnir", "Recipe: Mjollnir"],
|
161
|
+
158 => ["mjollnir", "Mjollnir"],
|
162
|
+
159 => ["recipe_skadi", "Recipe: Eye of Skadi"],
|
163
|
+
160 => ["skadi", "Eye of Skadi"],
|
164
|
+
161 => ["recipe_sange", "Recipe: Sange"],
|
165
|
+
162 => ["sange", "Sange"],
|
166
|
+
163 => ["recipe_helm_of_the_dominator", "Recipe: Helm of the Dominator"],
|
167
|
+
164 => ["helm_of_the_dominator", "Helm of the Dominator"],
|
168
|
+
165 => ["recipe_maelstrom", "Recipe: Maelstrom"],
|
169
|
+
166 => ["maelstrom", "Maelstrom"],
|
170
|
+
167 => ["recipe_desolator", "Recipe: Desolator"],
|
171
|
+
168 => ["desolator", "Desolator"],
|
172
|
+
169 => ["recipe_yasha", "Recipe: Yasha"],
|
173
|
+
170 => ["yasha", "Yasha"],
|
174
|
+
171 => ["recipe_mask_of_madness", "Recipe: Mask of Madness"],
|
175
|
+
172 => ["mask_of_madness", "Mask of Madness"],
|
176
|
+
173 => ["recipe_diffusal_blade", "Recipe: Diffusal Blade"],
|
177
|
+
174 => ["diffusal_blade", "Diffusal Blade"],
|
178
|
+
175 => ["recipe_ethereal_blade", "Recipe: Ethereal Blade"],
|
179
|
+
176 => ["ethereal_blade", "Ethereal Blade"],
|
180
|
+
177 => ["recipe_soul_ring", "Recipe: Soul Ring"],
|
181
|
+
178 => ["soul_ring", "Soul Ring"],
|
182
|
+
179 => ["recipe_arcane_boots", "Recipe: Arcane Boots"],
|
183
|
+
180 => ["arcane_boots", "Arcane Boots"],
|
184
|
+
181 => ["orb_of_venom", "Orb of Venom"],
|
185
|
+
182 => ["stout_shield", "Stout Shield"],
|
186
|
+
183 => ["recipe_invis_sword", "Recipe: Shadow Blade"],
|
187
|
+
184 => ["recipe_ancient_janggo", "Recipe: Drum of Endurance"],
|
188
|
+
185 => ["ancient_janggo", "Drum of Endurance"],
|
189
|
+
186 => ["recipe_medallion_of_courage", "Recipe: Medallion of Courage"],
|
190
|
+
187 => ["medallion_of_courage", "Medallion of Courage"],
|
191
|
+
188 => ["smoke_of_deceit", "Smoke of Deceit"],
|
192
|
+
189 => ["recipe_veil_of_discord", "Recipe: Veil of Discord"],
|
193
|
+
190 => ["veil_of_discord", "Veil of Discord"],
|
194
|
+
191 => ["recipe_necronomicon_2", "Recipe: Necronomicon"],
|
195
|
+
192 => ["recipe_necronomicon_3", "Recipe: Necronomicon"],
|
196
|
+
193 => ["necronomicon_2", "Necronomicon"],
|
197
|
+
194 => ["necronomicon_3", "Necronomicon"],
|
198
|
+
195 => ["recipe_diffusal_blade_2", "Recipe: Diffusal Blade"],
|
199
|
+
196 => ["diffusal_blade_2", "Diffusal Blade"],
|
200
|
+
197 => ["recipe_dagon_2", "Recipe: Dagon"],
|
201
|
+
198 => ["recipe_dagon_3", "Recipe: Dagon"],
|
202
|
+
199 => ["recipe_dagon_4", "Recipe: Dagon"],
|
203
|
+
200 => ["recipe_dagon_5", "Recipe: Dagon"],
|
204
|
+
201 => ["dagon_2", "Dagon"],
|
205
|
+
202 => ["dagon_3", "Dagon"],
|
206
|
+
203 => ["dagon_4", "Dagon"],
|
207
|
+
204 => ["dagon_5", "Dagon"],
|
208
|
+
205 => ["recipe_rod_of_atos", "Recipe: Rod of Atos"],
|
209
|
+
206 => ["rod_of_atos", "Rod of Atos"],
|
210
|
+
207 => ["recipe_abyssal_blade", "Recipe: Abyssal Blade"],
|
211
|
+
208 => ["abyssal_blade", "Abyssal Blade"],
|
212
|
+
209 => ["recipe_heavens_halberd", "Recipe: Heaven's Halberd"],
|
213
|
+
210 => ["heavens_halberd", "Heaven's Halberd"],
|
214
|
+
211 => ["recipe_ring_of_aquila", "Recipe: Ring of Aquila"],
|
215
|
+
212 => ["ring_of_aquila", "Ring of Aquila"],
|
216
|
+
213 => ["recipe_tranquil_boots", "Recipe: Tranquil Boots"],
|
217
|
+
214 => ["tranquil_boots", "Tranquil Boots"],
|
218
|
+
215 => ["shadow_amulet", "Shadow Amulet"],
|
219
|
+
216 => ["halloween_candy_corn", "Greevil Taffy"],
|
220
|
+
217 => ["mystery_hook", "DOTA_Tooltip_Ability_item_mystery_hook"],
|
221
|
+
218 => ["mystery_arrow", "DOTA_Tooltip_Ability_item_mystery_arrow"],
|
222
|
+
219 => ["mystery_missile", "DOTA_Tooltip_Ability_item_mystery_missile"],
|
223
|
+
220 => ["mystery_toss", "DOTA_Tooltip_Ability_item_mystery_toss"],
|
224
|
+
221 => ["mystery_vacuum", "DOTA_Tooltip_Ability_item_mystery_vacuum"],
|
225
|
+
226 => ["halloween_rapier", "DOTA_Tooltip_Ability_item_halloween_rapier"],
|
226
|
+
227 => ["present", "A Gift!"],
|
227
|
+
228 => ["greevil_whistle", "Greevil Whistle"],
|
228
|
+
229 => ["winter_stocking", "Xmas Stocking"],
|
229
|
+
230 => ["winter_skates", "Speed Skates"],
|
230
|
+
231 => ["winter_cake", "Fruit-bit Cake"],
|
231
|
+
232 => ["winter_cookie", "Wizard Cookie"],
|
232
|
+
233 => ["winter_coco", "Cocoa with Marshmallows"],
|
233
|
+
234 => ["winter_ham", "Clove Studded Ham"],
|
234
|
+
235 => ["greevil_whistle_toggle", "Greevil Whistle"],
|
235
|
+
236 => ["winter_kringle", "Kringle"],
|
236
|
+
237 => ["winter_mushroom", "Snow Mushroom"],
|
237
|
+
238 => ["winter_greevil_treat", "Greevil Treat"],
|
238
|
+
239 => ["winter_greevil_garbage", "Greevil Chow"],
|
239
|
+
240 => ["winter_greevil_chewy", "Greevil Blink Bone"],
|
240
|
+
241 => ["tango_single", "Tango (Shared)"],
|
241
|
+
242 => ["crimson_guard", "Crimson Guard"],
|
242
|
+
243 => ["recipe_crimson_guard", "Recipe: Crimson Guard"],
|
242
243
|
}.freeze
|
243
244
|
|
244
245
|
attr_reader :id, :name
|
245
246
|
|
247
|
+
def self.all
|
248
|
+
MAPPING.keys.map { |id| new(id) }
|
249
|
+
end
|
250
|
+
|
246
251
|
def initialize(id)
|
247
252
|
@id = id
|
248
|
-
@
|
253
|
+
@internal_name = MAPPING[id][0]
|
254
|
+
@name = MAPPING[id][1]
|
249
255
|
end
|
250
256
|
|
251
257
|
def image_url(type = :lg)
|
252
|
-
"http://cdn.dota2.com/apps/dota2/images/items/#{
|
258
|
+
"http://cdn.dota2.com/apps/dota2/images/items/#{internal_name}_#{type}.png"
|
253
259
|
end
|
260
|
+
|
261
|
+
private
|
262
|
+
|
263
|
+
attr_reader :internal_name
|
254
264
|
end
|
255
265
|
end
|
256
266
|
end
|
data/lib/dota/api/match.rb
CHANGED
@@ -3,6 +3,36 @@ module Dota
|
|
3
3
|
class Match
|
4
4
|
include Utilities::Inspectable
|
5
5
|
|
6
|
+
TYPES = {
|
7
|
+
-1 => "Invalid",
|
8
|
+
0 => "Public Matchmaking",
|
9
|
+
1 => "Practice",
|
10
|
+
2 => "Tournament",
|
11
|
+
3 => "Tutorial",
|
12
|
+
4 => "Co-op with Bots",
|
13
|
+
5 => "Team Match",
|
14
|
+
6 => "Solo Queue"
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
MODES = {
|
18
|
+
0 => "None",
|
19
|
+
1 => "All Pick",
|
20
|
+
2 => "Captain's Mode",
|
21
|
+
3 => "Random Draft",
|
22
|
+
4 => "Single Draft",
|
23
|
+
5 => "All Random",
|
24
|
+
6 => "Intro",
|
25
|
+
7 => "Diretide",
|
26
|
+
8 => "Reverse Captain's Mode",
|
27
|
+
9 => "The Greeviling",
|
28
|
+
10 => "Tutorial",
|
29
|
+
11 => "Mid Only",
|
30
|
+
12 => "Least Played",
|
31
|
+
13 => "New Player Pool",
|
32
|
+
14 => "Compendium Matchmaking",
|
33
|
+
16 => "Captain's Draft"
|
34
|
+
}.freeze
|
35
|
+
|
6
36
|
def initialize(raw)
|
7
37
|
@raw = raw
|
8
38
|
end
|
@@ -11,6 +41,34 @@ module Dota
|
|
11
41
|
raw["match_id"]
|
12
42
|
end
|
13
43
|
|
44
|
+
def mode
|
45
|
+
MODES[raw["game_mode"]]
|
46
|
+
end
|
47
|
+
|
48
|
+
def mode_id
|
49
|
+
raw["game_mode"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def type
|
53
|
+
TYPES[raw["lobby_type"]]
|
54
|
+
end
|
55
|
+
|
56
|
+
def type_id
|
57
|
+
raw["lobby_type"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def drafts
|
61
|
+
raw["picks_bans"].map do |raw_draft|
|
62
|
+
Draft.new(raw_draft)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def players
|
67
|
+
raw["players"].map do |raw_player|
|
68
|
+
Player.new(raw_player)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
14
72
|
def sequence
|
15
73
|
raw["match_seq_num"]
|
16
74
|
end
|
@@ -55,14 +113,6 @@ module Dota
|
|
55
113
|
raw["cluster"]
|
56
114
|
end
|
57
115
|
|
58
|
-
def mode
|
59
|
-
raw["game_mode"]
|
60
|
-
end
|
61
|
-
|
62
|
-
def lobby
|
63
|
-
raw["lobby_type"]
|
64
|
-
end
|
65
|
-
|
66
116
|
def radiant_tower_status
|
67
117
|
raw["tower_status_radiant"]
|
68
118
|
end
|
@@ -79,18 +129,6 @@ module Dota
|
|
79
129
|
raw["barracks_status_dire"]
|
80
130
|
end
|
81
131
|
|
82
|
-
def players
|
83
|
-
raw["players"].map do |raw_player|
|
84
|
-
Player.new(raw_player)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def drafts
|
89
|
-
raw["picks_bans"].map do |raw_draft|
|
90
|
-
Draft.new(raw_draft)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
132
|
private
|
95
133
|
|
96
134
|
attr_reader :raw
|
data/lib/dota/version.rb
CHANGED
data/spec/dota/api/hero_spec.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
describe Dota::API::Hero do
|
2
|
-
let(:
|
2
|
+
let(:hero) do
|
3
3
|
VCR.use_cassette("GetMatchDetails") do
|
4
4
|
test_client.match(sample_match_id).players.first.hero
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
+
specify ".all" do
|
9
|
+
heroes = described_class.all
|
10
|
+
expect(heroes.first).to be_a described_class
|
11
|
+
expect(heroes.count).to eq 108
|
12
|
+
end
|
13
|
+
|
8
14
|
specify "#id" do
|
9
|
-
expect(
|
15
|
+
expect(hero.id).to eq 69
|
10
16
|
end
|
11
17
|
|
12
18
|
specify "#name" do
|
13
|
-
expect(
|
19
|
+
expect(hero.name).to eq "Doom"
|
14
20
|
end
|
15
21
|
|
16
22
|
specify "#image_url" do
|
17
|
-
expect(
|
23
|
+
expect(hero.image_url).to eq "http://cdn.dota2.com/apps/dota2/images/heroes/doom_bringer_full.png"
|
18
24
|
end
|
19
25
|
end
|
data/spec/dota/api/item_spec.rb
CHANGED
@@ -5,12 +5,18 @@ describe Dota::API::Item do
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
+
specify ".all" do
|
9
|
+
items = described_class.all
|
10
|
+
expect(items.first).to be_a described_class
|
11
|
+
expect(items.count).to eq 238
|
12
|
+
end
|
13
|
+
|
8
14
|
specify "#id" do
|
9
15
|
expect(item.id).to eq 1
|
10
16
|
end
|
11
17
|
|
12
18
|
specify "#name" do
|
13
|
-
expect(item.name).to eq "
|
19
|
+
expect(item.name).to eq "Blink Dagger"
|
14
20
|
end
|
15
21
|
|
16
22
|
specify "#image_url" do
|
data/spec/dota/api/match_spec.rb
CHANGED
@@ -9,6 +9,38 @@ describe Dota::API::Match do
|
|
9
9
|
expect(match.id).to eq sample_match_id
|
10
10
|
end
|
11
11
|
|
12
|
+
specify "#league_id" do
|
13
|
+
expect(match.league_id).to eq 600
|
14
|
+
end
|
15
|
+
|
16
|
+
specify "#type" do
|
17
|
+
expect(match.type).to eq "Tournament"
|
18
|
+
end
|
19
|
+
|
20
|
+
specify "#type_id" do
|
21
|
+
expect(match.type_id).to eq 2
|
22
|
+
end
|
23
|
+
|
24
|
+
specify "#mode" do
|
25
|
+
expect(match.mode).to eq "Captain's Mode"
|
26
|
+
end
|
27
|
+
|
28
|
+
specify "#mode_id" do
|
29
|
+
expect(match.mode_id).to eq 2
|
30
|
+
end
|
31
|
+
|
32
|
+
specify "#players" do
|
33
|
+
players = match.players
|
34
|
+
expect(players.count).to eq 10
|
35
|
+
expect(players.first).to be_a Dota::API::Match::Player
|
36
|
+
end
|
37
|
+
|
38
|
+
specify "#drafts" do
|
39
|
+
drafts = match.drafts
|
40
|
+
expect(drafts.count).to eq 20
|
41
|
+
expect(drafts.first).to be_a Dota::API::Match::Draft
|
42
|
+
end
|
43
|
+
|
12
44
|
specify "#sequence" do
|
13
45
|
expect(match.sequence).to eq 709365483
|
14
46
|
end
|
@@ -49,18 +81,6 @@ describe Dota::API::Match do
|
|
49
81
|
expect(match.cluster).to eq 111
|
50
82
|
end
|
51
83
|
|
52
|
-
specify "#mode" do
|
53
|
-
expect(match.mode).to eq 2
|
54
|
-
end
|
55
|
-
|
56
|
-
specify "#lobby" do
|
57
|
-
expect(match.lobby).to eq 2
|
58
|
-
end
|
59
|
-
|
60
|
-
specify "#league_id" do
|
61
|
-
expect(match.league_id).to eq 600
|
62
|
-
end
|
63
|
-
|
64
84
|
specify "#radiant_tower_status" do
|
65
85
|
expect(match.radiant_tower_status).to eq 2039
|
66
86
|
end
|
@@ -76,16 +96,4 @@ describe Dota::API::Match do
|
|
76
96
|
specify "#dire_barracks_status" do
|
77
97
|
expect(match.dire_barracks_status).to eq 63
|
78
98
|
end
|
79
|
-
|
80
|
-
specify "#players" do
|
81
|
-
players = match.players
|
82
|
-
expect(players.count).to eq 10
|
83
|
-
expect(players.first).to be_a Dota::API::Match::Player
|
84
|
-
end
|
85
|
-
|
86
|
-
specify "#drafts" do
|
87
|
-
drafts = match.drafts
|
88
|
-
expect(drafts.count).to eq 20
|
89
|
-
expect(drafts.first).to be_a Dota::API::Match::Draft
|
90
|
-
end
|
91
99
|
end
|
data/spec/dota_spec.rb
CHANGED
@@ -18,13 +18,23 @@ describe Dota do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
specify "#hero" do
|
21
|
-
|
22
|
-
expect(
|
21
|
+
hero = api.hero(43)
|
22
|
+
expect(hero).to be_a Dota::API::Hero
|
23
|
+
end
|
24
|
+
|
25
|
+
specify "#heroes" do
|
26
|
+
hero = api.heroes.first
|
27
|
+
expect(hero).to be_a Dota::API::Hero
|
23
28
|
end
|
24
29
|
|
25
30
|
specify "#item" do
|
26
|
-
|
27
|
-
expect(
|
31
|
+
item = api.item(114)
|
32
|
+
expect(item).to be_a Dota::API::Item
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "#items" do
|
36
|
+
item = api.items.first
|
37
|
+
expect(item).to be_a Dota::API::Item
|
28
38
|
end
|
29
39
|
|
30
40
|
specify "#match" do
|
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.4
|
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: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,34 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.7'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.7'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +131,7 @@ extra_rdoc_files: []
|
|
145
131
|
files:
|
146
132
|
- ".gitignore"
|
147
133
|
- ".rspec"
|
134
|
+
- ".travis.yml"
|
148
135
|
- Gemfile
|
149
136
|
- Guardfile
|
150
137
|
- LICENSE.txt
|