steam-condenser 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.md +2 -1
  2. data/Rakefile +10 -1
  3. data/lib/steam-condenser/version.rb +1 -1
  4. data/lib/steam/community/app_news.rb +0 -0
  5. data/lib/steam/community/game_leaderboard.rb +199 -0
  6. data/lib/steam/community/game_leaderboard_entry.rb +43 -0
  7. data/lib/steam/community/game_stats.rb +16 -0
  8. data/lib/steam/community/steam_game.rb +18 -0
  9. data/lib/steam/community/steam_group.rb +9 -4
  10. data/lib/steam/community/steam_id.rb +45 -41
  11. data/lib/steam/community/tf2/tf2_beta_inventory.rb +22 -0
  12. data/lib/steam/community/tf2/tf2_golden_wrench.rb +0 -0
  13. data/lib/steam/community/tf2/tf2_stats.rb +10 -4
  14. data/lib/steam/community/web_api.rb +0 -0
  15. data/lib/steam/servers/master_server.rb +2 -1
  16. data/lib/steam/servers/server.rb +1 -1
  17. data/lib/steam/sockets/rcon_socket.rb +0 -1
  18. data/lib/steam/sockets/steam_socket.rb +2 -1
  19. data/steam-condenser.gemspec +5 -4
  20. data/test/core_ext/test_stringio.rb +59 -0
  21. data/test/fixtures/invalid.xml +2 -0
  22. data/test/fixtures/sonofthor.xml +882 -0
  23. data/test/fixtures/status_goldsrc +3 -0
  24. data/test/fixtures/status_source +3 -0
  25. data/test/fixtures/valve-members.xml +231 -0
  26. data/test/helper.rb +37 -0
  27. data/test/steam/communtiy/test_steam_group.rb +83 -0
  28. data/test/steam/communtiy/test_steam_id.rb +85 -0
  29. data/test/steam/communtiy/test_web_api.rb +98 -0
  30. data/test/steam/servers/test_game_server.rb +308 -0
  31. data/test/steam/servers/test_goldsrc_server.rb +59 -0
  32. data/test/steam/servers/test_master_server.rb +131 -0
  33. data/test/steam/servers/test_server.rb +72 -0
  34. data/test/steam/servers/test_source_server.rb +140 -0
  35. data/test/steam/sockets/test_goldsrc_socket.rb +127 -0
  36. data/test/steam/sockets/test_master_server_socket.rb +41 -0
  37. data/test/steam/sockets/test_rcon_socket.rb +109 -0
  38. data/test/steam/sockets/test_source_socket.rb +77 -0
  39. data/test/steam/sockets/test_steam_socket.rb +97 -0
  40. metadata +94 -34
  41. data/Gemfile.lock +0 -22
  42. data/test/query_tests.rb +0 -70
  43. data/test/rcon_tests.rb +0 -78
  44. data/test/steam/communtiy/steam_community_test_suite.rb +0 -12
  45. data/test/steam/communtiy/steam_group_tests.rb +0 -44
  46. data/test/steam/communtiy/steam_id_tests.rb +0 -49
  47. data/test/steam_community_tests.rb +0 -45
  48. data/test/stringio_additions_tests.rb +0 -77
data/Gemfile.lock DELETED
@@ -1,22 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- steam-condenser (1.0.0)
5
- bzip2-ruby (~> 0.2.7)
6
- multi_json (~> 1.0.3)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- bzip2-ruby (0.2.7)
12
- multi_json (1.0.3)
13
- rake (0.9.2)
14
- yard (0.7.2)
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- rake (~> 0.9.2)
21
- steam-condenser!
22
- yard (~> 0.7.2)
data/test/query_tests.rb DELETED
@@ -1,70 +0,0 @@
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) 2008-2011, Sebastian Staudt
5
-
6
- require 'ipaddr'
7
- require 'test/unit'
8
-
9
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
10
-
11
- require 'errors/timeout_error'
12
- require 'steam/servers/goldsrc_server'
13
- require 'steam/servers/master_server'
14
- require 'steam/servers/source_server'
15
-
16
- class QueryTests < Test::Unit::TestCase
17
-
18
- # This test tries to initialize an invalid GoldSrc server
19
- def test_invalid_goldsrc_server
20
- assert_raise SteamCondenser::TimeoutError do
21
- invalid_server = GoldSrcServer.new IPAddr.new('1.0.0.0')
22
- invalid_server.ping
23
- end
24
- end
25
-
26
- # This test tries to initialize an invalid Source server
27
- def test_invalid_source_server
28
- assert_raise SteamCondenser::TimeoutError do
29
- invalid_server = SourceServer.new IPAddr.new('1.0.0.0')
30
- invalid_server.ping
31
- end
32
- end
33
-
34
- # This test gets a random GoldSrc server from the master server and does a
35
- # full query on it
36
- def test_random_goldsrc_server
37
- assert_nothing_raised do
38
- master_server = MasterServer.new(*MasterServer::GOLDSRC_MASTER_SERVER)
39
- servers = master_server.servers MasterServer::REGION_ALL, '\type\d\empty\1\full\1\gamedir\valve'
40
-
41
- assert !servers.empty?, 'Got no servers from master server.'
42
-
43
- server = GoldSrcServer.new(*servers[rand(servers.length)])
44
- server.init
45
- server.update_players
46
- server.update_rules
47
-
48
- print server.to_s
49
- end
50
- end
51
-
52
- # This test gets a random Source server from the master server and does a
53
- # full query on it
54
- def test_random_source_server
55
- assert_nothing_raised do
56
- master_server = MasterServer.new(*MasterServer::SOURCE_MASTER_SERVER)
57
- servers = master_server.servers MasterServer::REGION_ALL, '\type\d\empty\1\full\1\gamedir\tf'
58
-
59
- assert !servers.empty?, 'Got no servers from master server.'
60
-
61
- server = SourceServer.new(*servers[rand(servers.length)])
62
- server.init
63
- server.update_players
64
- server.update_rules
65
-
66
- print server.to_s
67
- end
68
- end
69
-
70
- end
data/test/rcon_tests.rb DELETED
@@ -1,78 +0,0 @@
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) 2008-2011, Sebastian Staudt
5
-
6
- require 'ipaddr'
7
- require 'test/unit'
8
-
9
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
10
-
11
- require 'steam/servers/goldsrc_server'
12
- require 'steam/servers/source_server'
13
-
14
- class RCONTests < Test::Unit::TestCase
15
-
16
- # This test tries to run the "status" command over RCON on a GoldSrc server
17
- def test_long_rcon_goldsrc_server
18
- assert_nothing_raised do
19
- server = GoldSrcServer.new IPAddr.new('127.0.0.1')
20
- server.rcon_auth 'test'
21
- rcon_reply = server.rcon_exec 'cvarlist'
22
- print "#{rcon_reply}\n"
23
-
24
- assert(
25
- rcon_reply.include?('CvarList ? for syntax'),
26
- 'Did not receive complete cvarlist.')
27
- end
28
- end
29
-
30
- # This test tries to run the "status" command over RCON on a Source server
31
- def test_long_rcon_source_server
32
- assert_nothing_raised do
33
- server = SourceServer.new IPAddr.new('127.0.0.1')
34
- if server.rcon_auth 'test'
35
- rcon_reply = server.rcon_exec 'cvarlist'
36
- print "#{rcon_reply}\n"
37
- end
38
-
39
- assert(
40
- rcon_reply.include?('total convars/concommands'),
41
- 'Did not receive complete cvarlist.')
42
- end
43
- end
44
-
45
- # This test tries to run the "status" command over RCON on a GoldSrc server
46
- def test_short_rcon_goldsrc_server
47
- assert_nothing_raised do
48
- server = GoldSrcServer.new IPAddr.new('127.0.0.1')
49
- server.rcon_auth 'test'
50
- rcon_reply = server.rcon_exec 'version'
51
- print "#{rcon_reply}\n"
52
-
53
- assert(
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.');
58
- end
59
- end
60
-
61
- # This test tries to run the "status" command over RCON on a Source server
62
- def test_short_rcon_source_server
63
- assert_nothing_raised do
64
- server = SourceServer.new IPAddr.new('127.0.0.1')
65
- if server.rcon_auth 'test'
66
- rcon_reply = server.rcon_exec 'version'
67
- print "#{rcon_reply}\n"
68
- end
69
-
70
- assert(
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.');
75
- end
76
- end
77
-
78
- end
@@ -1,12 +0,0 @@
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) 2009-2011, Sebastian Staudt
5
-
6
- require 'test/unit'
7
-
8
- suite_dir = File.dirname(__FILE__)
9
- $LOAD_PATH.unshift(suite_dir) unless $LOAD_PATH.include?(suite_dir)
10
-
11
- require 'steam_group_tests'
12
- require 'steam_id_tests'
@@ -1,44 +0,0 @@
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) 2009-2011, Sebastian Staudt
5
-
6
- $:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
7
-
8
- require 'test/unit'
9
-
10
- require 'steam/community/steam_group'
11
-
12
- class SteamGroupTests < Test::Unit::TestCase
13
-
14
- def test_bypass_cache
15
- SteamGroup.clear_cache
16
- group = SteamGroup.new('valve')
17
- fetch_time = group.fetch_time
18
- sleep 1
19
- group = SteamGroup.new('valve', true, true)
20
- assert_operator(fetch_time, :<, group.fetch_time)
21
- end
22
-
23
- def test_cache
24
- SteamGroup.clear_cache
25
- group = SteamGroup.new('valve')
26
- fetch_time = group.fetch_time
27
- assert_equal(true, SteamGroup.cached?(103582791429521412))
28
- assert_equal(true, SteamGroup.cached?('valve'))
29
- sleep 1
30
- group = SteamGroup.new('valve')
31
- assert_equal(fetch_time, group.fetch_time)
32
- end
33
-
34
- def test_case_insensitivity
35
- SteamGroup.clear_cache
36
- group = SteamGroup.new('valve', false)
37
- group2 = SteamGroup.new('Valve', false)
38
- group3 = SteamGroup.new('VALVE', false)
39
- assert_equal(true, SteamGroup.cached?('valve'))
40
- assert_equal(group, group2)
41
- assert_equal(group, group3)
42
- end
43
-
44
- end
@@ -1,49 +0,0 @@
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) 2009-2011, Sebastian Staudt
5
-
6
- $:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
7
-
8
- require 'test/unit'
9
-
10
- require 'steam/community/steam_id'
11
-
12
- class SteamIdTests < Test::Unit::TestCase
13
-
14
- def test_bypass_cache
15
- SteamId.clear_cache
16
- steam_id = SteamId.new('koraktor')
17
- fetch_time = steam_id.fetch_time
18
- sleep 1
19
- steam_id = SteamId.new('koraktor', true, true)
20
- assert_operator(fetch_time, :<, steam_id.fetch_time)
21
- end
22
-
23
- def test_cache
24
- SteamId.clear_cache
25
- steam_id = SteamId.new('koraktor')
26
- fetch_time = steam_id.fetch_time
27
- assert_equal(true, SteamId.cached?(76561197961384956))
28
- assert_equal(true, SteamId.cached?('koraktor'))
29
- sleep 1
30
- steam_id = SteamId.new('koraktor')
31
- assert_equal(fetch_time, steam_id.fetch_time)
32
- end
33
-
34
- def test_case_insensitivity
35
- SteamId.clear_cache
36
- steam_id = SteamId.new('koraktor', false)
37
- steam_id2 = SteamId.new('Koraktor', false)
38
- steam_id3 = SteamId.new('KORAKTOR', false)
39
- assert_equal(true, SteamId.cached?('koraktor'))
40
- assert_equal(steam_id, steam_id2)
41
- assert_equal(steam_id, steam_id3)
42
- end
43
-
44
- def test_convert_steam_id_to_community_id
45
- steam_id64 = SteamId.convert_steam_id_to_community_id('STEAM_0:0:12345')
46
- assert_equal(76561197960290418, steam_id64)
47
- end
48
-
49
- end
@@ -1,45 +0,0 @@
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) 2008-2011, Sebastian Staudt
5
-
6
- require 'test/unit'
7
-
8
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
9
-
10
- require 'steam/community/steam_id'
11
-
12
- class SteamCommunityTests < Test::Unit::TestCase
13
-
14
- def test_group_by_custom_url
15
- group = SteamGroup.new('valve')
16
- p group.member_count
17
- end
18
-
19
- def test_group_by_groupid_64
20
- group = SteamGroup.new(103582791429521412)
21
- p group.member_count
22
- end
23
-
24
- # This test tries to aquire information from a online Steam ID by using the
25
- # custom URL. This test only passes if the parsing of the XML document works
26
- def test_steam_id_by_custom_url
27
- assert_nothing_raised do
28
- steam_id = SteamId.new('koraktor')
29
- p steam_id
30
- p steam_id.game_stats('tf2')
31
- end
32
- end
33
-
34
- # This test tries to aquire information from a online Steam ID by using the
35
- # 64bit numeric SteamID. This test only passes if the parsing of the XML
36
- # document works
37
- def test_steam_id_by_steamid_64
38
- assert_nothing_raised do
39
- steam_id = SteamId.new(76561197961384956)
40
- p steam_id
41
- p steam_id.game_stats('tf2')
42
- end
43
- end
44
-
45
- end
@@ -1,77 +0,0 @@
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) 2009-2011, Sebastian Staudt
5
-
6
- require 'test/unit'
7
-
8
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
9
-
10
- require 'core_ext/stringio'
11
-
12
- class StringIOTests < Test::Unit::TestCase
13
-
14
- def test_allocate
15
- buffer = StringIO.alloc 10
16
- assert_equal("\0" * 10, buffer.string)
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.cstring)
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.string)
59
- buffer = StringIO.alloc 4
60
- buffer.write('test')
61
- assert_equal('test', buffer.string)
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.string)
75
- end
76
-
77
- end