renchap-wowr 0.5.1 → 0.5.3

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/README CHANGED
@@ -36,6 +36,11 @@ Author
36
36
  ------
37
37
  Originally written by Ben Humphreys benhumphreys[at]gmail.com
38
38
  Maintained by Peter Wood peter+wowr[at]alastria.net
39
- Patches from Renaud Chaput and Michael Chen
39
+
40
+ Patches:
41
+ Renaud Chaput
42
+ Michael Chen
43
+ Ken Preudhomme
44
+ Scott (thestorcks.de)
40
45
 
41
46
  Apologies to anyone missed, please let Peter Wood know if this is the case.
@@ -3,7 +3,7 @@
3
3
  # http://wowr.rubyforge.org/
4
4
  # Written by Ben Humphreys
5
5
  # http://benhumphreys.co.uk/
6
- # Matained By Peter Wood
6
+ # Maintained By Peter Wood
7
7
  # http://narwar.net/
8
8
  #
9
9
  # Author:: Ben Humphreys
@@ -299,7 +299,7 @@ module Wowr
299
299
 
300
300
  xml = get_xml(@@guild_info_url, options)
301
301
 
302
- if (xml%'guildKey') && !(xml%'guildInfo').children.empty?
302
+ if !(xml%'guildInfo').children.empty?
303
303
  return Wowr::Classes::FullGuild.new(xml)
304
304
  else
305
305
  raise Wowr::Exceptions::GuildNotFound.new(options[:guild_name])
@@ -310,9 +310,11 @@ module Wowr
310
310
  # Search for items with the specified name.
311
311
  # Returns an array of Wowr::Classes::SearchItem.
312
312
  # Searches across all realms.
313
+ # Can search for items based upon the following options => :source, :dungeon, :item_type ("armor, weapon, etc"), :item_slot (head, shoulders, etc), and :item_sub_type (leather, mail, etc)
314
+ # The dungeon param is the dungeon ID
313
315
  # Caching is disabled for searching.
314
316
  # * name (String) Name of the item
315
- # * options (Hash) Optional hash of arguments identical to those used in the API constructor (realm, debug, cache etc.)
317
+ # * options (Hash) Optional hash of arguments identical to those used in the API constructor (realm, debug, cache etc.).
316
318
  def search_items(name, options = {})
317
319
  if (name.is_a?(Hash))
318
320
  options = name
@@ -321,6 +323,8 @@ module Wowr
321
323
  end
322
324
 
323
325
  options.merge!(:type => @@search_types[:item])
326
+
327
+ puts options.inspect if options[:debug]
324
328
  return search(options)
325
329
  end
326
330
 
@@ -463,16 +467,18 @@ module Wowr
463
467
  # * cookie (String) Cookie data returned by the login function.
464
468
  # * guild_name (String) Guild name
465
469
  # * options (Hash) Optional hash of arguments identical to those used in the API constructor (realm, debug, cache etc.)
466
- def get_guild_bank_contents(cookie, guild_name = @guild_name, options = {})
470
+ def get_guild_bank_contents(cookie, name = @guild_name, options = {})
471
+ full_cookie = ' JSESSIONID='+cookie
472
+
467
473
  if (cookie.is_a?(Hash))
468
- options = cookie
474
+ options = full_cookie
469
475
  elsif (guild_name.is_a?(Hash))
470
476
  options = guild_name
471
- options.merge!(:cookie => cookie)
472
- options.merge!(:guild_name => @guild_name)
477
+ options.merge!(:cookie => full_cookie)
478
+ options.merge!(:guild_name => name)
473
479
  else
474
- options.merge!(:cookie => cookie)
475
- options.merge!(:guild_name => guild_name)
480
+ options.merge!(:cookie => full_cookie)
481
+ options.merge!(:guild_name => name)
476
482
  end
477
483
  options = merge_defaults(options)
478
484
 
@@ -504,14 +510,16 @@ module Wowr
504
510
  # * guild_name (String) Guild name
505
511
  # * options (Hash) Optional hash of arguments identical to those used in the API constructor (realm, debug, cache etc.)
506
512
  def get_guild_bank_log(cookie, name = @guild_name, options = {})
513
+ full_cookie = ' JSESSIONID='+cookie
514
+
507
515
  if (cookie.is_a?(Hash))
508
- options = cookie
516
+ options = full_cookie
509
517
  elsif (name.is_a?(Hash))
510
518
  options = name
511
- options.merge!(:cookie => cookie)
512
- options.merge!(:guild_name => @guild_name)
519
+ options.merge!(:cookie => full_cookie)
520
+ options.merge!(:guild_name => name)
513
521
  else
514
- options.merge!(:cookie => cookie)
522
+ options.merge!(:cookie => full_cookie)
515
523
  options.merge!(:guild_name => name)
516
524
  end
517
525
 
@@ -538,20 +546,22 @@ module Wowr
538
546
 
539
547
 
540
548
  def get_complete_world_calendar(cookie, name = @character_name, realm = @realm, options = {})
549
+ full_cookie = ' JSESSIONID='+cookie
550
+
541
551
  if (cookie.is_a?(Hash))
542
- options = cookie
552
+ options = full_cookie
543
553
  elsif (name.is_a?(Hash))
544
554
  options = name
545
- options.merge!(:cookie => cookie)
555
+ options.merge!(:cookie => full_cookie)
546
556
  options.merge!(:character_name => @character_name)
547
557
  options.merge!(:realm => @realm)
548
558
  elsif (realm.is_a?(Hash))
549
559
  options = realm
550
- options.merge!(:cookie => cookie)
560
+ options.merge!(:cookie => full_cookie)
551
561
  options.merge!(:character_name => name)
552
562
  options.merge!(:realm => @realm)
553
563
  else
554
- options.merge!(:cookie => cookie)
564
+ options.merge!(:cookie => full_cookie)
555
565
  options.merge!(:character_name => name)
556
566
  options.merge!(:realm => realm)
557
567
  end
@@ -572,20 +582,22 @@ module Wowr
572
582
 
573
583
 
574
584
  def get_world_calendar(cookie, name = @character_name, realm = @realm, options = {})
585
+ full_cookie = ' JSESSIONID='+cookie
586
+
575
587
  if (cookie.is_a?(Hash))
576
- options = cookie
588
+ options = full_cookie
577
589
  elsif (name.is_a?(Hash))
578
590
  options = name
579
- options.merge!(:cookie => cookie)
591
+ options.merge!(:cookie => full_cookie)
580
592
  options.merge!(:character_name => @character_name)
581
593
  options.merge!(:realm => @realm)
582
594
  elsif (realm.is_a?(Hash))
583
595
  options = realm
584
- options.merge!(:cookie => cookie)
596
+ options.merge!(:cookie => full_cookie)
585
597
  options.merge!(:character_name => name)
586
598
  options.merge!(:realm => @realm)
587
599
  else
588
- options.merge!(:cookie => cookie)
600
+ options.merge!(:cookie => full_cookie)
589
601
  options.merge!(:character_name => name)
590
602
  options.merge!(:realm => realm)
591
603
  end
@@ -618,21 +630,23 @@ module Wowr
618
630
  end
619
631
 
620
632
 
621
- def get_full_user_calendar(cookie, name = @character_name, realm = @realm, options = {})
633
+ def get_full_user_calendar(cookie, name = @character_name, realm = @realm, options = {})
634
+ full_cookie = ' JSESSIONID='+cookie
635
+
622
636
  if (cookie.is_a?(Hash))
623
- options = cookie
637
+ options = full_cookie
624
638
  elsif (name.is_a?(Hash))
625
639
  options = name
626
- options.merge!(:cookie => cookie)
640
+ options.merge!(:cookie => full_cookie)
627
641
  options.merge!(:character_name => @character_name)
628
642
  options.merge!(:realm => @realm)
629
643
  elsif (realm.is_a?(Hash))
630
644
  options = realm
631
- options.merge!(:cookie => cookie)
645
+ options.merge!(:cookie => full_cookie)
632
646
  options.merge!(:character_name => name)
633
647
  options.merge!(:realm => @realm)
634
648
  else
635
- options.merge!(:cookie => cookie)
649
+ options.merge!(:cookie => full_cookie)
636
650
  options.merge!(:character_name => name)
637
651
  options.merge!(:realm => realm)
638
652
  end
@@ -654,20 +668,22 @@ module Wowr
654
668
 
655
669
 
656
670
  def get_user_calendar(cookie, name = @character_name, realm = @realm, options = {})
671
+ full_cookie = ' JSESSIONID='+cookie
672
+
657
673
  if (cookie.is_a?(Hash))
658
- options = cookie
674
+ options = full_cookie
659
675
  elsif (name.is_a?(Hash))
660
676
  options = name
661
- options.merge!(:cookie => cookie)
677
+ options.merge!(:cookie => full_cookie)
662
678
  options.merge!(:character_name => @character_name)
663
679
  options.merge!(:realm => @realm)
664
680
  elsif (realm.is_a?(Hash))
665
681
  options = realm
666
- options.merge!(:cookie => cookie)
682
+ options.merge!(:cookie => full_cookie)
667
683
  options.merge!(:character_name => name)
668
684
  options.merge!(:realm => @realm)
669
685
  else
670
- options.merge!(:cookie => cookie)
686
+ options.merge!(:cookie => full_cookie)
671
687
  options.merge!(:character_name => name)
672
688
  options.merge!(:realm => realm)
673
689
  end
@@ -701,28 +717,30 @@ module Wowr
701
717
 
702
718
 
703
719
  def get_calendar_event (cookie, event = nil, name = @character_name, realm = @realm, options = {})
720
+ full_cookie = ' JSESSIONID='+cookie
721
+
704
722
  if (cookie.is_a?(Hash))
705
- options = cookie
723
+ options = full_cookie
706
724
  elsif (event.is_a?(Hash))
707
725
  options = event
708
- options.merge!(:cookie => cookie)
726
+ options.merge!(:cookie => full_cookie)
709
727
  options.merge!(:event => nil)
710
728
  options.merge!(:character_name => @character_name)
711
729
  options.merge!(:realm => @realm)
712
730
  elsif (name.is_a?(Hash))
713
731
  options = name
714
- options.merge!(:cookie => cookie)
732
+ options.merge!(:cookie => full_cookie)
715
733
  options.merge!(:event => event)
716
734
  options.merge!(:character_name => @character_name)
717
735
  options.merge!(:realm => @realm)
718
736
  elsif (realm.is_a?(Hash))
719
737
  options = realm
720
- options.merge!(:cookie => cookie)
738
+ options.merge!(:cookie => full_cookie)
721
739
  options.merge!(:event => event)
722
740
  options.merge!(:character_name => name)
723
741
  options.merge!(:realm => @realm)
724
742
  else
725
- options.merge!(:cookie => cookie)
743
+ options.merge!(:cookie => full_cookie)
726
744
  options.merge!(:event => event)
727
745
  options.merge!(:character_name => name)
728
746
  options.merge!(:realm => realm)
@@ -906,7 +924,7 @@ module Wowr
906
924
 
907
925
  # All we need to do is goto the armory login page passing our long life cookie, we should get 302 instantly.
908
926
  stage1 = login_http(authentication_url, true, { @@persistant_cookie => long_life_cookie })
909
-
927
+
910
928
  # Let's see
911
929
  if (stage1.code == "200")
912
930
  # It's no good, our cookie doesn't work anymore.
@@ -1035,12 +1053,19 @@ module Wowr
1035
1053
 
1036
1054
  # better way of doing this?
1037
1055
  # Map custom keys to the HTTP request values
1056
+ # TODO add handles for searching based upon stats
1038
1057
  reqs = {
1039
1058
  :character_name => 'n',
1059
+ :source => "fl[source]", # dungeon, badges, arena, etc
1060
+ :dungeon => "fl[dungeon]", # seems it needs the dungeons id rather than name
1061
+ :difficulty => "fl[difficulty]", # normal, heroic, etc
1062
+ :item_type => "fl[type]", # weapon, armor, trinket, etc
1063
+ :item_slot => "fl[slot]", # head, shoulders, etc
1064
+ :item_sub_type => "fl[subTp]", # leather, mail, etc
1040
1065
  :realm => 'r',
1041
1066
  :search => 'searchQuery',
1042
1067
  :type => 'searchType',
1043
- :guild_name => 'n',
1068
+ :guild_name => 'gn',
1044
1069
  :item_id => 'i',
1045
1070
  :team_size => 'ts',
1046
1071
  :team_name => 't',
@@ -1052,7 +1077,7 @@ module Wowr
1052
1077
  :event => 'e',
1053
1078
  :now => 'now',
1054
1079
  :achievement_category => 'c'
1055
- }
1080
+ }
1056
1081
 
1057
1082
  params = []
1058
1083
  options.each do |key, value|
@@ -1082,7 +1107,7 @@ module Wowr
1082
1107
 
1083
1108
  req["cookie"] += options[:cookie] if options[:cookie]
1084
1109
 
1085
- uri = URI.parse(url)
1110
+ uri = URI.parse(URI.escape(url))
1086
1111
 
1087
1112
  http = Net::HTTP.new(uri.host, uri.port)
1088
1113
 
@@ -1097,7 +1122,7 @@ module Wowr
1097
1122
  begin
1098
1123
  tries = 0
1099
1124
  http.start do
1100
- puts "Get URL "+url if options[:debug]
1125
+ puts "Get URL "+ url if options[:debug]
1101
1126
  res = http.request req
1102
1127
  # response = res.body
1103
1128
 
@@ -1109,13 +1134,13 @@ module Wowr
1109
1134
  if tries > @@max_connection_tries
1110
1135
  raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
1111
1136
  else
1112
- retry
1137
+ redo
1113
1138
  end
1114
1139
  end
1115
1140
  end
1116
1141
  rescue Timeout::Error => e
1117
1142
  raise Wowr::Exceptions::NetworkTimeout.new('Timed out - Timeout::Error Exception')
1118
- rescue Net::HTTPExceptions => e
1143
+ rescue SocketError, Net::HTTPExceptions => e
1119
1144
  raise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.')
1120
1145
  end
1121
1146
  end
@@ -1195,7 +1220,7 @@ module Wowr
1195
1220
  def login_final_bounce(url)
1196
1221
  # Let's bounce to our page that will give us our short term cookie, URL has Kerbrose style ticket.
1197
1222
  finalstage = login_http(url)
1198
-
1223
+
1199
1224
  # Did we get a 200?
1200
1225
  if (finalstage.code == "200")
1201
1226
  # Get the short term cookie at last
@@ -1231,7 +1256,7 @@ module Wowr
1231
1256
  end
1232
1257
 
1233
1258
  req.set_form_data(data, '&') if data
1234
-
1259
+
1235
1260
  http.start do
1236
1261
  res = http.request(req)
1237
1262
 
@@ -1244,7 +1269,7 @@ module Wowr
1244
1269
  if tries > @@max_connection_tries
1245
1270
  raise Wowr::Exceptions::NetworkTimeout.new('Timed out')
1246
1271
  else
1247
- retry
1272
+ redo
1248
1273
  end
1249
1274
  end
1250
1275
  end
@@ -24,6 +24,7 @@ module Wowr
24
24
  :realm,
25
25
  :battle_group, :last_login,
26
26
  :relevance, :search_rank,
27
+ :achievement_points,
27
28
 
28
29
  :season_games_played, :season_games_won, :team_rank, :contribution # From ArenaTeam info
29
30
 
@@ -64,6 +65,9 @@ module Wowr
64
65
  @relevance = elem[:relevance].to_i
65
66
  @search_rank = elem[:searchRank].to_i
66
67
 
68
+ @achievement_points = elem[:points].to_i if elem[:points]
69
+ @achievement_points = elem[:achPoints].to_i if elem[:achPoints]
70
+
67
71
  # Incoming string is 2007-02-24 20:33:04.0, parse to datetime
68
72
  #@last_login = elem[:lastLoginDate] == "" ? nil : DateTime.parse(elem[:lastLoginDate])
69
73
  @last_login = elem[:lastLoginDate] == "" ? nil : elem[:lastLoginDate]
@@ -130,7 +134,8 @@ module Wowr
130
134
  class InfoCharacter < Character
131
135
 
132
136
  # character_info
133
- attr_reader :char_url, :title, :known_titles,
137
+ attr_reader :char_url,
138
+ :title, :known_titles,
134
139
  :faction, :faction_id,
135
140
  :arena_teams,
136
141
  :last_modified,
@@ -147,7 +152,7 @@ module Wowr
147
152
 
148
153
  attr_reader :melee, :ranged, :spell,
149
154
  :defenses, :resistances,
150
- :talent_spec, :pvp,
155
+ :talent_spec, :all_talent_specs, :pvp,
151
156
  :professions,
152
157
  :items,
153
158
  :buffs, :debuffs
@@ -156,6 +161,8 @@ module Wowr
156
161
  # Don't care about battlegroups yet
157
162
  # I don't think I can call stuff from the constructor?
158
163
  def initialize(sheet, api = nil)
164
+ super(sheet%'character', api)
165
+
159
166
  @api = api
160
167
 
161
168
  character_info(sheet%'character')
@@ -237,14 +244,20 @@ module Wowr
237
244
 
238
245
  def character_tab(elem)
239
246
  # <title value=""/>
240
- @title = (elem%'title')[:value] == "" ? nil : (elem%'title')[:value]
241
-
247
+ #@title = (elem%'title')[:value] == "" ? nil : (elem%'title')[:value]
248
+ if (@prefix || @suffix)
249
+ @title = (@prefix ? @prefix : "") + "%s" + (@suffix ? @suffix : "")
250
+ end
251
+
252
+
242
253
  @known_titles = []
243
254
 
244
255
  @known_titles << @title if (@title)
245
- (elem%'knownTitles'/:title).each do |entry|
246
- @known_titles << entry[:value] if (!@known_titles.include?(entry[:value]))
247
- end
256
+
257
+ #@known_titles << @title if (@title)
258
+ #(elem%'knownTitles'/:title).each do |entry|
259
+ # @known_titles << entry[:value] if (!@known_titles.include?(entry[:value]))
260
+ #end
248
261
 
249
262
  @health = (elem%'characterBars'%'health')[:effective].to_i
250
263
  @second_bar = SecondBar.new(elem%'characterBars'%'secondBar')
@@ -269,7 +282,14 @@ module Wowr
269
282
  @resistances[res] = Resistance.new(elem%'resistances'%res)
270
283
  end
271
284
 
272
- @talent_spec = TalentSpec.new(elem%'talentSpec')
285
+ @all_talent_specs = []
286
+
287
+ (elem%'talentSpecs'/:talentSpec).each do |spec|
288
+ new_spec = TalentSpec.new(spec)
289
+ @all_talent_specs << new_spec
290
+
291
+ @talent_spec = new_spec if (new_spec.active)
292
+ end
273
293
 
274
294
  @pvp = Pvp.new(elem%'pvp')
275
295
 
@@ -677,13 +697,16 @@ module Wowr
677
697
 
678
698
  # Note the list of talent trees starts at 1. This is quirky, but that's what's used in the XML
679
699
  class TalentSpec
680
- attr_reader :trees
700
+ attr_reader :trees, :active, :group, :primary
681
701
 
682
702
  def initialize(elem)
683
703
  @trees = []
684
704
  @trees[1] = elem[:treeOne].to_i
685
705
  @trees[2] = elem[:treeTwo].to_i
686
706
  @trees[3] = elem[:treeThree].to_i
707
+ @active = (elem[:active].to_i == 1 ? true : false)
708
+ @group = elem[:group].to_i
709
+ @primary = elem[:prim]
687
710
  end
688
711
  end
689
712
 
@@ -14,8 +14,8 @@ module Wowr #:nodoc:
14
14
  alias_method :to_s, :name
15
15
 
16
16
  def initialize(elem)
17
- if (elem%'guildKey')
18
- guild = (elem%'guildKey')
17
+ if (elem%'guildHeader')
18
+ guild = (elem%'guildHeader')
19
19
  else
20
20
  guild = elem
21
21
  end
@@ -82,4 +82,4 @@ module Wowr #:nodoc:
82
82
 
83
83
  end
84
84
  end
85
- end
85
+ end
@@ -16,7 +16,7 @@ module Wowr
16
16
  attr_reader :motd, :info, :money, :ranks, :bags
17
17
 
18
18
  def initialize(elem)
19
- super(elem%'guildKey')
19
+ super(elem%'guildHeader')
20
20
 
21
21
  @motd = (elem%'guildMessages')[:motd]
22
22
  @info = (elem%'guildMessages')[:info]
@@ -58,15 +58,18 @@ module Wowr
58
58
 
59
59
  def initialize(elem, api = nil)
60
60
  super(elem)
61
-
61
+
62
62
  @entries = []
63
- (elem%'banklogs'/:banklog).each do |entry|
63
+
64
+ if (elem%'banklogs')
65
+ (elem%'banklogs'/:banklog).each do |entry|
64
66
  @entries << GuildBankLogEntry.new(entry, self, api)
65
- end
67
+ end
66
68
 
67
- @group_now = (elem%'banklogs')[:now].to_i
68
- @group_next = (elem%'banklogs')[:next].to_i
69
- @group_prev = (elem%'banklogs')[:prev].to_i
69
+ @group_now = (elem%'banklogs')[:now].to_i
70
+ @group_next = (elem%'banklogs')[:next].to_i
71
+ @group_prev = (elem%'banklogs')[:prev].to_i
72
+ end
70
73
  end
71
74
  end
72
75
 
@@ -98,7 +101,10 @@ module Wowr
98
101
  3 => 'Move Item',
99
102
  4 => 'Deposit Money',
100
103
  5 => 'Withdraw Money',
101
- 6 => 'Repair'
104
+ 6 => 'Repair',
105
+ 7 => 'Move Item',
106
+ 8 => 'Withdraw Money',
107
+ 9 => 'Guild Bank Tab Purchase'
102
108
  }
103
109
 
104
110
  def initialize(elem, bank = nil, api = nil)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renchap-wowr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Humphreys
8
8
  - Peter Wood
9
9
  - Renaud Chaput
10
+ - Ken Preudhomme
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
@@ -67,6 +68,7 @@ files:
67
68
  - README
68
69
  has_rdoc: true
69
70
  homepage: http://wowr.rubyforge.org/
71
+ licenses:
70
72
  post_install_message:
71
73
  rdoc_options:
72
74
  - --inline-source
@@ -88,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  requirements: []
89
91
 
90
92
  rubyforge_project: wowr
91
- rubygems_version: 1.2.0
93
+ rubygems_version: 1.3.5
92
94
  signing_key:
93
95
  specification_version: 2
94
96
  summary: A Ruby library for the World of Warcraft Armory