steam-condenser 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Gemfile.lock +30 -0
  2. data/LICENSE +1 -1
  3. data/README.md +4 -3
  4. data/lib/steam-condenser/version.rb +2 -2
  5. data/lib/steam/community/alien_swarm/alien_swarm_mission.rb +24 -22
  6. data/lib/steam/community/alien_swarm/alien_swarm_stats.rb +66 -65
  7. data/lib/steam/community/alien_swarm/alien_swarm_weapon.rb +6 -6
  8. data/lib/steam/community/app_news.rb +2 -2
  9. data/lib/steam/community/css/css_map.rb +4 -4
  10. data/lib/steam/community/css/css_stats.rb +43 -43
  11. data/lib/steam/community/css/css_weapon.rb +5 -5
  12. data/lib/steam/community/defense_grid/defense_grid_stats.rb +36 -35
  13. data/lib/steam/community/dods/dods_class.rb +14 -14
  14. data/lib/steam/community/dods/dods_stats.rb +5 -4
  15. data/lib/steam/community/dods/dods_weapon.rb +6 -6
  16. data/lib/steam/community/game_achievement.rb +38 -31
  17. data/lib/steam/community/game_inventory.rb +6 -6
  18. data/lib/steam/community/game_leaderboard.rb +34 -32
  19. data/lib/steam/community/game_leaderboard_entry.rb +6 -6
  20. data/lib/steam/community/game_stats.rb +39 -65
  21. data/lib/steam/community/game_weapon.rb +2 -2
  22. data/lib/steam/community/l4d/abstract_l4d_stats.rb +54 -49
  23. data/lib/steam/community/l4d/abstract_l4d_weapon.rb +7 -6
  24. data/lib/steam/community/l4d/l4d2_map.rb +10 -10
  25. data/lib/steam/community/l4d/l4d2_stats.rb +33 -33
  26. data/lib/steam/community/l4d/l4d2_weapon.rb +8 -7
  27. data/lib/steam/community/l4d/l4d_explosive.rb +5 -4
  28. data/lib/steam/community/l4d/l4d_map.rb +8 -7
  29. data/lib/steam/community/l4d/l4d_stats.rb +7 -7
  30. data/lib/steam/community/l4d/l4d_weapon.rb +5 -4
  31. data/lib/steam/community/portal2/portal2_stats.rb +3 -3
  32. data/lib/steam/community/steam_game.rb +106 -16
  33. data/lib/steam/community/steam_group.rb +51 -40
  34. data/lib/steam/community/steam_id.rb +119 -87
  35. data/lib/steam/community/tf2/tf2_class.rb +14 -14
  36. data/lib/steam/community/tf2/tf2_class_factory.rb +2 -2
  37. data/lib/steam/community/tf2/tf2_engineer.rb +5 -7
  38. data/lib/steam/community/tf2/tf2_golden_wrench.rb +1 -1
  39. data/lib/steam/community/tf2/tf2_medic.rb +4 -6
  40. data/lib/steam/community/tf2/tf2_sniper.rb +3 -5
  41. data/lib/steam/community/tf2/tf2_spy.rb +10 -6
  42. data/lib/steam/community/tf2/tf2_stats.rb +15 -7
  43. data/lib/steam/community/web_api.rb +15 -1
  44. data/lib/steam/community/xml_data.rb +17 -0
  45. data/lib/steam/servers/game_server.rb +4 -4
  46. data/lib/steam/servers/master_server.rb +2 -2
  47. data/lib/steam/servers/source_server.rb +0 -2
  48. data/lib/steam/sockets/goldsrc_socket.rb +2 -2
  49. data/lib/steam/steam_player.rb +2 -2
  50. data/steam-condenser.gemspec +3 -2
  51. data/test/helper.rb +10 -2
  52. data/test/steam/communtiy/test_steam_group.rb +4 -4
  53. data/test/steam/communtiy/test_steam_id.rb +28 -2
  54. data/test/steam/communtiy/test_web_api.rb +2 -2
  55. data/test/steam/packets/test_steam_packet.rb +37 -0
  56. data/test/steam/servers/test_game_server.rb +296 -308
  57. data/test/steam/servers/test_goldsrc_server.rb +59 -59
  58. data/test/steam/servers/test_master_server.rb +131 -131
  59. data/test/steam/servers/test_server.rb +72 -72
  60. data/test/steam/servers/test_source_server.rb +126 -140
  61. data/test/steam/sockets/test_master_server_socket.rb +1 -0
  62. metadata +39 -19
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ steam-condenser (1.2.0)
5
+ bzip2-ruby (~> 0.2.7)
6
+ multi_json (~> 1.3.1)
7
+ multi_xml (~> 0.4.1)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ bzip2-ruby (0.2.7)
13
+ metaclass (0.0.1)
14
+ mocha (0.11.1)
15
+ metaclass (~> 0.0.1)
16
+ multi_json (1.3.2)
17
+ multi_xml (0.4.4)
18
+ rake (0.9.2.2)
19
+ shoulda-context (1.0.0)
20
+ yard (0.7.5)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ mocha (~> 0.11.1)
27
+ rake (~> 0.9.2)
28
+ shoulda-context (~> 1.0.0)
29
+ steam-condenser!
30
+ yard (~> 0.7.2)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2011, Sebastian Staudt
1
+ Copyright (c) 2008-2012, Sebastian Staudt
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
data/README.md CHANGED
@@ -29,9 +29,10 @@ included LICENSE file.
29
29
 
30
30
  ## Credits
31
31
 
32
- * Sebastian Staudt -- koraktor(at)gmail.com
33
- * DeFirence -- defirence(at)defirence.za.net
34
- * Mike Połtyn -- mike(at)railslove.com
32
+ * Sebastian Staudt koraktor(at)gmail.com
33
+ * DeFirence defirence(at)defirence.za.net
34
+ * Mike Połtyn mike(at)railslove.com
35
+ * Sam Kinard – snkinard(at)gmail.com
35
36
 
36
37
  ## See Also
37
38
 
@@ -1,11 +1,11 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under
2
2
  # the terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2010-2011, Sebastian Staudt
4
+ # Copyright (c) 2010-2012, Sebastian Staudt
5
5
 
6
6
  module SteamCondenser
7
7
 
8
8
  # The current version of Steam Condenser
9
- VERSION = '1.1.0'
9
+ VERSION = '1.2.0'
10
10
 
11
11
  end
@@ -88,30 +88,32 @@ class AlienSwarmMission
88
88
 
89
89
  # Creates a new mission instance of based on the given XML data
90
90
  #
91
- # @param [REXML::Element] mission_data The data representing this mission
92
- def initialize(mission_data)
93
- @avg_damage_taken = mission_data.elements['damagetakenavg'].text.to_f
94
- @avg_friendly_fire = mission_data.elements['friendlyfireavg'].text.to_f
95
- @avg_kills = mission_data.elements['killsavg'].text.to_f
96
- @best_difficulty = mission_data.elements['bestdifficulty'].text
97
- @damage_taken = mission_data.elements['damagetaken'].text.to_i
98
- @friendly_fire = mission_data.elements['friendlyfire'].text.to_i
99
- @games_successful = mission_data.elements['gamessuccess'].text.to_i
100
- @img = AlienSwarmStats::BASE_URL + mission_data.elements['image'].text
101
- @kills = mission_data.elements['kills'].text.to_i
102
- @map_name = mission_data.name
103
- @name = mission_data.elements['name'].text
104
- @total_games = mission_data.elements['gamestotal'].text.to_i
105
- @total_games_percentage = mission_data.elements['gamestotalpct'].text.to_f
91
+ # @param [String] map_name The name of the mission's map
92
+ # @param [Hash<String, Object>] mission_data The data representing this
93
+ # mission
94
+ def initialize(map_name, mission_data)
95
+ @avg_damage_taken = mission_data['damagetakenavg'].to_f
96
+ @avg_friendly_fire = mission_data['friendlyfireavg'].to_f
97
+ @avg_kills = mission_data['killsavg'].to_f
98
+ @best_difficulty = mission_data['bestdifficulty']
99
+ @damage_taken = mission_data['damagetaken'].to_i
100
+ @friendly_fire = mission_data['friendlyfire'].to_i
101
+ @games_successful = mission_data['gamessuccess'].to_i
102
+ @img = AlienSwarmStats::BASE_URL + mission_data['image']
103
+ @kills = mission_data['kills'].to_i
104
+ @map_name = map_name
105
+ @name = mission_data['name']
106
+ @total_games = mission_data['gamestotal'].to_i
107
+ @total_games_percentage = mission_data['gamestotalpct'].to_f
106
108
 
107
109
  @time = {}
108
- @time[:average] = mission_data.elements['avgtime'].text
109
- @time[:brutal] = mission_data.elements['brutaltime'].text
110
- @time[:easy] = mission_data.elements['easytime'].text
111
- @time[:hard] = mission_data.elements['hardtime'].text
112
- @time[:insane] = mission_data.elements['insanetime'].text
113
- @time[:normal] = mission_data.elements['normaltime'].text
114
- @time[:total] = mission_data.elements['totaltime'].text
110
+ @time[:average] = mission_data['avgtime']
111
+ @time[:brutal] = mission_data['brutaltime']
112
+ @time[:easy] = mission_data['easytime']
113
+ @time[:hard] = mission_data['hardtime']
114
+ @time[:insane] = mission_data['insanetime']
115
+ @time[:normal] = mission_data['normaltime']
116
+ @time[:total] = mission_data['totaltime']
115
117
  end
116
118
 
117
119
  end
@@ -17,7 +17,7 @@ class AlienSwarmStats < GameStats
17
17
  attr_reader :lifetime_stats
18
18
 
19
19
  # The base URL for all images referenced in the stats
20
- BASE_URL = 'http://steamcommunity.com/public/images/gamestats/swarm/'
20
+ BASE_URL = 'http://cdn.steamcommunity.com/public/images/gamestats/swarm/'
21
21
 
22
22
  # The names of all weapons in Alien Swarm
23
23
  WEAPONS = [ 'Autogun', 'Cannon_Sentry', 'Chainsaw', 'Flamer',
@@ -36,28 +36,28 @@ class AlienSwarmStats < GameStats
36
36
  super steam_id, 'alienswarm'
37
37
 
38
38
  if public?
39
- @hours_played = @xml_data.elements['stats/lifetime/timeplayed'].text
39
+ @hours_played = @xml_data['stats']['lifetime']['timeplayed']
40
40
 
41
41
  @lifetime_stats = {}
42
- @lifetime_stats[:accuracy] = @xml_data.elements['stats/lifetime/accuracy'].text.to_f
43
- @lifetime_stats[:aliens_burned] = @xml_data.elements['stats/lifetime/aliensburned'].text.to_i
44
- @lifetime_stats[:aliens_killed] = @xml_data.elements['stats/lifetime/alienskilled'].text.to_i
45
- @lifetime_stats[:campaigns] = @xml_data.elements['stats/lifetime/campaigns'].text.to_i
46
- @lifetime_stats[:damage_taken] = @xml_data.elements['stats/lifetime/damagetaken'].text.to_i
47
- @lifetime_stats[:experience] = @xml_data.elements['stats/lifetime/experience'].text.to_i
48
- @lifetime_stats[:experience_required] = @xml_data.elements['stats/lifetime/xprequired'].text.to_i
49
- @lifetime_stats[:fast_hacks] = @xml_data.elements['stats/lifetime/fasthacks'].text.to_i
50
- @lifetime_stats[:friendly_fire] = @xml_data.elements['stats/lifetime/friendlyfire'].text.to_i
51
- @lifetime_stats[:games_successful] = @xml_data.elements['stats/lifetime/gamessuccess'].text.to_i
52
- @lifetime_stats[:healing] = @xml_data.elements['stats/lifetime/healing'].text.to_i
53
- @lifetime_stats[:kills_per_hour] = @xml_data.elements['stats/lifetime/killsperhour'].text.to_f
54
- @lifetime_stats[:level] = @xml_data.elements['stats/lifetime/level'].text.to_i
55
- @lifetime_stats[:promotion] = @xml_data.elements['stats/lifetime/promotion'].text.to_i
56
- @lifetime_stats[:promotion_img] = BASE_URL + @xml_data.elements['stats/lifetime/promotionpic'].text if @lifetime_stats[:promotion] > 0
57
- @lifetime_stats[:next_unlock] = @xml_data.elements['stats/lifetime/nextunlock'].text
58
- @lifetime_stats[:next_unlock_img] = BASE_URL + @xml_data.elements['stats/lifetime/nextunlockimg'].text
59
- @lifetime_stats[:shots_fired] = @xml_data.elements['stats/lifetime/shotsfired'].text.to_i
60
- @lifetime_stats[:total_games] = @xml_data.elements['stats/lifetime/totalgames'].text.to_i
42
+ @lifetime_stats[:accuracy] = @xml_data['stats']['lifetime']['accuracy'].to_f
43
+ @lifetime_stats[:aliens_burned] = @xml_data['stats']['lifetime']['aliensburned'].to_i
44
+ @lifetime_stats[:aliens_killed] = @xml_data['stats']['lifetime']['alienskilled'].to_i
45
+ @lifetime_stats[:campaigns] = @xml_data['stats']['lifetime']['campaigns'].to_i
46
+ @lifetime_stats[:damage_taken] = @xml_data['stats']['lifetime']['damagetaken'].to_i
47
+ @lifetime_stats[:experience] = @xml_data['stats']['lifetime']['experience'].to_i
48
+ @lifetime_stats[:experience_required] = @xml_data['stats']['lifetime']['xprequired'].to_i
49
+ @lifetime_stats[:fast_hacks] = @xml_data['stats']['lifetime']['fasthacks'].to_i
50
+ @lifetime_stats[:friendly_fire] = @xml_data['stats']['lifetime']['friendlyfire'].to_i
51
+ @lifetime_stats[:games_successful] = @xml_data['stats']['lifetime']['gamessuccess'].to_i
52
+ @lifetime_stats[:healing] = @xml_data['stats']['lifetime']['healing'].to_i
53
+ @lifetime_stats[:kills_per_hour] = @xml_data['stats']['lifetime']['killsperhour'].to_f
54
+ @lifetime_stats[:level] = @xml_data['stats']['lifetime']['level'].to_i
55
+ @lifetime_stats[:promotion] = @xml_data['stats']['lifetime']['promotion'].to_i
56
+ @lifetime_stats[:promotion_img] = BASE_URL + @xml_data['stats']['lifetime']['promotionpic'] if @lifetime_stats[:promotion] > 0
57
+ @lifetime_stats[:next_unlock] = @xml_data['stats']['lifetime']['nextunlock']
58
+ @lifetime_stats[:next_unlock_img] = BASE_URL + @xml_data['stats']['lifetime']['nextunlockimg']
59
+ @lifetime_stats[:shots_fired] = @xml_data['stats']['lifetime']['shotsfired'].to_i
60
+ @lifetime_stats[:total_games] = @xml_data['stats']['lifetime']['totalgames'].to_i
61
61
 
62
62
  @lifetime_stats[:games_successful_percentage] = (@lifetime_stats[:total_games] > 0) ? @lifetime_stats[:games_successful].to_f / @lifetime_stats[:total_games] : 0;
63
63
  end
@@ -73,26 +73,26 @@ class AlienSwarmStats < GameStats
73
73
 
74
74
  if @favorites.nil?
75
75
  @favorites = {}
76
- @favorites[:class] = @xml_data.elements['stats/favorites/class'].text
77
- @favorites[:class_img] = @xml_data.elements['stats/favorites/classimg'].text
78
- @favorites[:class_percentage] = @xml_data.elements['stats/favorites/classpct'].text.to_f
79
- @favorites[:difficulty] = @xml_data.elements['stats/favorites/difficulty'].text
80
- @favorites[:difficulty_percentage] = @xml_data.elements['stats/favorites/difficultypct'].text.to_f
81
- @favorites[:extra] = @xml_data.elements['stats/favorites/extra'].text
82
- @favorites[:extra_img] = @xml_data.elements['stats/favorites/extraimg'].text
83
- @favorites[:extra_percentage] = @xml_data.elements['stats/favorites/extrapct'].text.to_f
84
- @favorites[:marine] = @xml_data.elements['stats/favorites/marine'].text
85
- @favorites[:marine_img] = @xml_data.elements['stats/favorites/marineimg'].text
86
- @favorites[:marine_percentage] = @xml_data.elements['stats/favorites/marinepct'].text.to_f
87
- @favorites[:mission] = @xml_data.elements['stats/favorites/mission'].text
88
- @favorites[:mission_img] = @xml_data.elements['stats/favorites/missionimg'].text
89
- @favorites[:mission_percentage] = @xml_data.elements['stats/favorites/missionpct'].text.to_f
90
- @favorites[:primary_weapon] = @xml_data.elements['stats/favorites/primary'].text
91
- @favorites[:primary_weapon_img] = @xml_data.elements['stats/favorites/primaryimg'].text
92
- @favorites[:primary_weapon_percentage] = @xml_data.elements['stats/favorites/primarypct'].text.to_f
93
- @favorites[:secondary_weapon] = @xml_data.elements['stats/favorites/secondary'].text
94
- @favorites[:secondary_weapon_img] = @xml_data.elements['stats/favorites/secondaryimg'].text
95
- @favorites[:secondary_weapon_percentage] = @xml_data.elements['stats/favorites/secondarypct'].text.to_f
76
+ @favorites[:class] = @xml_data['stats']['favorites']['class']
77
+ @favorites[:class_img] = @xml_data['stats']['favorites']['classimg']
78
+ @favorites[:class_percentage] = @xml_data['stats']['favorites']['classpct'].to_f
79
+ @favorites[:difficulty] = @xml_data['stats']['favorites']['difficulty']
80
+ @favorites[:difficulty_percentage] = @xml_data['stats']['favorites']['difficultypct'].to_f
81
+ @favorites[:extra] = @xml_data['stats']['favorites']['extra']
82
+ @favorites[:extra_img] = @xml_data['stats']['favorites']['extraimg']
83
+ @favorites[:extra_percentage] = @xml_data['stats']['favorites']['extrapct'].to_f
84
+ @favorites[:marine] = @xml_data['stats']['favorites']['marine']
85
+ @favorites[:marine_img] = @xml_data['stats']['favorites']['marineimg']
86
+ @favorites[:marine_percentage] = @xml_data['stats']['favorites']['marinepct'].to_f
87
+ @favorites[:mission] = @xml_data['stats']['favorites']['mission']
88
+ @favorites[:mission_img] = @xml_data['stats']['favorites']['missionimg']
89
+ @favorites[:mission_percentage] = @xml_data['stats']['favorites']['missionpct'].to_f
90
+ @favorites[:primary_weapon] = @xml_data['stats']['favorites']['primary']
91
+ @favorites[:primary_weapon_img] = @xml_data['stats']['favorites']['primaryimg']
92
+ @favorites[:primary_weapon_percentage] = @xml_data['stats']['favorites']['primarypct'].to_f
93
+ @favorites[:secondary_weapon] = @xml_data['stats']['favorites']['secondary']
94
+ @favorites[:secondary_weapon_img] = @xml_data['stats']['favorites']['secondaryimg']
95
+ @favorites[:secondary_weapon_percentage] = @xml_data['stats']['favorites']['secondarypct'].to_f
96
96
  end
97
97
 
98
98
  @favorites
@@ -109,27 +109,27 @@ class AlienSwarmStats < GameStats
109
109
 
110
110
  if @item_stats.nil?
111
111
  @item_stats = {}
112
- @item_stats[:ammo_deployed] = @xml_data.elements['stats/weapons/ammo_deployed'].text.to_i
113
- @item_stats[:sentryguns_deployed] = @xml_data.elements['stats/weapons/sentryguns_deployed'].text.to_i
114
- @item_stats[:sentry_flamers_deployed] = @xml_data.elements['stats/weapons/sentry_flamers_deployed'].text.to_i
115
- @item_stats[:sentry_freeze_deployed] = @xml_data.elements['stats/weapons/sentry_freeze_deployed'].text.to_i
116
- @item_stats[:sentry_cannon_deployed] = @xml_data.elements['stats/weapons/sentry_cannon_deployed'].text.to_i
117
- @item_stats[:medkits_used] = @xml_data.elements['stats/weapons/medkits_used'].text.to_i
118
- @item_stats[:flares_used] = @xml_data.elements['stats/weapons/flares_used'].text.to_i
119
- @item_stats[:adrenaline_used] = @xml_data.elements['stats/weapons/adrenaline_used'].text.to_i
120
- @item_stats[:tesla_traps_deployed] = @xml_data.elements['stats/weapons/tesla_traps_deployed'].text.to_i
121
- @item_stats[:freeze_grenades_thrown] = @xml_data.elements['stats/weapons/freeze_grenades_thrown'].text.to_i
122
- @item_stats[:electric_armor_used] = @xml_data.elements['stats/weapons/electric_armor_used'].text.to_i
123
- @item_stats[:healgun_heals] = @xml_data.elements['stats/weapons/healgun_heals'].text.to_i
124
- @item_stats[:healgun_heals_self] = @xml_data.elements['stats/weapons/healgun_heals_self'].text.to_i
125
- @item_stats[:healbeacon_heals] = @xml_data.elements['stats/weapons/healbeacon_heals'].text.to_i
126
- @item_stats[:healbeacon_heals_self] = @xml_data.elements['stats/weapons/healbeacon_heals_self'].text.to_i
127
- @item_stats[:damage_amps_used] = @xml_data.elements['stats/weapons/damage_amps_used'].text.to_i
128
- @item_stats[:healbeacons_deployed] = @xml_data.elements['stats/weapons/healbeacons_deployed'].text.to_i
129
- @item_stats[:healbeacon_heals_pct] = @xml_data.elements['stats/weapons/healbeacon_heals_pct'].text.to_f
130
- @item_stats[:healgun_heals_pct] = @xml_data.elements['stats/weapons/healgun_heals_pct'].text.to_f
131
- @item_stats[:healbeacon_heals_pct_self] = @xml_data.elements['stats/weapons/healbeacon_heals_pct_self'].text.to_f
132
- @item_stats[:healgun_heals_pct_self] = @xml_data.elements['stats/weapons/healgun_heals_pct_self'].text.to_f
112
+ @item_stats[:ammo_deployed] = @xml_data['stats']['weapons']['ammo_deployed'].to_i
113
+ @item_stats[:sentryguns_deployed] = @xml_data['stats']['weapons']['sentryguns_deployed'].to_i
114
+ @item_stats[:sentry_flamers_deployed] = @xml_data['stats']['weapons']['sentry_flamers_deployed'].to_i
115
+ @item_stats[:sentry_freeze_deployed] = @xml_data['stats']['weapons']['sentry_freeze_deployed'].to_i
116
+ @item_stats[:sentry_cannon_deployed] = @xml_data['stats']['weapons']['sentry_cannon_deployed'].to_i
117
+ @item_stats[:medkits_used] = @xml_data['stats']['weapons']['medkits_used'].to_i
118
+ @item_stats[:flares_used] = @xml_data['stats']['weapons']['flares_used'].to_i
119
+ @item_stats[:adrenaline_used] = @xml_data['stats']['weapons']['adrenaline_used'].to_i
120
+ @item_stats[:tesla_traps_deployed] = @xml_data['stats']['weapons']['tesla_traps_deployed'].to_i
121
+ @item_stats[:freeze_grenades_thrown] = @xml_data['stats']['weapons']['freeze_grenades_thrown'].to_i
122
+ @item_stats[:electric_armor_used] = @xml_data['stats']['weapons']['electric_armor_used'].to_i
123
+ @item_stats[:healgun_heals] = @xml_data['stats']['weapons']['healgun_heals'].to_i
124
+ @item_stats[:healgun_heals_self] = @xml_data['stats']['weapons']['healgun_heals_self'].to_i
125
+ @item_stats[:healbeacon_heals] = @xml_data['stats']['weapons']['healbeacon_heals'].to_i
126
+ @item_stats[:healbeacon_heals_self] = @xml_data['stats']['weapons']['healbeacon_heals_self'].to_i
127
+ @item_stats[:damage_amps_used] = @xml_data['stats']['weapons']['damage_amps_used'].to_i
128
+ @item_stats[:healbeacons_deployed] = @xml_data['stats']['weapons']['healbeacons_deployed'].to_i
129
+ @item_stats[:healbeacon_heals_pct] = @xml_data['stats']['weapons']['healbeacon_heals_pct'].to_f
130
+ @item_stats[:healgun_heals_pct] = @xml_data['stats']['weapons']['healgun_heals_pct'].to_f
131
+ @item_stats[:healbeacon_heals_pct_self] = @xml_data['stats']['weapons']['healbeacon_heals_pct_self'].to_f
132
+ @item_stats[:healgun_heals_pct_self] = @xml_data['stats']['weapons']['healgun_heals_pct_self'].to_f
133
133
  end
134
134
 
135
135
  @item_stats
@@ -146,8 +146,9 @@ class AlienSwarmStats < GameStats
146
146
 
147
147
  if @mission_stats.nil?
148
148
  @mission_stats = {}
149
- @xml_data.elements.each('stats/missions/*') do |mission_data|
150
- @mission_stats[mission_data.name] = AlienSwarmMission.new(mission_data)
149
+ @xml_data['stats']['missions'].each do |mission_data|
150
+ mission = AlienSwarmMission.new *mission_data
151
+ @mission_stats[mission.name] = mission
151
152
  end
152
153
  end
153
154
 
@@ -166,7 +167,7 @@ class AlienSwarmStats < GameStats
166
167
  if @weapon_stats.nil?
167
168
  @weapon_stats = {}
168
169
  WEAPONS.each do |weapon_node|
169
- weapon_data = @xml_data.elements["stats/weapons/#{weapon_node}"]
170
+ weapon_data = @xml_data['stats']['weapons'][weapon_node]
170
171
  weapon = AlienSwarmWeapon.new(weapon_data)
171
172
  @weapon_stats[weapon.name] = weapon
172
173
  end
@@ -35,15 +35,15 @@ class AlienSwarmWeapon
35
35
 
36
36
  # Creates a new weapon instance based on the assigned weapon XML data
37
37
  #
38
- # @param [REXML::Element] weapon_data The data representing this weapon
38
+ # @param [Hash<String, Object>] weapon_data The data representing this weapon
39
39
  def initialize(weapon_data)
40
40
  super
41
41
 
42
- @accuracy = weapon_data.elements['accuracy'].text.to_f
43
- @damage = weapon_data.elements['damage'].text.to_i
44
- @friendly_fire = weapon_data.elements['friendlyfire'].text.to_i
45
- @name = weapon_data.elements['name'].text
46
- @shots = weapon_data.elements['shotsfired'].text.to_i
42
+ @accuracy = weapon_data['accuracy'].to_f
43
+ @damage = weapon_data['damage'].to_i
44
+ @friendly_fire = weapon_data['friendlyfire'].to_i
45
+ @name = weapon_data['name']
46
+ @shots = weapon_data['shotsfired'].to_i
47
47
  end
48
48
 
49
49
  end
@@ -83,7 +83,7 @@ class AppNews
83
83
  data = WebApi.json('ISteamNews', 'GetNewsForApp', 2, params)
84
84
 
85
85
  news_items = []
86
- MultiJson.decode(data, { :symbolize_keys => true })[:appnews][:newsitems].each do |news_data|
86
+ MultiJson.load(data, { :symbolize_keys => true })[:appnews][:newsitems].each do |news_data|
87
87
  news_items << AppNews.new(app_id, news_data)
88
88
  end
89
89
 
@@ -105,7 +105,7 @@ class AppNews
105
105
  #
106
106
  # @return [String] A simple text representing this news
107
107
  def to_s
108
- "#{@feed_label}: #{@title}"
108
+ "#@feed_label: #@title"
109
109
  end
110
110
 
111
111
  private
@@ -32,13 +32,13 @@ class CSSMap
32
32
  # given XML data
33
33
  #
34
34
  # @param [String] map_name The name of the map
35
- # @param [REXML::Element] maps_data The XML data of all maps
35
+ # @param [Hash<String, Object>] maps_data The XML data of all maps
36
36
  def initialize(map_name, maps_data)
37
37
  @name = map_name
38
38
 
39
- @favorite = (maps_data.elements['favorite'].text == @name)
40
- @rounds_played = maps_data.elements["#{@name}_rounds"].text.to_i
41
- @rounds_won = maps_data.elements["#{@name}_wins"].text.to_i
39
+ @favorite = (maps_data['favorite'] == @name)
40
+ @rounds_played = maps_data["#{@name}_rounds"].to_i
41
+ @rounds_won = maps_data["#{@name}_wins"].to_i
42
42
 
43
43
  @rounds_lost = @rounds_played - @rounds_won
44
44
  @rounds_won_percentage = (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0
@@ -34,8 +34,8 @@ class CSSStats < GameStats
34
34
  # @return [Hash<Symbol, Object>] The overall statistics
35
35
  attr_reader :total_stats
36
36
 
37
- # Creates a <var>CSSStats</var> instance by calling the super constructor
38
- # with the game name <var>"cs:s"</var>
37
+ # Creates a `CSSStats` instance by calling the super constructor
38
+ # with the game name `'cs:s'`
39
39
  #
40
40
  # @param [String, Fixnum] steam_id The custom URL or 64bit Steam ID of the
41
41
  # user
@@ -46,45 +46,45 @@ class CSSStats < GameStats
46
46
  @last_match_stats = {}
47
47
  @total_stats = {}
48
48
 
49
- @last_match_stats[:cost_per_kill] = @xml_data.elements['stats/lastmatch/costkill'].text.to_f
50
- @last_match_stats[:ct_wins] = @xml_data.elements['stats/lastmatch/ct_wins'].text.to_i
51
- @last_match_stats[:damage] = @xml_data.elements['stats/lastmatch/dmg'].text.to_i
52
- @last_match_stats[:deaths] = @xml_data.elements['stats/lastmatch/deaths'].text.to_i
53
- @last_match_stats[:dominations] = @xml_data.elements['stats/lastmatch/dominations'].text.to_i
54
- @last_match_stats[:favorite_weapon_id] = @xml_data.elements['stats/lastmatch/favwpnid'].text.to_i
55
- @last_match_stats[:kills] = @xml_data.elements['stats/lastmatch/kills'].text.to_i
56
- @last_match_stats[:max_players] = @xml_data.elements['stats/lastmatch/max_players'].text.to_i
57
- @last_match_stats[:money] = @xml_data.elements['stats/lastmatch/money'].text.to_i
58
- @last_match_stats[:revenges] = @xml_data.elements['stats/lastmatch/revenges'].text.to_i
59
- @last_match_stats[:stars] = @xml_data.elements['stats/lastmatch/stars'].text.to_i
60
- @last_match_stats[:t_wins] = @xml_data.elements['stats/lastmatch/t_wins'].text.to_i
61
- @last_match_stats[:wins] = @xml_data.elements['stats/lastmatch/wins'].text.to_i
62
- @total_stats[:blind_kills] = @xml_data.elements['stats/lifetime/blindkills'].text.to_i
63
- @total_stats[:bombs_defused] = @xml_data.elements['stats/lifetime/bombsdefused'].text.to_i
64
- @total_stats[:bombs_planted] = @xml_data.elements['stats/lifetime/bombsplanted'].text.to_i
65
- @total_stats[:damage] = @xml_data.elements['stats/lifetime/dmg'].text.to_i
66
- @total_stats[:deaths] = @xml_data.elements['stats/summary/deaths'].text.to_i
67
- @total_stats[:domination_overkills] = @xml_data.elements['stats/lifetime/dominationoverkills'].text.to_i
68
- @total_stats[:dominations] = @xml_data.elements['stats/lifetime/dominations'].text.to_i
69
- @total_stats[:earned_money] = @xml_data.elements['stats/lifetime/money'].text.to_i
70
- @total_stats[:enemy_weapon_kills] = @xml_data.elements['stats/lifetime/enemywpnkills'].text.to_i
71
- @total_stats[:headshots] = @xml_data.elements['stats/lifetime/headshots'].text.to_i
72
- @total_stats[:hits] = @xml_data.elements['stats/summary/shotshit'].text.to_i
73
- @total_stats[:hostages_rescued] = @xml_data.elements['stats/lifetime/hostagesrescued'].text.to_i
74
- @total_stats[:kills] = @xml_data.elements['stats/summary/kills'].text.to_i
75
- @total_stats[:knife_kills] = @xml_data.elements['stats/lifetime/knifekills'].text.to_i
76
- @total_stats[:logos_sprayed] = @xml_data.elements['stats/lifetime/decals'].text.to_i
77
- @total_stats[:nightvision_damage] = @xml_data.elements['stats/lifetime/nvgdmg'].text.to_i
78
- @total_stats[:pistol_rounds_won] = @xml_data.elements['stats/lifetime/pistolrounds'].text.to_i
79
- @total_stats[:revenges] = @xml_data.elements['stats/lifetime/revenges'].text.to_i
80
- @total_stats[:rounds_played] = @xml_data.elements['stats/summary/rounds'].text.to_i
81
- @total_stats[:rounds_won] = @xml_data.elements['stats/summary/wins'].text.to_i
82
- @total_stats[:seconds_played] = @xml_data.elements['stats/summary/timeplayed'].text.to_i
83
- @total_stats[:shots] = @xml_data.elements['stats/summary/shots'].text.to_i
84
- @total_stats[:stars] = @xml_data.elements['stats/summary/stars'].text.to_i
85
- @total_stats[:weapons_donated] = @xml_data.elements['stats/lifetime/wpndonated'].text.to_i
86
- @total_stats[:windows_broken] = @xml_data.elements['stats/lifetime/winbroken'].text.to_i
87
- @total_stats[:zoomed_sniper_kills] = @xml_data.elements['stats/lifetime/zsniperkills'].text.to_i
49
+ @last_match_stats[:cost_per_kill] = @xml_data['stats']['lastmatch']['costkill'].to_f
50
+ @last_match_stats[:ct_wins] = @xml_data['stats']['lastmatch']['ct_wins'].to_i
51
+ @last_match_stats[:damage] = @xml_data['stats']['lastmatch']['dmg'].to_i
52
+ @last_match_stats[:deaths] = @xml_data['stats']['lastmatch']['deaths'].to_i
53
+ @last_match_stats[:dominations] = @xml_data['stats']['lastmatch']['dominations'].to_i
54
+ @last_match_stats[:favorite_weapon_id] = @xml_data['stats']['lastmatch']['favwpnid'].to_i
55
+ @last_match_stats[:kills] = @xml_data['stats']['lastmatch']['kills'].to_i
56
+ @last_match_stats[:max_players] = @xml_data['stats']['lastmatch']['max_players'].to_i
57
+ @last_match_stats[:money] = @xml_data['stats']['lastmatch']['money'].to_i
58
+ @last_match_stats[:revenges] = @xml_data['stats']['lastmatch']['revenges'].to_i
59
+ @last_match_stats[:stars] = @xml_data['stats']['lastmatch']['stars'].to_i
60
+ @last_match_stats[:t_wins] = @xml_data['stats']['lastmatch']['t_wins'].to_i
61
+ @last_match_stats[:wins] = @xml_data['stats']['lastmatch']['wins'].to_i
62
+ @total_stats[:blind_kills] = @xml_data['stats']['lifetime']['blindkills'].to_i
63
+ @total_stats[:bombs_defused] = @xml_data['stats']['lifetime']['bombsdefused'].to_i
64
+ @total_stats[:bombs_planted] = @xml_data['stats']['lifetime']['bombsplanted'].to_i
65
+ @total_stats[:damage] = @xml_data['stats']['lifetime']['dmg'].to_i
66
+ @total_stats[:deaths] = @xml_data['stats']['summary']['deaths'].to_i
67
+ @total_stats[:domination_overkills] = @xml_data['stats']['lifetime']['dominationoverkills'].to_i
68
+ @total_stats[:dominations] = @xml_data['stats']['lifetime']['dominations'].to_i
69
+ @total_stats[:earned_money] = @xml_data['stats']['lifetime']['money'].to_i
70
+ @total_stats[:enemy_weapon_kills] = @xml_data['stats']['lifetime']['enemywpnkills'].to_i
71
+ @total_stats[:headshots] = @xml_data['stats']['lifetime']['headshots'].to_i
72
+ @total_stats[:hits] = @xml_data['stats']['summary']['shotshit'].to_i
73
+ @total_stats[:hostages_rescued] = @xml_data['stats']['lifetime']['hostagesrescued'].to_i
74
+ @total_stats[:kills] = @xml_data['stats']['summary']['kills'].to_i
75
+ @total_stats[:knife_kills] = @xml_data['stats']['lifetime']['knifekills'].to_i
76
+ @total_stats[:logos_sprayed] = @xml_data['stats']['lifetime']['decals'].to_i
77
+ @total_stats[:nightvision_damage] = @xml_data['stats']['lifetime']['nvgdmg'].to_i
78
+ @total_stats[:pistol_rounds_won] = @xml_data['stats']['lifetime']['pistolrounds'].to_i
79
+ @total_stats[:revenges] = @xml_data['stats']['lifetime']['revenges'].to_i
80
+ @total_stats[:rounds_played] = @xml_data['stats']['summary']['rounds'].to_i
81
+ @total_stats[:rounds_won] = @xml_data['stats']['summary']['wins'].to_i
82
+ @total_stats[:seconds_played] = @xml_data['stats']['summary']['timeplayed'].to_i
83
+ @total_stats[:shots] = @xml_data['stats']['summary']['shots'].to_i
84
+ @total_stats[:stars] = @xml_data['stats']['summary']['stars'].to_i
85
+ @total_stats[:weapons_donated] = @xml_data['stats']['lifetime']['wpndonated'].to_i
86
+ @total_stats[:windows_broken] = @xml_data['stats']['lifetime']['winbroken'].to_i
87
+ @total_stats[:zoomed_sniper_kills] = @xml_data['stats']['lifetime']['zsniperkills'].to_i
88
88
 
89
89
  @last_match_stats[:kdratio] = (@total_stats[:deaths] > 0) ? @last_match_stats[:kills].to_f / @last_match_stats[:deaths] : 0
90
90
  @total_stats[:accuracy] = (@total_stats[:shots] > 0) ? @total_stats[:hits].to_f / @total_stats[:shots] : 0
@@ -103,7 +103,7 @@ class CSSStats < GameStats
103
103
 
104
104
  if @map_stats.nil?
105
105
  @map_stats = {}
106
- maps_data = @xml_data.elements['stats/maps']
106
+ maps_data = @xml_data['stats']['maps']
107
107
 
108
108
  MAPS.each do |map_name|
109
109
  @map_stats[map_name] = CSSMap.new(map_name, maps_data)
@@ -123,7 +123,7 @@ class CSSStats < GameStats
123
123
 
124
124
  if @weapon_stats.nil?
125
125
  @weapon_stats = {}
126
- weapons_data = @xml_data.elements['stats/weapons']
126
+ weapons_data = @xml_data['stats']['weapons']
127
127
 
128
128
  WEAPONS.each do |weapon_name|
129
129
  @weapon_stats[weapon_name] = CSSWeapon.new(weapon_name, weapons_data)