wowr 0.1.2 → 0.2.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.
- data/lib/wowr.rb +159 -39
- data/lib/wowr/classes.rb +107 -34
- metadata +2 -2
data/lib/wowr.rb
CHANGED
@@ -12,13 +12,11 @@ rescue LoadError
|
|
12
12
|
end
|
13
13
|
require 'net/http'
|
14
14
|
require 'cgi'
|
15
|
+
require 'fileutils' # for making cache directories
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
require 'wowr/exceptions'
|
20
|
-
require 'wowr/extensions'
|
21
|
-
require 'wowr/classes'
|
17
|
+
require 'wowr/exceptions.rb'
|
18
|
+
require 'wowr/extensions.rb'
|
19
|
+
require 'wowr/classes.rb'
|
22
20
|
|
23
21
|
module Wowr
|
24
22
|
class API
|
@@ -41,6 +39,8 @@ module Wowr
|
|
41
39
|
@@arena_team_url = 'team-info.xml'
|
42
40
|
|
43
41
|
@@max_connection_tries = 10
|
42
|
+
|
43
|
+
@@cache_directory_path = 'cache/'
|
44
44
|
|
45
45
|
# Tiny forum-used race/class icons
|
46
46
|
# @@icon_url = 'http://wowbench.com/images/icons/32x32/'
|
@@ -78,7 +78,6 @@ module Wowr
|
|
78
78
|
9 => 'Warlock',
|
79
79
|
#10 => 'Purveyor of Baked Goods', # there is no class 10
|
80
80
|
11 => 'Druid'
|
81
|
-
# 12 => 'Death Knight'?
|
82
81
|
}
|
83
82
|
|
84
83
|
@@genders = {
|
@@ -110,22 +109,29 @@ module Wowr
|
|
110
109
|
|
111
110
|
@@arena_team_sizes = [2, 3, 5]
|
112
111
|
|
113
|
-
attr_accessor :character_name, :guild_name, :realm, :locale
|
112
|
+
attr_accessor :character_name, :guild_name, :realm, :locale, :caching
|
114
113
|
|
115
114
|
# You can set up the API with an optional default guild and realm
|
116
115
|
# These will be used in all your API requests unless you specify otherwise
|
117
116
|
# For item requests, the locale will not matter in results, but may affect the speed of replies
|
117
|
+
# Caching is off by default
|
118
118
|
# TODO: are these nil declarations pointless?
|
119
|
-
def initialize(options = {:character_name => nil,
|
119
|
+
def initialize(options = {:character_name => nil,
|
120
|
+
:guild_name => nil,
|
121
|
+
:realm => nil,
|
122
|
+
:locale => :us,
|
123
|
+
:caching => false})
|
120
124
|
@character_name = options[:character_name]
|
121
125
|
@guild_name = options[:guild_name]
|
122
126
|
@realm = options[:realm]
|
123
127
|
@locale = options[:locale] #|| :us
|
128
|
+
@caching = options[:caching]
|
124
129
|
end
|
125
130
|
|
126
131
|
|
127
132
|
# General-purpose search
|
128
133
|
# All specific searches are wrappers around this method.
|
134
|
+
# Caching is disabled for searching
|
129
135
|
def search(options = {:search => nil, :type => nil})
|
130
136
|
if @@search_types.include? options[:type]
|
131
137
|
raise Wowr::Exceptions::InvalidSearchType.new
|
@@ -135,6 +141,8 @@ module Wowr
|
|
135
141
|
raise Wowr::Exceptions::NoSearchString.new
|
136
142
|
end
|
137
143
|
|
144
|
+
options.merge!(:caching => false)
|
145
|
+
|
138
146
|
xml = get_xml(@@search_url, options)
|
139
147
|
|
140
148
|
results = []
|
@@ -172,13 +180,22 @@ module Wowr
|
|
172
180
|
|
173
181
|
# Characters
|
174
182
|
# Note searches go across all realms by default
|
183
|
+
# Caching is disabled for searching
|
175
184
|
def search_characters(options = {:name => @character_name})
|
176
185
|
options.merge!(:type => @@search_types[:character])
|
177
186
|
return search(options)
|
178
187
|
end
|
179
188
|
|
180
|
-
def get_character_sheet(options = {:character_name => @character_name, :realm => @realm})
|
189
|
+
def get_character_sheet(options = {:character_name => @character_name, :realm => @realm, :caching => @caching})
|
181
190
|
xml = get_xml(@@character_sheet_url, options)
|
191
|
+
|
192
|
+
# resist_types = ['arcane', 'fire', 'frost', 'holy', 'nature', 'shadow']
|
193
|
+
# @resistances = {}
|
194
|
+
# resist_types.each do |res|
|
195
|
+
# @resistances[res] = Wowr::Classes::Resistance.new(xml%'resistances'%res)
|
196
|
+
# end
|
197
|
+
# puts @resistances.to_yaml
|
198
|
+
# puts xml
|
182
199
|
return Wowr::Classes::CharacterSheet.new(xml)
|
183
200
|
end
|
184
201
|
|
@@ -186,12 +203,13 @@ module Wowr
|
|
186
203
|
|
187
204
|
# Guilds
|
188
205
|
# Note searches go across all realms by default
|
206
|
+
# Caching is disabled for searching
|
189
207
|
def search_guilds(options = {:search => @guild_name, :locale => @locale})
|
190
208
|
options.merge!(:type => @@search_types[:guild])
|
191
209
|
return search(options)
|
192
210
|
end
|
193
211
|
|
194
|
-
def get_guild(options = {:guild_name => @guild_name, :realm => @realm})
|
212
|
+
def get_guild(options = {:guild_name => @guild_name, :realm => @realm, :caching => @caching})
|
195
213
|
xml = get_xml(@@guild_info_url, options)
|
196
214
|
return Wowr::Classes::Guild.new(xml)
|
197
215
|
end
|
@@ -200,6 +218,7 @@ module Wowr
|
|
200
218
|
|
201
219
|
# Items
|
202
220
|
# Items are not realm-specific
|
221
|
+
# Caching is disabled for searching
|
203
222
|
def search_items(options = {:search => nil})
|
204
223
|
options.merge!(:type => @@search_types[:item])
|
205
224
|
return search(options)
|
@@ -211,7 +230,7 @@ module Wowr
|
|
211
230
|
#return Wowr::Classes::ItemTooltip.new(xml%'itemTooltip')
|
212
231
|
#end
|
213
232
|
|
214
|
-
def get_item_info(options = {:item_id => nil, :locale => @locale})
|
233
|
+
def get_item_info(options = {:item_id => nil, :locale => @locale, :caching => @caching})
|
215
234
|
xml = get_xml(@@item_info_url, options)
|
216
235
|
if (xml%'itemInfo'%'item')
|
217
236
|
return Wowr::Classes::ItemInfo.new(xml%'itemInfo'%'item')
|
@@ -220,7 +239,7 @@ module Wowr
|
|
220
239
|
end
|
221
240
|
end
|
222
241
|
|
223
|
-
def get_item_tooltip(options = {:item_id => nil})
|
242
|
+
def get_item_tooltip(options = {:item_id => nil, :caching => @caching})
|
224
243
|
xml = get_xml(@@item_tooltip_url, options)
|
225
244
|
|
226
245
|
# tooltip returns empty document when not found
|
@@ -234,12 +253,13 @@ module Wowr
|
|
234
253
|
|
235
254
|
|
236
255
|
# Arena Teams
|
256
|
+
# Caching is disabled for searching
|
237
257
|
def search_arena_teams(options = {})
|
238
258
|
options.merge!(:type => @@search_types[:arena_team])
|
239
259
|
return search(options)
|
240
260
|
end
|
241
261
|
|
242
|
-
def get_arena_team(options = {:team_name => :nil, :team_size => nil, :realm => @realm})
|
262
|
+
def get_arena_team(options = {:team_name => :nil, :team_size => nil, :realm => @realm, :caching => @caching})
|
243
263
|
if !@@arena_team_sizes.include?(options[:team_size])
|
244
264
|
raise Wowr::Exceptions::InvalidArenaTeamSize.new("Arena teams size must be: #{@@arena_team_sizes.inspect}")
|
245
265
|
end
|
@@ -254,19 +274,22 @@ module Wowr
|
|
254
274
|
# end
|
255
275
|
|
256
276
|
|
257
|
-
|
258
|
-
def
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
277
|
+
# Clear the cache, optional filename
|
278
|
+
def clear_cache(cache_path = @@cache_directory_path)
|
279
|
+
begin
|
280
|
+
FileUtils.remove_dir(cache_path)
|
281
|
+
rescue Exception => e
|
282
|
+
|
263
283
|
end
|
264
284
|
end
|
265
285
|
|
286
|
+
|
287
|
+
protected
|
288
|
+
|
266
289
|
# TODO: pretty damn hacky
|
267
|
-
def get_xml(url,
|
268
|
-
|
290
|
+
def get_xml(url, options = {:caching => @caching})
|
269
291
|
# better way of doing this?
|
292
|
+
# Map custom keys to the HTTP request values
|
270
293
|
reqs = {
|
271
294
|
:character_name => 'n',
|
272
295
|
:realm => 'r',
|
@@ -279,7 +302,7 @@ module Wowr
|
|
279
302
|
}
|
280
303
|
|
281
304
|
params = []
|
282
|
-
|
305
|
+
options.each do |key, value|
|
283
306
|
if reqs[key]
|
284
307
|
params << "#{reqs[key]}=#{u(value)}"
|
285
308
|
end
|
@@ -289,30 +312,20 @@ module Wowr
|
|
289
312
|
query = '?' + params.join('&')
|
290
313
|
end
|
291
314
|
|
292
|
-
locale =
|
315
|
+
locale = options[:locale] || @locale
|
293
316
|
|
294
317
|
base = self.base_url(locale)
|
295
|
-
uri = URI.parse(base + url)
|
296
318
|
full_query = base + url + query
|
319
|
+
|
297
320
|
#puts full_query
|
298
|
-
req = Net::HTTP::Get.new(full_query)
|
299
|
-
req["user-agent"] = "Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2"
|
300
|
-
res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
|
301
321
|
|
302
|
-
|
303
|
-
|
304
|
-
when Net::HTTPSuccess, Net::HTTPRedirection
|
305
|
-
res.body
|
322
|
+
if options[:caching]
|
323
|
+
response = get_cache(full_query)
|
306
324
|
else
|
307
|
-
|
308
|
-
if tries > @@max_connection_tries
|
309
|
-
raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
|
310
|
-
else
|
311
|
-
retry
|
312
|
-
end
|
325
|
+
response = http_request(full_query)
|
313
326
|
end
|
314
327
|
|
315
|
-
#puts response
|
328
|
+
# puts response
|
316
329
|
|
317
330
|
doc = Hpricot.XML(response)
|
318
331
|
begin
|
@@ -337,6 +350,113 @@ module Wowr
|
|
337
350
|
|
338
351
|
end
|
339
352
|
|
353
|
+
# TODO Rename
|
354
|
+
def http_request(url)
|
355
|
+
req = Net::HTTP::Get.new(url)
|
356
|
+
req["user-agent"] = "Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2"
|
357
|
+
|
358
|
+
uri = URI.parse(url)
|
359
|
+
|
360
|
+
http = Net::HTTP.new uri.host, uri.port
|
361
|
+
http.start do
|
362
|
+
res = http.request req
|
363
|
+
response = res.body
|
364
|
+
end
|
365
|
+
|
366
|
+
# tries = 0
|
367
|
+
# response = case res
|
368
|
+
# when Net::HTTPSuccess, Net::HTTPRedirection
|
369
|
+
# res.body
|
370
|
+
# else
|
371
|
+
# tries += 1
|
372
|
+
# if tries > @@max_connection_tries
|
373
|
+
# raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
|
374
|
+
# else
|
375
|
+
# retry
|
376
|
+
# end
|
377
|
+
# end
|
378
|
+
|
379
|
+
|
380
|
+
#response = res.body
|
381
|
+
|
382
|
+
# while
|
383
|
+
# tries += 1
|
384
|
+
# if tries > @@max_connection_tries
|
385
|
+
# raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
|
386
|
+
# else
|
387
|
+
# retry
|
388
|
+
# end
|
389
|
+
# end
|
390
|
+
#
|
391
|
+
# begin
|
392
|
+
# res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
|
393
|
+
# rescue Timeout::Error => e
|
394
|
+
# retry
|
395
|
+
# #raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
|
396
|
+
# end
|
397
|
+
#
|
398
|
+
# tries = 0
|
399
|
+
# response = case res
|
400
|
+
# when Net::HTTPSuccess, Net::HTTPRedirection
|
401
|
+
# res.body
|
402
|
+
# else
|
403
|
+
#
|
404
|
+
# end
|
405
|
+
end
|
406
|
+
|
407
|
+
|
408
|
+
def get_cache(url)
|
409
|
+
path = @@cache_directory_path + url_to_filename(url);
|
410
|
+
|
411
|
+
# file doesn't exist, make it
|
412
|
+
if !File.exists?(path)
|
413
|
+
|
414
|
+
# TODO: Hacky
|
415
|
+
FileUtils.mkdir_p(@@cache_directory_path + 'us/') unless File.directory?(@@cache_directory_path + 'us/')
|
416
|
+
FileUtils.mkdir_p(@@cache_directory_path + 'eu/') unless File.directory?(@@cache_directory_path + 'eu/')
|
417
|
+
|
418
|
+
xml_content = http_request(url)
|
419
|
+
|
420
|
+
# write the cache
|
421
|
+
file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
|
422
|
+
#file = File.open(path, 'w')
|
423
|
+
file.write(xml_content)
|
424
|
+
file.close
|
425
|
+
|
426
|
+
# file exists, return the contents
|
427
|
+
else
|
428
|
+
file = File.open(path, 'r')
|
429
|
+
xml_content = file.read
|
430
|
+
file.close
|
431
|
+
end
|
432
|
+
return xml_content
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
# :nodoc:
|
438
|
+
# remove http://
|
439
|
+
def url_to_filename(url)
|
440
|
+
if (url.include?(@@armory_url))
|
441
|
+
path = 'us/' + url.gsub(@@eu_armory_url, '')
|
442
|
+
elsif (url.include?(@@eu_armory_url))
|
443
|
+
path = 'eu/' + url.gsub(@@eu_armory_url, '')
|
444
|
+
end
|
445
|
+
|
446
|
+
return path
|
447
|
+
end
|
448
|
+
|
449
|
+
|
450
|
+
# :nodoc:
|
451
|
+
def base_url(locale = @locale)
|
452
|
+
if locale == :eu
|
453
|
+
@@eu_armory_url
|
454
|
+
else
|
455
|
+
@@armory_url
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
|
340
460
|
# :nodoc:
|
341
461
|
def u(str)
|
342
462
|
if str.instance_of?(String)
|
data/lib/wowr/classes.rb
CHANGED
@@ -37,11 +37,11 @@ module Wowr
|
|
37
37
|
:klass, :klass_id,
|
38
38
|
:gender, :gender_id,
|
39
39
|
:race, :race_id,
|
40
|
-
:guild, :guild_id,
|
40
|
+
:guild, :guild_id, :guild_url,
|
41
41
|
:battle_group, :last_login,
|
42
42
|
:relevance, :search_rank,
|
43
43
|
|
44
|
-
:season_games_played, :season_games_won, :team_rank # From ArenaTeam info
|
44
|
+
:season_games_played, :season_games_won, :team_rank, :contribution # From ArenaTeam info
|
45
45
|
|
46
46
|
def initialize(elem)
|
47
47
|
@name = elem[:name]
|
@@ -60,8 +60,9 @@ module Wowr
|
|
60
60
|
|
61
61
|
@guild = elem[:guild] == "" ? nil : elem[:guild]
|
62
62
|
@guild_id = elem[:guildId].to_i == 0 ? nil : elem[:guildId].to_i
|
63
|
+
@guild_url = elem[:guildUrl] == "" ? nil : elem[:guildUrl]
|
63
64
|
|
64
|
-
@battle_group = elem[:battleGroup]
|
65
|
+
@battle_group = elem[:battleGroup] == "" ? nil : elem[:battleGroup]
|
65
66
|
@battle_group_id = elem[:battleGroupId].to_i
|
66
67
|
|
67
68
|
@relevance = elem[:relevance].to_i
|
@@ -72,9 +73,14 @@ module Wowr
|
|
72
73
|
@last_login = elem[:lastLoginDate] == "" ? nil : elem[:lastLoginDate]
|
73
74
|
|
74
75
|
# From ArenaTeam info, can be blank on normal requests
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
#<character battleGroup="" charUrl="r=Draenor&n=Lothaar" class="Paladin" classId="2"
|
77
|
+
# contribution="1602" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0"
|
78
|
+
# guild="Passion" guildId="36659" guildUrl="r=Draenor&n=Passion&p=1" name="Lothaar"
|
79
|
+
# race="Human" raceId="1" seasonGamesPlayed="20" seasonGamesWon="13" teamRank="1"/>
|
80
|
+
@season_games_played = elem[:seasonGamesPlayed] == "" ? nil : elem[:seasonGamesPlayed].to_i
|
81
|
+
@season_games_won = elem[:seasonGamesWon] == "" ? nil : elem[:seasonGamesWon].to_i
|
82
|
+
@team_rank = elem[:teamRank] == "" ? nil : elem[:teamRank].to_i
|
83
|
+
@contribution = elem[:contribution] == "" ? nil : elem[:contribution].to_i
|
78
84
|
#@char_url = elem[:charUrl] # TODO: Merge with URL?
|
79
85
|
end
|
80
86
|
end
|
@@ -83,6 +89,7 @@ module Wowr
|
|
83
89
|
|
84
90
|
# Full character details
|
85
91
|
# uses characterInfo element
|
92
|
+
# NEEDS TO EXTEND BASE CHARACTER THING
|
86
93
|
class CharacterSheet
|
87
94
|
|
88
95
|
# character_info
|
@@ -91,9 +98,10 @@ module Wowr
|
|
91
98
|
:race, :race_id,
|
92
99
|
:klass, :klass_id,
|
93
100
|
:faction, :faction_id,
|
94
|
-
:
|
101
|
+
:guild, :guild_url,
|
95
102
|
:realm,
|
96
103
|
:battle_group,
|
104
|
+
:arena_teams,
|
97
105
|
:last_modified
|
98
106
|
|
99
107
|
# character_tab
|
@@ -105,7 +113,8 @@ module Wowr
|
|
105
113
|
alias_method :int, :intellect
|
106
114
|
alias_method :spi, :spirit
|
107
115
|
|
108
|
-
attr_reader :
|
116
|
+
attr_reader :title,
|
117
|
+
:melee, :ranged, :spell,
|
109
118
|
:defenses, :resistances,
|
110
119
|
:talent_spec, :pvp,
|
111
120
|
:professions,
|
@@ -120,14 +129,29 @@ module Wowr
|
|
120
129
|
character_tab(elem%'characterTab')
|
121
130
|
end
|
122
131
|
|
123
|
-
|
132
|
+
# <character
|
133
|
+
# battleGroup="Conviction"
|
134
|
+
# charUrl="r=Genjuros&n=Jonlok"
|
135
|
+
# class="Warlock"
|
136
|
+
# classId="9"
|
137
|
+
# faction="Horde"
|
138
|
+
# factionId="1"
|
139
|
+
# gender="Male"
|
140
|
+
# genderId="0"
|
141
|
+
# guildName=""
|
142
|
+
# lastModified="12 February 2008"
|
143
|
+
# level="41"
|
144
|
+
# name="Jonlok"
|
145
|
+
# prefix=""
|
146
|
+
# race="Orc"
|
147
|
+
# raceId="2"
|
148
|
+
# realm="Genjuros"
|
149
|
+
# suffix=""/>
|
124
150
|
def character_info(elem)
|
125
151
|
# basic info
|
126
152
|
@name = elem[:name]
|
127
153
|
@level = elem[:level].to_i
|
128
|
-
@char_url = elem[:
|
129
|
-
@rank = elem[:rank].to_i
|
130
|
-
@title = elem[:title]
|
154
|
+
@char_url = elem[:charUrl]
|
131
155
|
|
132
156
|
@klass = elem[:class]
|
133
157
|
@klass_id = elem[:classId].to_i
|
@@ -141,22 +165,37 @@ module Wowr
|
|
141
165
|
@faction = elem[:faction]
|
142
166
|
@faction_id = elem[:factionId].to_i
|
143
167
|
|
144
|
-
@guild = elem[:
|
145
|
-
@guild_url = elem[:guildUrl]
|
168
|
+
@guild = elem[:guildName] == "" ? nil : elem[:guildName]
|
169
|
+
@guild_url = elem[:guildUrl] == "" ? nil : elem[:guildUrl]
|
170
|
+
|
171
|
+
@prefix = elem[:prefix]
|
172
|
+
@suffix = elem[:suffix]
|
146
173
|
|
147
174
|
@realm = elem[:realm]
|
148
175
|
|
149
176
|
@battle_group = elem[:battleGroup]
|
150
177
|
|
151
|
-
|
178
|
+
# format is February 11, 2008
|
179
|
+
@last_modified = elem[:lastModified] == "" ? nil : DateTime.parse(elem[:lastModified])
|
180
|
+
#@last_modified = elem[:lastModified]#.to_time
|
181
|
+
|
182
|
+
@arena_teams = []
|
183
|
+
(elem/:arenaTeam).each do |arena_team|
|
184
|
+
@arena_team << ArenaTeam.new(arena_team)
|
185
|
+
end
|
186
|
+
|
152
187
|
end
|
153
188
|
|
154
189
|
def character_tab(elem)
|
190
|
+
|
191
|
+
# <title value=""/>
|
192
|
+
@title = (elem%'title')[:value] == "" ? nil : (elem%'title')[:value]
|
193
|
+
#@known_titles = <knownTitles/>
|
194
|
+
|
155
195
|
@health = (elem%'characterBars'%'health')[:effective].to_i
|
156
196
|
@second_bar = SecondBar.new(elem%'characterBars'%'secondBar')
|
157
197
|
|
158
198
|
# base stats
|
159
|
-
# % is alias for Hpricot's 'at' method, assume only 1 baseStats/strength element
|
160
199
|
@strength = Strength.new(elem%'baseStats'%'strength')
|
161
200
|
@agility = Agility.new(elem%'baseStats'%'agility')
|
162
201
|
@stamina = Stamina.new(elem%'baseStats'%'stamina')
|
@@ -169,41 +208,32 @@ module Wowr
|
|
169
208
|
@spell = Spell.new(elem.at(' > spell')) # TODO: hacky?
|
170
209
|
@defenses = Defenses.new(elem%'defenses')
|
171
210
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
#@resistances[:arcane] = ArcaneResistance.new(elem[:resistances][:arcane])
|
178
|
-
#@resistances[resistance] = Resistance.new(resistance)
|
211
|
+
# TODO: Massive problem, doesn't fill in resistances for some reason
|
212
|
+
resist_types = ['arcane', 'fire', 'frost', 'holy', 'nature', 'shadow']
|
213
|
+
@resistances = {}
|
214
|
+
resist_types.each do |res|
|
215
|
+
@resistances[res] = Resistance.new(elem%'resistances'%res)
|
179
216
|
end
|
180
217
|
|
181
|
-
|
182
218
|
@talent_spec = TalentSpec.new(elem%'talentSpec')
|
183
219
|
|
184
220
|
@pvp = Pvp.new(elem%'pvp')
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
# professions
|
221
|
+
|
189
222
|
@professions = []
|
190
223
|
(elem%'professions'/:skill).each do |skill|
|
191
224
|
@professions << Profession.new(skill)
|
192
225
|
end
|
193
226
|
|
194
|
-
# items
|
195
227
|
@items = []
|
196
228
|
(elem%'items'/:item).each do |item|
|
197
229
|
@items << EquippedItem.new(item)
|
198
230
|
end
|
199
231
|
|
200
|
-
# buffs
|
201
232
|
@buffs = []
|
202
233
|
(elem%'buffs'/:spell).each do |buff|
|
203
234
|
@buffs << Buff.new(buff)
|
204
235
|
end
|
205
236
|
|
206
|
-
# debuffs
|
207
237
|
@debuffs = []
|
208
238
|
(elem%'debuffs'/:spell).each do |debuff|
|
209
239
|
@debuffs << Buff.new(debuff)
|
@@ -297,11 +327,22 @@ module Wowr
|
|
297
327
|
|
298
328
|
|
299
329
|
|
330
|
+
# <melee>
|
331
|
+
# <mainHandDamage dps="65.6" max="149" min="60" percent="0" speed="1.60"/>
|
332
|
+
# <offHandDamage dps="0.0" max="0" min="0" percent="0" speed="2.00"/>
|
333
|
+
# <mainHandSpeed hastePercent="0.00" hasteRating="0" value="1.60"/>
|
334
|
+
# <offHandSpeed hastePercent="0.00" hasteRating="0" value="2.00"/>
|
335
|
+
# <power base="338" effective="338" increasedDps="24.0"/>
|
336
|
+
# <hitRating increasedHitPercent="0.00" value="0"/>
|
337
|
+
# <critChance percent="4.16" plusPercent="0.00" rating="0"/>
|
338
|
+
# <expertise additional="0" percent="0.00" rating="0" value="0"/>
|
339
|
+
# </melee>
|
300
340
|
class Melee
|
301
341
|
attr_reader :main_hand_skill, :off_hand_skill,
|
302
342
|
:main_hand_damage, :off_hand_damage,
|
303
343
|
:main_hand_speed, :off_hand_speed,
|
304
344
|
:speed, :hit_rating, :crit_chance
|
345
|
+
:expertise
|
305
346
|
|
306
347
|
def initialize(elem)
|
307
348
|
# TODO: Do these not exist anymore?
|
@@ -317,9 +358,19 @@ module Wowr
|
|
317
358
|
@power = WeaponPower.new(elem%'power')
|
318
359
|
@hit_rating = WeaponHitRating.new(elem%'hitRating')
|
319
360
|
@crit_chance = WeaponCritChance.new(elem%'critChance')
|
361
|
+
|
362
|
+
@expertise = WeaponExpertise.new(elem%'expertise')
|
320
363
|
end
|
321
364
|
end
|
322
365
|
|
366
|
+
# <ranged>
|
367
|
+
# <weaponSkill rating="0" value="-1"/>
|
368
|
+
# <damage dps="0.0" max="0" min="0" percent="0" speed="0.00"/>
|
369
|
+
# <speed hastePercent="0.00" hasteRating="0" value="0.00"/>
|
370
|
+
# <power base="57" effective="57" increasedDps="4.0" petAttack="-1.00" petSpell="-1.00"/>
|
371
|
+
# <hitRating increasedHitPercent="0.00" value="0"/>
|
372
|
+
# <critChance percent="0.92" plusPercent="0.00" rating="0"/>
|
373
|
+
# </ranged>
|
323
374
|
class Ranged
|
324
375
|
attr_reader :weapon_skill, :damage, :speed, :power,
|
325
376
|
:hit_rating, :crit_chance
|
@@ -396,6 +447,17 @@ module Wowr
|
|
396
447
|
end
|
397
448
|
end
|
398
449
|
|
450
|
+
# <expertise additional="0" percent="0.00" rating="0" value="0"/>
|
451
|
+
class WeaponExpertise
|
452
|
+
attr_reader :additional, :percent, :rating, :value
|
453
|
+
|
454
|
+
def initialize(elem)
|
455
|
+
@additional = elem[:additional].to_i
|
456
|
+
@percent = elem[:percent].to_f
|
457
|
+
@rating = elem[:rating].to_i
|
458
|
+
@value = elem[:value].to_i
|
459
|
+
end
|
460
|
+
end
|
399
461
|
|
400
462
|
|
401
463
|
# Decided to do funky stuff to the XML to make it more useful.
|
@@ -703,7 +765,7 @@ module Wowr
|
|
703
765
|
|
704
766
|
|
705
767
|
# Provides detailed item information
|
706
|
-
# Note that the itemtooltip just returns an empty document when the item
|
768
|
+
# Note that the itemtooltip XML just returns an empty document when the item
|
707
769
|
# can't be found.
|
708
770
|
class ItemTooltip < Item
|
709
771
|
attr_reader :desc, :overall_quality_id, :bonding, :max_count, #:id, :name, :icon,
|
@@ -781,8 +843,6 @@ module Wowr
|
|
781
843
|
end
|
782
844
|
|
783
845
|
|
784
|
-
#@bonuses[:strength] = (elem/:bonusStrength).html.to_i if (elem/:bonusStrength)
|
785
|
-
|
786
846
|
if (elem%'allowableClasses')
|
787
847
|
@allowable_classes = []
|
788
848
|
(elem%'allowableClasses'/:class).each do |klass|
|
@@ -1210,6 +1270,19 @@ module Wowr
|
|
1210
1270
|
|
1211
1271
|
# A group of individuals
|
1212
1272
|
# Note that search results don't contain the members
|
1273
|
+
# <arenaTeams>
|
1274
|
+
# <arenaTeam battleGroup="Blackout" faction="Alliance" factionId="0" gamesPlayed="10" gamesWon="7" lastSeasonRanking="0" name="SØPPERBIL" ranking="8721" rating="1610" realm="Draenor" realmUrl="b=Blackout&r=Draenor&ts=2&t=S%C3%98PPERBIL&ff=realm&fv=Draenor&select=S%C3%98PPERBIL" seasonGamesPlayed="49" seasonGamesWon="28" size="2" url="r=Draenor&ts=2&t=S%C3%98PPERBIL&select=S%C3%98PPERBIL">
|
1275
|
+
# <emblem background="ff2034cc" borderColor="ff14a30c" borderStyle="1" iconColor="ff1d800a" iconStyle="95"/>
|
1276
|
+
# <members>
|
1277
|
+
# <character battleGroup="" charUrl="r=Draenor&n=Arussil" class="Rogue" classId="4" contribution="1613" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0" guild="Adept" guildId="38253" guildUrl="r=Draenor&n=Adept&p=1" name="Arussil" race="Night Elf" raceId="4" seasonGamesPlayed="48" seasonGamesWon="28" teamRank="0"/>
|
1278
|
+
# <character battleGroup="" charUrl="r=Draenor&n=Cake" class="Shaman" classId="7" contribution="1516" gamesPlayed="0" gamesWon="0" gender="Male" genderId="0" guild="Adept" guildId="38253" guildUrl="r=Draenor&n=Adept&p=1" name="Cake" race="Draenei" raceId="11" seasonGamesPlayed="1" seasonGamesWon="1" teamRank="1"/>
|
1279
|
+
#
|
1280
|
+
# <character battleGroup="" charUrl="r=Draenor&n=Efes" class="Druid" classId="11" contribution="1508" gamesPlayed="0" gamesWon="0" gender="Female" genderId="1" guild="Adept" guildId="38253" guildUrl="r=Draenor&n=Adept&p=1" name="Efes" race="Night Elf" raceId="4" seasonGamesPlayed="13" seasonGamesWon="7" teamRank="1"/>
|
1281
|
+
# <character battleGroup="" charUrl="r=Draenor&n=Lothaar" class="Paladin" classId="2" contribution="1602" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0" guild="Ultimo Impero Oscuro" guildId="37203" guildUrl="r=Draenor&n=Ultimo+Impero+Oscuro&p=1" name="Lothaar" race="Human" raceId="1" seasonGamesPlayed="20" seasonGamesWon="13" teamRank="1"/>
|
1282
|
+
# <character battleGroup="" charUrl="r=Draenor&n=Lothaar" class="Paladin" classId="2" contribution="1602" gamesPlayed="10" gamesWon="7" gender="Male" genderId="0" guild="Passion" guildId="36659" guildUrl="r=Draenor&n=Passion&p=1" name="Lothaar" race="Human" raceId="1" seasonGamesPlayed="20" seasonGamesWon="13" teamRank="1"/>
|
1283
|
+
# </members>
|
1284
|
+
# </arenaTeam>
|
1285
|
+
# </arenaTeams>
|
1213
1286
|
class ArenaTeam
|
1214
1287
|
attr_reader :name, :size, :battle_group, :faction, :faction_id, :realm, :realm_url,
|
1215
1288
|
:games_played, :games_won, :ranking, :rating,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wowr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Humphreys
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2008-
|
14
|
+
date: 2008-03-18 00:00:00 +00:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|