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
data/lib/byte_buffer.rb DELETED
@@ -1,126 +0,0 @@
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) 2008-2009, Sebastian Staudt
5
-
6
- require "exceptions/buffer_underflow_exception"
7
-
8
- # The ByteBuffer class derived from Java's java.nio.ByteBuffer
9
- class ByteBuffer
10
-
11
- attr_accessor :limit
12
- attr_reader :position
13
- protected :initialize
14
-
15
- # Creates a new buffer with the given size in bytes
16
- def self.allocate(length)
17
- return ByteBuffer.new(0.chr * length)
18
- end
19
-
20
- # Creates a new buffer from an existing String
21
- def self.wrap(byte_array)
22
- return ByteBuffer.new(byte_array.to_s)
23
- end
24
-
25
- #
26
- def initialize(byte_array)
27
- if byte_array.is_a? ByteBuffer
28
- raise Exception.new
29
- end
30
-
31
- @byte_array = byte_array.to_s
32
- @capacity = @byte_array.length
33
- @limit = @capacity
34
- @position = 0
35
- @mark = -1
36
- end
37
-
38
- def array
39
- return @byte_array
40
- end
41
-
42
- def clear
43
- @limit = @capacity
44
- @position = 0
45
- @mark = -1
46
-
47
- return self
48
- end
49
-
50
- def flip
51
- @limit = @position
52
- @position = 0
53
- @mark = -1
54
-
55
- return self
56
- end
57
-
58
- def get(length = nil)
59
- if length == nil
60
- length = @limit - @position
61
- elsif length > self.remaining
62
- BufferUnderflowException.new
63
- end
64
-
65
- data = @byte_array[@position, length]
66
- @position += length
67
-
68
- return data
69
- end
70
-
71
- def get_byte
72
- return self.get(1)[0]
73
- end
74
-
75
- def get_float
76
- return self.get(4).unpack("e")[0]
77
- end
78
-
79
- def get_long
80
- return self.get(4).unpack("V")[0]
81
- end
82
-
83
- def get_short
84
- return self.get(2).unpack("v")[0]
85
- end
86
-
87
- def get_signed_long
88
- return self.get(4).unpack('l')[0]
89
- end
90
-
91
- def get_string
92
- zero_byte_index = @byte_array.index("\0", @position)
93
- if zero_byte_index == nil
94
- nil
95
- else
96
- data_string = self.get(zero_byte_index - @position)
97
- @position += 1
98
- data_string
99
- end
100
- end
101
-
102
- def length
103
- return @byte_array.length
104
- end
105
-
106
- def remaining
107
- return @limit - @position
108
- end
109
-
110
- def rewind
111
- @position = 0
112
- @mark = -1
113
-
114
- return self
115
- end
116
-
117
- def put(source_byte_array)
118
- new_position = [source_byte_array.length, self.remaining].min
119
-
120
- @byte_array[@position, new_position] = source_byte_array
121
- @position = new_position
122
-
123
- return self
124
- end
125
-
126
- end
@@ -1,8 +0,0 @@
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) 2008-2009, Sebastian Staudt
5
-
6
- class BufferUnderflowException < Exception
7
-
8
- end
@@ -1,76 +0,0 @@
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, Sebastian Staudt
5
-
6
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
7
-
8
- require 'test/unit'
9
- require 'byte_buffer'
10
-
11
- class ByteBufferTests < Test::Unit::TestCase
12
-
13
- def test_allocate
14
- buffer = ByteBuffer.allocate(10)
15
- assert_equal("\0" * 10, buffer.array)
16
- end
17
-
18
- def test_get_byte
19
- buffer = ByteBuffer.wrap('test')
20
- assert_equal('t'[0], buffer.get_byte)
21
- assert_equal(3, buffer.remaining)
22
- end
23
-
24
- def test_get_float
25
- buffer = ByteBuffer.wrap('test')
26
- assert_equal('7.71353668494131e+31', buffer.get_float.to_s)
27
- assert_equal(0, buffer.remaining)
28
- end
29
-
30
- def test_get_long
31
- buffer = ByteBuffer.wrap('test')
32
- assert_equal(1953719668, buffer.get_long)
33
- assert_equal(0, buffer.remaining)
34
- end
35
-
36
- def test_get_short
37
- buffer = ByteBuffer.wrap('test')
38
- assert_equal(25972, buffer.get_short)
39
- assert_equal(2, buffer.remaining)
40
- end
41
-
42
- def test_get_signed_long
43
- buffer = ByteBuffer.wrap(" \255")
44
- assert_equal(-1390403552, buffer.get_signed_long)
45
- assert_equal(0, buffer.remaining)
46
- end
47
-
48
- def test_get_string
49
- buffer = ByteBuffer.wrap("test\0test")
50
- assert_equal('test', buffer.get_string)
51
- assert_equal(4, buffer.remaining)
52
- end
53
-
54
- def test_put
55
- buffer = ByteBuffer.wrap('te')
56
- buffer.put('st')
57
- assert_equal('st', buffer.array)
58
- buffer = ByteBuffer.allocate(4)
59
- buffer.put('test')
60
- assert_equal('test', buffer.array)
61
- end
62
-
63
- def test_rewind
64
- buffer = ByteBuffer.wrap('test')
65
- assert_equal(25972, buffer.get_short)
66
- buffer.rewind
67
- assert_equal(25972, buffer.get_short)
68
- end
69
-
70
- def test_wrap
71
- string = 'test'
72
- buffer = ByteBuffer.wrap(string)
73
- assert_equal(string, buffer.array)
74
- end
75
-
76
- end