steam-condenser 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/VERSION.yml +2 -2
  2. data/lib/datagram_channel.rb +30 -33
  3. data/lib/exceptions/packet_format_exception.rb +7 -3
  4. data/lib/exceptions/rcon_ban_exception.rb +7 -5
  5. data/lib/exceptions/rcon_no_auth_exception.rb +8 -6
  6. data/lib/exceptions/timeout_exception.rb +10 -4
  7. data/lib/socket_channel.rb +11 -17
  8. data/lib/steam/community/cacheable.rb +5 -7
  9. data/lib/steam/community/css/css_map.rb +31 -0
  10. data/lib/steam/community/css/css_stats.rb +116 -0
  11. data/lib/steam/community/css/css_weapon.rb +33 -0
  12. data/lib/steam/community/dods/dods_stats.rb +3 -3
  13. data/lib/steam/community/game_stats.rb +14 -13
  14. data/lib/steam/community/game_weapon.rb +3 -5
  15. data/lib/steam/community/l4d/abstract_l4d_stats.rb +4 -2
  16. data/lib/steam/community/l4d/l4d_explosive.rb +2 -2
  17. data/lib/steam/community/l4d/l4d_map.rb +3 -3
  18. data/lib/steam/community/steam_group.rb +2 -4
  19. data/lib/steam/community/steam_id.rb +2 -2
  20. data/lib/steam/community/tf2/tf2_class.rb +17 -17
  21. data/lib/steam/community/tf2/tf2_class_factory.rb +17 -17
  22. data/lib/steam/community/tf2/tf2_engineer.rb +9 -9
  23. data/lib/steam/community/tf2/tf2_medic.rb +9 -9
  24. data/lib/steam/community/tf2/tf2_sniper.rb +7 -7
  25. data/lib/steam/community/tf2/tf2_spy.rb +9 -9
  26. data/lib/steam/community/tf2/tf2_stats.rb +9 -9
  27. data/lib/steam/packets/a2a_ack_packet.rb +11 -9
  28. data/lib/steam/packets/a2a_ping_packet.rb +5 -4
  29. data/lib/steam/packets/a2m_get_servers_batch2_packet.rb +13 -12
  30. data/lib/steam/packets/a2s_info_packet.rb +8 -7
  31. data/lib/steam/packets/a2s_player_packet.rb +6 -6
  32. data/lib/steam/packets/a2s_rules_packet.rb +5 -5
  33. data/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +4 -3
  34. data/lib/steam/packets/m2a_server_batch_packet.rb +20 -22
  35. data/lib/steam/packets/rcon/rcon_auth_request.rb +5 -5
  36. data/lib/steam/packets/rcon/rcon_auth_response.rb +6 -6
  37. data/lib/steam/packets/rcon/rcon_exec_request.rb +5 -5
  38. data/lib/steam/packets/rcon/rcon_exec_response.rb +2 -2
  39. data/lib/steam/packets/rcon/rcon_goldsrc_request.rb +7 -7
  40. data/lib/steam/packets/rcon/rcon_goldsrc_response.rb +8 -8
  41. data/lib/steam/packets/rcon/rcon_packet.rb +12 -16
  42. data/lib/steam/packets/rcon/rcon_packet_factory.rb +19 -19
  43. data/lib/steam/packets/request_with_challenge.rb +5 -5
  44. data/lib/steam/packets/s2a_info2_packet.rb +28 -30
  45. data/lib/steam/packets/s2a_info_base_packet.rb +11 -16
  46. data/lib/steam/packets/s2a_info_detailed_packet.rb +30 -28
  47. data/lib/steam/packets/s2a_player_packet.rb +7 -9
  48. data/lib/steam/packets/s2a_rules_packet.rb +8 -12
  49. data/lib/steam/packets/s2c_challenge_packet.rb +7 -6
  50. data/lib/steam/packets/steam_packet.rb +7 -6
  51. data/lib/steam/packets/steam_packet_factory.rb +37 -38
  52. data/lib/steam/servers/game_server.rb +76 -86
  53. data/lib/steam/servers/goldsrc_server.rb +5 -5
  54. data/lib/steam/servers/master_server.rb +24 -24
  55. data/lib/steam/servers/source_server.rb +17 -19
  56. data/lib/steam/sockets/goldsrc_socket.rb +43 -46
  57. data/lib/steam/sockets/master_server_socket.rb +11 -13
  58. data/lib/steam/sockets/rcon_socket.rb +15 -17
  59. data/lib/steam/sockets/source_socket.rb +21 -21
  60. data/lib/steam/sockets/steam_socket.rb +25 -28
  61. data/lib/steam/steam_player.rb +3 -1
  62. data/lib/stringio_additions.rb +48 -0
  63. data/test/datagram_channel_tests.rb +8 -8
  64. data/test/query_tests.rb +15 -14
  65. data/test/rcon_tests.rb +32 -31
  66. data/test/socket_channel_tests.rb +7 -7
  67. data/test/steam/communtiy/steam_community_test_suite.rb +5 -2
  68. data/test/steam_community_tests.rb +4 -3
  69. data/test/stringio_additions_tests.rb +77 -0
  70. metadata +15 -8
  71. data/lib/byte_buffer.rb +0 -126
  72. data/lib/exceptions/buffer_underflow_exception.rb +0 -8
  73. data/test/byte_buffer_tests.rb +0 -76
@@ -1,14 +1,14 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2009, Sebastian Staudt
5
-
6
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
7
5
 
8
6
  require 'test/unit'
9
7
 
10
- require 'byte_buffer'
8
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
9
+
11
10
  require 'datagram_channel'
11
+ require 'stringio_additions'
12
12
 
13
13
  class DatagramChannelTests < Test::Unit::TestCase
14
14
 
@@ -22,18 +22,18 @@ class DatagramChannelTests < Test::Unit::TestCase
22
22
  channel.connect('localhost', port)
23
23
 
24
24
  string = 'test'
25
-
26
- buffer = ByteBuffer.wrap(string)
25
+
26
+ buffer = StringIO.new string
27
27
  channel.write(buffer)
28
28
  sent, socket_addr = socket.recvfrom(4)
29
29
  socket.send(string, 0, 'localhost', socket_addr[1])
30
- buffer = ByteBuffer.allocate(4)
30
+ buffer = StringIO.allocate 4
31
31
  channel.read(buffer)
32
32
 
33
33
  channel.close
34
34
  socket.close
35
35
 
36
- received = buffer.array
36
+ received = buffer.data
37
37
 
38
38
  assert_equal(string, sent)
39
39
  assert_equal(string, received)
data/test/query_tests.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
+
6
+ require 'ipaddr'
7
+ require 'test/unit'
5
8
 
6
9
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
7
10
 
8
- require "exceptions/timeout_exception"
9
- require "ipaddr"
10
- require "steam/servers/goldsrc_server"
11
- require "steam/servers/master_server"
12
- require "steam/servers/source_server"
13
- require "test/unit"
11
+ require 'exceptions/timeout_exception'
12
+ require 'steam/servers/goldsrc_server'
13
+ require 'steam/servers/master_server'
14
+ require 'steam/servers/source_server'
14
15
 
15
16
  class QueryTests < Test::Unit::TestCase
16
17
 
@@ -18,7 +19,7 @@ class QueryTests < Test::Unit::TestCase
18
19
  def test_invalid_goldsrc_server
19
20
  assert_raise TimeoutException do
20
21
  invalid_server = GoldSrcServer.new IPAddr.new("1.0.0.0")
21
- invalid_server.get_ping
22
+ invalid_server.ping
22
23
  end
23
24
  end
24
25
 
@@ -26,16 +27,16 @@ class QueryTests < Test::Unit::TestCase
26
27
  def test_invalid_source_server
27
28
  assert_raise TimeoutException do
28
29
  invalid_server = SourceServer.new IPAddr.new("1.0.0.0")
29
- invalid_server.get_ping
30
+ invalid_server.ping
30
31
  end
31
32
  end
32
-
33
+
33
34
  # This test gets a random GoldSrc server from the master server and does a
34
35
  # full query on it
35
36
  def test_random_goldsrc_server
36
37
  assert_nothing_raised do
37
38
  master_server = MasterServer.new(*MasterServer::GOLDSRC_MASTER_SERVER)
38
- servers = master_server.get_servers MasterServer::REGION_ALL, "\\type\\d\\empty\\1\\full\\1\\gamedir\\valve"
39
+ servers = master_server.servers MasterServer::REGION_ALL, "\\type\\d\\empty\\1\\full\\1\\gamedir\\valve"
39
40
 
40
41
  assert !servers.empty?, "Got no servers from master server."
41
42
 
@@ -47,13 +48,13 @@ class QueryTests < Test::Unit::TestCase
47
48
  print server.to_s
48
49
  end
49
50
  end
50
-
51
+
51
52
  # This test gets a random Source server from the master server and does a
52
53
  # full query on it
53
54
  def test_random_source_server
54
55
  assert_nothing_raised do
55
56
  master_server = MasterServer.new(*MasterServer::SOURCE_MASTER_SERVER)
56
- servers = master_server.get_servers MasterServer::REGION_ALL, "\\type\\d\\empty\\1\\full\\1\\gamedir\\tf"
57
+ servers = master_server.servers MasterServer::REGION_ALL, "\\type\\d\\empty\\1\\full\\1\\gamedir\\tf"
57
58
 
58
59
  assert !servers.empty?, "Got no servers from master server."
59
60
 
@@ -65,5 +66,5 @@ class QueryTests < Test::Unit::TestCase
65
66
  print server.to_s
66
67
  end
67
68
  end
68
-
69
+
69
70
  end
data/test/rcon_tests.rb CHANGED
@@ -1,76 +1,77 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
+
6
+ require 'ipaddr'
7
+ require 'test/unit'
5
8
 
6
9
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
7
10
 
8
- require "ipaddr"
9
- require "steam/servers/goldsrc_server"
10
- require "steam/servers/source_server"
11
- require "test/unit"
11
+ require 'steam/servers/goldsrc_server'
12
+ require 'steam/servers/source_server'
12
13
 
13
14
  class RCONTests < Test::Unit::TestCase
14
15
 
15
16
  # This test tries to run the "status" command over RCON on a GoldSrc server
16
17
  def test_long_rcon_goldsrc_server
17
18
  assert_nothing_raised do
18
- server = GoldSrcServer.new IPAddr.new("127.0.0.1")
19
- server.rcon_auth "test"
20
- rcon_reply = server.rcon_exec "cvarlist"
19
+ server = GoldSrcServer.new IPAddr.new('127.0.0.1')
20
+ server.rcon_auth 'test'
21
+ rcon_reply = server.rcon_exec 'cvarlist'
21
22
  print "#{rcon_reply}\n"
22
23
 
23
24
  assert(
24
- rcon_reply.include?("CvarList ? for syntax"),
25
- "Did not receive complete cvarlist.")
25
+ rcon_reply.include?('CvarList ? for syntax'),
26
+ 'Did not receive complete cvarlist.')
26
27
  end
27
28
  end
28
-
29
+
29
30
  # This test tries to run the "status" command over RCON on a Source server
30
31
  def test_long_rcon_source_server
31
32
  assert_nothing_raised do
32
- server = SourceServer.new IPAddr.new("127.0.0.1")
33
- if server.rcon_auth "test"
34
- rcon_reply = server.rcon_exec "cvarlist"
33
+ server = SourceServer.new IPAddr.new('127.0.0.1')
34
+ if server.rcon_auth 'test'
35
+ rcon_reply = server.rcon_exec 'cvarlist'
35
36
  print "#{rcon_reply}\n"
36
37
  end
37
38
 
38
39
  assert(
39
- rcon_reply.include?("total convars/concommands"),
40
- "Did not receive complete cvarlist.")
40
+ rcon_reply.include?('total convars/concommands'),
41
+ 'Did not receive complete cvarlist.')
41
42
  end
42
43
  end
43
-
44
+
44
45
  # This test tries to run the "status" command over RCON on a GoldSrc server
45
46
  def test_short_rcon_goldsrc_server
46
47
  assert_nothing_raised do
47
- server = GoldSrcServer.new IPAddr.new("127.0.0.1")
48
- server.rcon_auth "test"
49
- rcon_reply = server.rcon_exec "version"
48
+ server = GoldSrcServer.new IPAddr.new('127.0.0.1')
49
+ server.rcon_auth 'test'
50
+ rcon_reply = server.rcon_exec 'version'
50
51
  print "#{rcon_reply}\n"
51
52
 
52
53
  assert(
53
- rcon_reply.include?("Protocol version") &&
54
- rcon_reply.include?("Exe version") &&
55
- rcon_reply.include?("Exe build"),
56
- "Did not receive correct version response.");
54
+ rcon_reply.include?('Protocol version') &&
55
+ rcon_reply.include?('Exe version') &&
56
+ rcon_reply.include?('Exe build'),
57
+ 'Did not receive correct version response.');
57
58
  end
58
59
  end
59
60
 
60
61
  # This test tries to run the "status" command over RCON on a Source server
61
62
  def test_short_rcon_source_server
62
63
  assert_nothing_raised do
63
- server = SourceServer.new IPAddr.new("127.0.0.1")
64
- if server.rcon_auth "test"
65
- rcon_reply = server.rcon_exec "version"
64
+ server = SourceServer.new IPAddr.new('127.0.0.1')
65
+ if server.rcon_auth 'test'
66
+ rcon_reply = server.rcon_exec 'version'
66
67
  print "#{rcon_reply}\n"
67
68
  end
68
69
 
69
70
  assert(
70
- rcon_reply.include?("Protocol version") &&
71
- rcon_reply.include?("Exe version") &&
72
- rcon_reply.include?("Exe build"),
73
- "Did not receive correct version response.");
71
+ rcon_reply.include?('Protocol version') &&
72
+ rcon_reply.include?('Exe version') &&
73
+ rcon_reply.include?('Exe build'),
74
+ 'Did not receive correct version response.');
74
75
  end
75
76
  end
76
77
 
@@ -1,13 +1,13 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2009, Sebastian Staudt
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
5
5
 
6
6
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
7
7
 
8
8
  require 'test/unit'
9
9
 
10
- require 'byte_buffer'
10
+ require 'stringio_additions'
11
11
  require 'socket_channel'
12
12
 
13
13
  class SocketChannelTests < Test::Unit::TestCase
@@ -19,22 +19,22 @@ class SocketChannelTests < Test::Unit::TestCase
19
19
 
20
20
  channel = SocketChannel.open
21
21
  channel.connect Socket.getaddrinfo('localhost', port)
22
-
22
+
23
23
  socket= server.accept
24
24
 
25
25
  string = 'test'
26
-
27
- buffer = ByteBuffer.wrap(string)
26
+
27
+ buffer = StringIO.new string
28
28
  channel.write(buffer)
29
29
  sent, socket_addr = socket.recvfrom(4)
30
30
  socket.send(string, 0)
31
- buffer = ByteBuffer.allocate(4)
31
+ buffer = StringIO.allocate 4
32
32
  channel.read(buffer)
33
33
 
34
34
  channel.close
35
35
  socket.close
36
36
 
37
- received = buffer.array
37
+ received = buffer.data
38
38
 
39
39
  assert_equal(string, sent)
40
40
  assert_equal(string, received)
@@ -1,9 +1,12 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2009, Sebastian Staudt
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
5
5
 
6
- require 'test/unit'
6
+ require 'test/unit'
7
+
8
+ suite_dir = File.dirname(__FILE__)
9
+ $LOAD_PATH.unshift(suite_dir) unless $LOAD_PATH.include?(suite_dir)
7
10
 
8
11
  require 'steam_group_tests'
9
12
  require 'steam_id_tests'
@@ -3,10 +3,11 @@
3
3
  #
4
4
  # Copyright (c) 2008-2009, Sebastian Staudt
5
5
 
6
+ require 'test/unit'
7
+
6
8
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
7
9
 
8
- require "steam/community/steam_id"
9
- require "test/unit"
10
+ require 'steam/community/steam_id'
10
11
 
11
12
  class SteamCommunityTests < Test::Unit::TestCase
12
13
 
@@ -40,5 +41,5 @@ class SteamCommunityTests < Test::Unit::TestCase
40
41
  p steam_id.game_stats('tf2')
41
42
  end
42
43
  end
43
-
44
+
44
45
  end
@@ -0,0 +1,77 @@
1
+ # This code is free software; you can redistribute it and/or modify it under the
2
+ # terms of the new BSD License.
3
+ #
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
5
+
6
+ require 'test/unit'
7
+
8
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
9
+
10
+ require 'stringio_additions'
11
+
12
+ class StringIOAdditionsTests < Test::Unit::TestCase
13
+
14
+ def test_allocate
15
+ buffer = StringIO.allocate(10)
16
+ assert_equal("\0" * 10, buffer.data)
17
+ end
18
+
19
+ def test_byte
20
+ buffer = StringIO.new('test')
21
+ assert_equal('t'[0], buffer.byte)
22
+ assert_equal(3, buffer.remaining)
23
+ end
24
+
25
+ def test_float
26
+ buffer = StringIO.new('test')
27
+ assert_equal('7.71353668494131e+31', buffer.float.to_s)
28
+ assert_equal(0, buffer.remaining)
29
+ end
30
+
31
+ def test_long
32
+ buffer = StringIO.new('test')
33
+ assert_equal(1953719668, buffer.long)
34
+ assert_equal(0, buffer.remaining)
35
+ end
36
+
37
+ def test_short
38
+ buffer = StringIO.new('test')
39
+ assert_equal(25972, buffer.short)
40
+ assert_equal(2, buffer.remaining)
41
+ end
42
+
43
+ def test_signed_long
44
+ buffer = StringIO.new(" \255")
45
+ assert_equal(-1390403552, buffer.signed_long)
46
+ assert_equal(0, buffer.remaining)
47
+ end
48
+
49
+ def test_string
50
+ buffer = StringIO.new("test\0test")
51
+ assert_equal('test', buffer.string)
52
+ assert_equal(4, buffer.remaining)
53
+ end
54
+
55
+ def test_put
56
+ buffer = StringIO.new('te')
57
+ buffer.write('st')
58
+ assert_equal('st', buffer.data)
59
+ buffer = StringIO.allocate(4)
60
+ buffer.write('test')
61
+ assert_equal('test', buffer.data)
62
+ end
63
+
64
+ def test_rewind
65
+ buffer = StringIO.new('test')
66
+ assert_equal(25972, buffer.short)
67
+ buffer.rewind
68
+ assert_equal(25972, buffer.short)
69
+ end
70
+
71
+ def test_wrap
72
+ string = 'test'
73
+ buffer = StringIO.new(string)
74
+ assert_equal(string, buffer.data)
75
+ end
76
+
77
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steam-condenser
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 10
8
- - 1
9
- version: 0.10.1
8
+ - 11
9
+ - 0
10
+ version: 0.11.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sebastian Staudt
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-05 00:00:00 +02:00
18
+ date: 2010-07-02 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -32,9 +33,7 @@ files:
32
33
  - Rakefile
33
34
  - VERSION.yml
34
35
  - lib/abstract_class.rb
35
- - lib/byte_buffer.rb
36
36
  - lib/datagram_channel.rb
37
- - lib/exceptions/buffer_underflow_exception.rb
38
37
  - lib/exceptions/packet_format_exception.rb
39
38
  - lib/exceptions/rcon_ban_exception.rb
40
39
  - lib/exceptions/rcon_no_auth_exception.rb
@@ -43,6 +42,9 @@ files:
43
42
  - lib/socket_channel.rb
44
43
  - lib/steam-condenser.rb
45
44
  - lib/steam/community/cacheable.rb
45
+ - lib/steam/community/css/css_map.rb
46
+ - lib/steam/community/css/css_stats.rb
47
+ - lib/steam/community/css/css_weapon.rb
46
48
  - lib/steam/community/defense_grid/defense_grid_stats.rb
47
49
  - lib/steam/community/dods/dods_class.rb
48
50
  - lib/steam/community/dods/dods_stats.rb
@@ -104,7 +106,7 @@ files:
104
106
  - lib/steam/sockets/source_socket.rb
105
107
  - lib/steam/sockets/steam_socket.rb
106
108
  - lib/steam/steam_player.rb
107
- - test/byte_buffer_tests.rb
109
+ - lib/stringio_additions.rb
108
110
  - test/datagram_channel_tests.rb
109
111
  - test/query_tests.rb
110
112
  - test/rcon_tests.rb
@@ -113,6 +115,7 @@ files:
113
115
  - test/steam/communtiy/steam_group_tests.rb
114
116
  - test/steam/communtiy/steam_id_tests.rb
115
117
  - test/steam_community_tests.rb
118
+ - test/stringio_additions_tests.rb
116
119
  has_rdoc: true
117
120
  homepage: http://koraktor.github.com/steam-condenser
118
121
  licenses: []
@@ -127,23 +130,27 @@ rdoc_options:
127
130
  require_paths:
128
131
  - lib
129
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
130
134
  requirements:
131
135
  - - ">="
132
136
  - !ruby/object:Gem::Version
137
+ hash: 3
133
138
  segments:
134
139
  - 0
135
140
  version: "0"
136
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
137
143
  requirements:
138
144
  - - ">="
139
145
  - !ruby/object:Gem::Version
146
+ hash: 3
140
147
  segments:
141
148
  - 0
142
149
  version: "0"
143
150
  requirements: []
144
151
 
145
152
  rubyforge_project: steam-condenser
146
- rubygems_version: 1.3.6
153
+ rubygems_version: 1.3.7
147
154
  signing_key:
148
155
  specification_version: 3
149
156
  summary: Steam Condenser - A Steam query library