dota 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad118a276cb0f8883e5072b9c41cc0a98767dc93
4
+ data.tar.gz: 5ccf4337d2d9c333d92fa58508e4f80dcdf7a9b2
5
+ SHA512:
6
+ metadata.gz: f63a7ae4e6cd23a9f6489a2e1d92ae312565ca05edce17465265c842a8747d0b6a06bced04929987077470371948e0acef9e24be947a39351c38f6fbbc2377b8
7
+ data.tar.gz: c3107344c0616c4c39f9abcac67fd86325411f4c79e684853149dc863e12ce3dd2afcf10a792f8572b41dfcdd641c7abee19431e91063d3c861a96ab71cbf535
@@ -0,0 +1,14 @@
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --order rand
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch("spec/spec_helper.rb") { "spec" }
5
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Vinni Carlo Caños
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.
@@ -0,0 +1,35 @@
1
+ # Dota
2
+
3
+ The Dota gem can be used integration with the Dota 2 WebAPI.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dota'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dota
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ Dota.configure do |config|
25
+ config.api_key = "STEAM_API_KEY"
26
+ end
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/[my-github-username]/dota/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dota/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dota"
8
+ spec.version = Dota::VERSION
9
+ spec.authors = ["Vinni Carlo Caños"]
10
+ spec.email = ["vinnicc@gmail.com"]
11
+ spec.summary = %q{Ruby client for the Dota 2 WebAPI}
12
+ spec.description = %q{Ruby client for the Dota 2 WebAPI}
13
+ spec.homepage = "http://github.com/vinnicc/dota"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "faraday", "~> 0.9.0"
22
+ spec.add_dependency "faraday_middleware", "~> 0.9.1"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "guard-rspec"
28
+ spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "vcr"
30
+ spec.add_development_dependency "webmock"
31
+ end
@@ -0,0 +1,27 @@
1
+ require 'dota/configuration'
2
+ require 'dota/version'
3
+
4
+ require 'dota/utils/inspect'
5
+
6
+ require 'dota/api/client'
7
+ require 'dota/api/item'
8
+ require 'dota/api/match'
9
+ require 'dota/api/match/player'
10
+
11
+ module Dota
12
+ class << self
13
+ attr_writer :configuration
14
+
15
+ def api
16
+ @client ||= API::Client.new
17
+ end
18
+
19
+ def configure(&block)
20
+ api.configure(&block)
21
+ end
22
+
23
+ def configuration
24
+ api.configuration
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Dota
5
+ module API
6
+ class Client
7
+ def match(id)
8
+ response = do_request("GetMatchDetails", match_id: id)["result"]
9
+ Match.new(response) if response
10
+ end
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield configuration
18
+ end
19
+
20
+ private
21
+
22
+ def do_request(method, options = {}, interface = "IDOTA2Match_570", method_version = "V001")
23
+ url = "https://api.steampowered.com/#{interface}/#{method}/#{method_version}/"
24
+
25
+ @faraday = Faraday.new(url) do |faraday|
26
+ faraday.response :json
27
+ faraday.adapter Faraday.default_adapter
28
+ end
29
+
30
+ response = @faraday.get do |request|
31
+ request.url(url, options.merge(key: configuration.api_key))
32
+ end
33
+ response.body
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,252 @@
1
+ module Dota
2
+ module API
3
+ class Item
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
+ 197 => "recipe_dagon_2",
108
+ 198 => "recipe_dagon_3",
109
+ 199 => "recipe_dagon_4",
110
+ 200 => "recipe_dagon_5",
111
+ 104 => "dagon",
112
+ 201 => "dagon_2",
113
+ 202 => "dagon_3",
114
+ 203 => "dagon_4",
115
+ 204 => "dagon_5",
116
+ 105 => "recipe_necronomicon",
117
+ 191 => "recipe_necronomicon_2",
118
+ 192 => "recipe_necronomicon_3",
119
+ 106 => "necronomicon",
120
+ 193 => "necronomicon_2",
121
+ 194 => "necronomicon_3",
122
+ 107 => "recipe_ultimate_scepter",
123
+ 108 => "ultimate_scepter",
124
+ 109 => "recipe_refresher",
125
+ 110 => "refresher",
126
+ 111 => "recipe_assault",
127
+ 112 => "assault",
128
+ 113 => "recipe_heart",
129
+ 114 => "heart",
130
+ 115 => "recipe_black_king_bar",
131
+ 116 => "black_king_bar",
132
+ 117 => "aegis",
133
+ 118 => "recipe_shivas_guard",
134
+ 119 => "shivas_guard",
135
+ 120 => "recipe_bloodstone",
136
+ 121 => "bloodstone",
137
+ 122 => "recipe_sphere",
138
+ 123 => "sphere",
139
+ 124 => "recipe_vanguard",
140
+ 125 => "vanguard",
141
+ 126 => "recipe_blade_mail",
142
+ 127 => "blade_mail",
143
+ 128 => "recipe_soul_booster",
144
+ 129 => "soul_booster",
145
+ 130 => "recipe_hood_of_defiance",
146
+ 131 => "hood_of_defiance",
147
+ 132 => "recipe_rapier",
148
+ 133 => "rapier",
149
+ 134 => "recipe_monkey_king_bar",
150
+ 135 => "monkey_king_bar",
151
+ 136 => "recipe_radiance",
152
+ 137 => "radiance",
153
+ 138 => "recipe_butterfly",
154
+ 139 => "butterfly",
155
+ 140 => "recipe_greater_crit",
156
+ 141 => "greater_crit",
157
+ 142 => "recipe_basher",
158
+ 143 => "basher",
159
+ 144 => "recipe_bfury",
160
+ 145 => "bfury",
161
+ 146 => "recipe_manta",
162
+ 147 => "manta",
163
+ 148 => "recipe_lesser_crit",
164
+ 149 => "lesser_crit",
165
+ 150 => "recipe_armlet",
166
+ 151 => "armlet",
167
+ 183 => "recipe_invis_sword",
168
+ 152 => "invis_sword",
169
+ 153 => "recipe_sange_and_yasha",
170
+ 154 => "sange_and_yasha",
171
+ 155 => "recipe_satanic",
172
+ 156 => "satanic",
173
+ 157 => "recipe_mjollnir",
174
+ 158 => "mjollnir",
175
+ 159 => "recipe_skadi",
176
+ 160 => "skadi",
177
+ 161 => "recipe_sange",
178
+ 162 => "sange",
179
+ 163 => "recipe_helm_of_the_dominator",
180
+ 164 => "helm_of_the_dominator",
181
+ 165 => "recipe_maelstrom",
182
+ 166 => "maelstrom",
183
+ 167 => "recipe_desolator",
184
+ 168 => "desolator",
185
+ 169 => "recipe_yasha",
186
+ 170 => "yasha",
187
+ 171 => "recipe_mask_of_madness",
188
+ 172 => "mask_of_madness",
189
+ 173 => "recipe_diffusal_blade",
190
+ 195 => "recipe_diffusal_blade_2",
191
+ 174 => "diffusal_blade",
192
+ 196 => "diffusal_blade_2",
193
+ 175 => "recipe_ethereal_blade",
194
+ 176 => "ethereal_blade",
195
+ 177 => "recipe_soul_ring",
196
+ 178 => "soul_ring",
197
+ 179 => "recipe_arcane_boots",
198
+ 180 => "arcane_boots",
199
+ 181 => "orb_of_venom",
200
+ 182 => "stout_shield",
201
+ 184 => "recipe_ancient_janggo",
202
+ 185 => "ancient_janggo",
203
+ 186 => "recipe_medallion_of_courage",
204
+ 187 => "medallion_of_courage",
205
+ 188 => "smoke_of_deceit",
206
+ 189 => "recipe_veil_of_discord",
207
+ 190 => "veil_of_discord",
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
+ 228 => "greevil_whistle",
227
+ 235 => "greevil_whistle_toggle",
228
+ 227 => "present",
229
+ 229 => "winter_stocking",
230
+ 230 => "winter_skates",
231
+ 231 => "winter_cake",
232
+ 232 => "winter_cookie",
233
+ 233 => "winter_coco",
234
+ 234 => "winter_ham",
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"
242
+ }.freeze
243
+
244
+ attr_reader :id, :name
245
+
246
+ def initialize(id)
247
+ @id = id
248
+ @name = MAPPING[id]
249
+ end
250
+ end
251
+ end
252
+ end