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
@@ -1,140 +1,126 @@
1
- # This code is free software; you can redistribute it and/or modify it under
2
- # the terms of the new BSD License.
3
- #
4
- # Copyright (c) 2011, Sebastian Staudt
5
-
6
- require 'helper'
7
- require 'steam/servers/source_server'
8
-
9
- class TestSourceServer < Test::Unit::TestCase
10
-
11
- context 'The user' do
12
-
13
- should 'be able to get a master server for Source servers' do
14
- master = mock
15
- MasterServer.expects(:new).with(*MasterServer::SOURCE_MASTER_SERVER).
16
- returns master
17
-
18
- assert_equal master, SourceServer.master
19
- end
20
-
21
- end
22
-
23
- context 'A Source server' do
24
-
25
- setup do
26
- Socket.stubs(:getaddrinfo).
27
- with('source', 27015, Socket::AF_INET, Socket::SOCK_DGRAM).
28
- returns [[nil, nil, 'source', '127.0.0.1']]
29
-
30
- @server = SourceServer.new 'source', 27015
31
- end
32
-
33
- should 'create client sockets upon initialization' do
34
- socket = mock
35
- SourceSocket.expects(:new).with('127.0.0.1', 27015).returns socket
36
- rcon_socket = mock
37
- RCONSocket.expects(:new).with('127.0.0.1', 27015).returns rcon_socket
38
-
39
- @server.init_socket
40
-
41
- assert_same socket, @server.instance_variable_get(:@socket)
42
- assert_same rcon_socket, @server.instance_variable_get(:@rcon_socket)
43
- end
44
-
45
- should 'be able to authenticate successfully' do
46
- reply = mock
47
-
48
- rcon_socket = mock
49
- rcon_socket.expects(:send).with do |packet|
50
- reply.expects(:request_id).twice.returns packet.request_id
51
-
52
- packet.is_a? RCONAuthRequest
53
- end
54
- rcon_socket.expects(:reply).twice.returns(nil).returns(reply)
55
- @server.instance_variable_set :@rcon_socket, rcon_socket
56
-
57
- assert @server.rcon_auth 'password'
58
- assert @server.instance_variable_get(:@rcon_authenticated)
59
- end
60
-
61
- should 'fail to authenticate if the wrong request ID is returned' do
62
- reply = mock
63
- reply.expects(:request_id).twice.returns -2
64
-
65
- rcon_socket = mock
66
- rcon_socket.expects(:send).with { |packet| packet.is_a? RCONAuthRequest }
67
- rcon_socket.expects(:reply).twice.returns(nil).returns(reply)
68
- @server.instance_variable_set :@rcon_socket, rcon_socket
69
-
70
- assert_not @server.rcon_auth 'password'
71
- assert_not @server.instance_variable_get(:@rcon_authenticated)
72
- end
73
-
74
- should 'raise an error if authentication fails' do
75
- reply = mock
76
- reply.expects(:request_id).returns -1
77
-
78
- rcon_socket = mock
79
- rcon_socket.expects(:send).with { |packet| packet.is_a? RCONAuthRequest }
80
- rcon_socket.expects(:reply).twice.returns(nil).returns(reply)
81
- @server.instance_variable_set :@rcon_socket, rcon_socket
82
-
83
- assert_raises RCONNoAuthError do
84
- @server.rcon_auth 'password'
85
- end
86
- end
87
-
88
- should 'raise an error if the RCON connection is not authenticated' do
89
- assert_raises RCONNoAuthError do
90
- @server.rcon_exec 'command'
91
- end
92
- end
93
-
94
- context 'with an authenticated RCON connection' do
95
-
96
- setup do
97
- @rcon_socket = mock
98
- @rcon_socket.expects(:send).with do |packet|
99
- packet.is_a?(RCONExecRequest) &&
100
- packet.instance_variable_get(:@content_data).string == "command\0\0" &&
101
- packet.instance_variable_get(:@request_id) == 1234
102
- end
103
- @rcon_socket.expects(:send).with do |packet|
104
- packet.is_a?(RCONTerminator) &&
105
- packet.instance_variable_get(:@request_id) == 1234
106
- end
107
-
108
- @server.instance_variable_set :@rcon_authenticated, true
109
- @server.instance_variable_set :@rcon_request_id, 1234
110
- @server.instance_variable_set :@rcon_socket, @rcon_socket
111
- end
112
-
113
- should 'reset the connection if the server indicates so' do
114
- reply = mock
115
- reply.expects(:is_a?).with(RCONAuthResponse).returns true
116
- @rcon_socket.expects(:reply).returns(reply)
117
-
118
- assert_raises RCONNoAuthError do
119
- @server.rcon_exec 'command'
120
- end
121
- assert_not @server.instance_variable_get(:@rcon_authenticated)
122
- end
123
-
124
- should 'receive the response of a command' do
125
- reply1 = mock :response => 'test'
126
- reply2 = mock :response => 'test'
127
- reply3 = mock
128
- reply3.expects(:response).twice.returns ''
129
-
130
- @rcon_socket.expects(:reply).times(3).returns(reply1).returns(reply2).
131
- returns reply3
132
-
133
- assert_equal 'testtest', @server.rcon_exec('command')
134
- end
135
-
136
- end
137
-
138
- end
139
-
140
- end
1
+ # This code is free software; you can redistribute it and/or modify it under
2
+ # the terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2011, Sebastian Staudt
5
+
6
+ require 'helper'
7
+ require 'steam/servers/source_server'
8
+
9
+ class TestSourceServer < Test::Unit::TestCase
10
+
11
+ context 'The user' do
12
+
13
+ should 'be able to get a master server for Source servers' do
14
+ master = mock
15
+ MasterServer.expects(:new).with(*MasterServer::SOURCE_MASTER_SERVER).
16
+ returns master
17
+
18
+ assert_equal master, SourceServer.master
19
+ end
20
+
21
+ end
22
+
23
+ context 'A Source server' do
24
+
25
+ setup do
26
+ Socket.stubs(:getaddrinfo).
27
+ with('source', 27015, Socket::AF_INET, Socket::SOCK_DGRAM).
28
+ returns [[nil, nil, 'source', '127.0.0.1']]
29
+
30
+ @server = SourceServer.new 'source', 27015
31
+ end
32
+
33
+ should 'create client sockets upon initialization' do
34
+ socket = mock
35
+ SourceSocket.expects(:new).with('127.0.0.1', 27015).returns socket
36
+ rcon_socket = mock
37
+ RCONSocket.expects(:new).with('127.0.0.1', 27015).returns rcon_socket
38
+
39
+ @server.init_socket
40
+
41
+ assert_same socket, @server.instance_variable_get(:@socket)
42
+ assert_same rcon_socket, @server.instance_variable_get(:@rcon_socket)
43
+ end
44
+
45
+ should 'be able to authenticate successfully' do
46
+ reply = mock
47
+
48
+ rcon_socket = mock
49
+ rcon_socket.expects(:send).with do |packet|
50
+ reply.expects(:request_id).returns packet.request_id
51
+
52
+ packet.is_a? RCONAuthRequest
53
+ end
54
+ rcon_socket.expects(:reply).twice.returns(nil).returns(reply)
55
+ @server.instance_variable_set :@rcon_socket, rcon_socket
56
+
57
+ assert @server.rcon_auth 'password'
58
+ assert @server.instance_variable_get(:@rcon_authenticated)
59
+ end
60
+
61
+ should 'fail to authenticate if the wrong request ID is returned' do
62
+ reply = mock
63
+ reply.expects(:request_id).returns -1
64
+
65
+ rcon_socket = mock
66
+ rcon_socket.expects(:send).with { |packet| packet.is_a? RCONAuthRequest }
67
+ rcon_socket.expects(:reply).twice.returns(nil).returns(reply)
68
+ @server.instance_variable_set :@rcon_socket, rcon_socket
69
+
70
+ assert_not @server.rcon_auth 'password'
71
+ assert_not @server.instance_variable_get(:@rcon_authenticated)
72
+ end
73
+
74
+ should 'raise an error if the RCON connection is not authenticated' do
75
+ assert_raises RCONNoAuthError do
76
+ @server.rcon_exec 'command'
77
+ end
78
+ end
79
+
80
+ context 'with an authenticated RCON connection' do
81
+
82
+ setup do
83
+ @rcon_socket = mock
84
+ @rcon_socket.expects(:send).with do |packet|
85
+ packet.is_a?(RCONExecRequest) &&
86
+ packet.instance_variable_get(:@content_data).string == "command\0\0" &&
87
+ packet.instance_variable_get(:@request_id) == 1234
88
+ end
89
+ @rcon_socket.expects(:send).with do |packet|
90
+ packet.is_a?(RCONTerminator) &&
91
+ packet.instance_variable_get(:@request_id) == 1234
92
+ end
93
+
94
+ @server.instance_variable_set :@rcon_authenticated, true
95
+ @server.instance_variable_set :@rcon_request_id, 1234
96
+ @server.instance_variable_set :@rcon_socket, @rcon_socket
97
+ end
98
+
99
+ should 'reset the connection if the server indicates so' do
100
+ reply = mock
101
+ reply.expects(:is_a?).with(RCONAuthResponse).returns true
102
+ @rcon_socket.expects(:reply).returns(reply)
103
+
104
+ assert_raises RCONNoAuthError do
105
+ @server.rcon_exec 'command'
106
+ end
107
+ assert_not @server.instance_variable_get(:@rcon_authenticated)
108
+ end
109
+
110
+ should 'receive the response of a command' do
111
+ reply1 = mock :response => 'test'
112
+ reply2 = mock :response => 'test'
113
+ reply3 = mock
114
+ reply3.expects(:response).twice.returns ''
115
+
116
+ @rcon_socket.expects(:reply).times(3).returns(reply1).returns(reply2).
117
+ returns reply3
118
+
119
+ assert_equal 'testtest', @server.rcon_exec('command')
120
+ end
121
+
122
+ end
123
+
124
+ end
125
+
126
+ end
@@ -12,6 +12,7 @@ class TestMasterServerSocket < Test::Unit::TestCase
12
12
 
13
13
  setup do
14
14
  @socket = MasterServerSocket.new '127.0.0.1'
15
+ @socket.instance_variable_set :@buffer, mock
15
16
  end
16
17
 
17
18
  should 'raise an error if the packet header is incorrect' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steam-condenser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sebastian Staudt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-13 00:00:00 Z
18
+ date: 2012-04-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bzip2-ruby
@@ -41,34 +41,50 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 17
44
+ hash: 25
45
45
  segments:
46
46
  - 1
47
- - 0
48
47
  - 3
49
- version: 1.0.3
48
+ - 1
49
+ version: 1.3.1
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: mocha
53
+ name: multi_xml
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
- hash: 55
60
+ hash: 13
61
61
  segments:
62
62
  - 0
63
- - 10
63
+ - 4
64
+ - 1
65
+ version: 0.4.1
66
+ type: :runtime
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: mocha
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 49
77
+ segments:
64
78
  - 0
65
- version: 0.10.0
79
+ - 11
80
+ - 1
81
+ version: 0.11.1
66
82
  type: :development
67
- version_requirements: *id003
83
+ version_requirements: *id004
68
84
  - !ruby/object:Gem::Dependency
69
85
  name: rake
70
86
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
87
+ requirement: &id005 !ruby/object:Gem::Requirement
72
88
  none: false
73
89
  requirements:
74
90
  - - ~>
@@ -80,11 +96,11 @@ dependencies:
80
96
  - 2
81
97
  version: 0.9.2
82
98
  type: :development
83
- version_requirements: *id004
99
+ version_requirements: *id005
84
100
  - !ruby/object:Gem::Dependency
85
101
  name: shoulda-context
86
102
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
103
+ requirement: &id006 !ruby/object:Gem::Requirement
88
104
  none: false
89
105
  requirements:
90
106
  - - ~>
@@ -96,11 +112,11 @@ dependencies:
96
112
  - 0
97
113
  version: 1.0.0
98
114
  type: :development
99
- version_requirements: *id005
115
+ version_requirements: *id006
100
116
  - !ruby/object:Gem::Dependency
101
117
  name: yard
102
118
  prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
119
+ requirement: &id007 !ruby/object:Gem::Requirement
104
120
  none: false
105
121
  requirements:
106
122
  - - ~>
@@ -112,7 +128,7 @@ dependencies:
112
128
  - 2
113
129
  version: 0.7.2
114
130
  type: :development
115
- version_requirements: *id006
131
+ version_requirements: *id007
116
132
  description: A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
117
133
  email:
118
134
  - koraktor@gmail.com
@@ -124,6 +140,7 @@ extra_rdoc_files: []
124
140
 
125
141
  files:
126
142
  - Gemfile
143
+ - Gemfile.lock
127
144
  - lib/core_ext/stringio.rb
128
145
  - lib/errors/packet_format_error.rb
129
146
  - lib/errors/rcon_ban_error.rb
@@ -178,6 +195,7 @@ files:
178
195
  - lib/steam/community/tf2/tf2_spy.rb
179
196
  - lib/steam/community/tf2/tf2_stats.rb
180
197
  - lib/steam/community/web_api.rb
198
+ - lib/steam/community/xml_data.rb
181
199
  - lib/steam/packets/a2m_get_servers_batch2_packet.rb
182
200
  - lib/steam/packets/a2s_info_packet.rb
183
201
  - lib/steam/packets/a2s_player_packet.rb
@@ -236,6 +254,7 @@ files:
236
254
  - test/steam/communtiy/test_steam_group.rb
237
255
  - test/steam/communtiy/test_steam_id.rb
238
256
  - test/steam/communtiy/test_web_api.rb
257
+ - test/steam/packets/test_steam_packet.rb
239
258
  - test/steam/servers/test_game_server.rb
240
259
  - test/steam/servers/test_goldsrc_server.rb
241
260
  - test/steam/servers/test_master_server.rb
@@ -275,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
294
  requirements: []
276
295
 
277
296
  rubyforge_project:
278
- rubygems_version: 1.8.12
297
+ rubygems_version: 1.8.23
279
298
  signing_key:
280
299
  specification_version: 3
281
300
  summary: Steam Condenser - A Steam query library
@@ -290,6 +309,7 @@ test_files:
290
309
  - test/steam/communtiy/test_steam_group.rb
291
310
  - test/steam/communtiy/test_steam_id.rb
292
311
  - test/steam/communtiy/test_web_api.rb
312
+ - test/steam/packets/test_steam_packet.rb
293
313
  - test/steam/servers/test_game_server.rb
294
314
  - test/steam/servers/test_goldsrc_server.rb
295
315
  - test/steam/servers/test_master_server.rb