steam-condenser 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,13 +9,15 @@ Currently it is implemented in Java, PHP and Ruby.
9
9
 
10
10
  * Linux, MacOS X or Windows
11
11
  * Ruby 1.8.6 or newer
12
- * [Ruby BZ2 module](http://www.rubyforge.org/projects/bz2)
12
+
13
+ The following gems are required:
14
+ * `bzip2-ruby` (for Source servers sending compressed responses)
13
15
 
14
16
  ## License
15
17
 
16
18
  This code is free software; you can redistribute it and/or modify it under the
17
- terms of the new BSD License. A copy of this license can be found in the LICENSE
18
- file.
19
+ terms of the new BSD License. A copy of this license can be found in the
20
+ included LICENSE file.
19
21
 
20
22
  ## Credits
21
23
 
@@ -29,4 +31,5 @@ file.
29
31
  * [Google group](http://groups.google.com/group/steam-condenser)
30
32
  * [Ohloh profile](http://www.ohloh.net/projects/steam-condenser)
31
33
 
32
- Follow Steam Condenser on Twitter [@steamcondenser](http://twitter.com/steamcondenser).
34
+ Follow Steam Condenser on Twitter
35
+ [@steamcondenser](http://twitter.com/steamcondenser).
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
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
5
 
6
6
  require 'rake/rdoctask'
7
7
  require 'rake/gempackagetask'
@@ -23,13 +23,15 @@ Jeweler::Tasks.new do |s|
23
23
 
24
24
  s.files = %w(README.md Rakefile LICENSE VERSION.yml) + src_files + test_files
25
25
  s.rdoc_options = ["--all", "--inline-source", "--line-numbers", "--charset=utf-8", "--webcvs=http://github.com/koraktor/steam-condenser/source/blob/master/ruby/%s"]
26
+
27
+ s.add_dependency('bzip2-ruby', '>= 0.2')
26
28
  end
27
29
 
28
30
  # Create a rake task +:rdoc+ to build the documentation
29
31
  desc "Building docs"
30
32
  Rake::RDocTask.new do |rdoc|
31
33
  rdoc.title = "Steam Condenser documentation"
32
- rdoc.rdoc_files.include ["lib/**/*.rb", "test/**/*.rb", "LICENSE", "README.md"]
34
+ rdoc.rdoc_files.include ["lib/**/*.rb", "LICENSE", "README.md"]
33
35
  rdoc.main = "README.md"
34
36
  rdoc.rdoc_dir = "rdoc"
35
37
  rdoc.options = ["--all", "--inline-source", "--line-numbers", "--charset=utf-8", "--webcvs=http://github.com/koraktor/steam-condenser/blob/master/ruby/%s"]
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 11
4
- :patch: 1
4
+ :patch: 2
@@ -1,16 +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
5
-
6
- require 'yaml'
7
-
8
- libdir = File.dirname(__FILE__)
9
- $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
10
5
 
11
6
  module SteamCondenser
12
7
 
13
- version = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'VERSION.yml'))
14
- VERSION = "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
8
+ require 'steam-condenser/community'
9
+ require 'steam-condenser/servers'
10
+ require 'steam-condenser/version'
15
11
 
16
12
  end
@@ -0,0 +1,16 @@
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) 2010, Sebastian Staudt
5
+
6
+ module SteamCondenser
7
+
8
+ require 'steam-condenser/version'
9
+
10
+ module Community
11
+
12
+ require 'steam/community/steam_id'
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,18 @@
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) 2010, Sebastian Staudt
5
+
6
+ module SteamCondenser
7
+
8
+ require 'steam-condenser/version'
9
+
10
+ module Servers
11
+
12
+ require 'steam/servers/goldsrc_server'
13
+ require 'steam/servers/master_server'
14
+ require 'steam/servers/source_server'
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,13 @@
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) 2010, Sebastian Staudt
5
+
6
+ require 'yaml'
7
+
8
+ module SteamCondenser
9
+
10
+ version = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'VERSION.yml'))
11
+ VERSION = "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
12
+
13
+ end
@@ -1,26 +1,30 @@
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
5
 
6
6
  # The GameAchievement class represents a specific achievement for a single game
7
7
  # and for a single user
8
8
  class GameAchievement
9
9
 
10
- attr_reader :app_id, :name, :steam_id
11
-
12
- # Creates the achievement with the given name for the given user and game and
13
- # marks it as already done if set to true
14
- def initialize(steam_id, app_id, name, done)
15
- @app_id = app_id
16
- @done = done
17
- @name = name
18
- @steam_id = steam_id
10
+ attr_reader :app_id, :name, :steam_id64, :timestamp
11
+
12
+ # Creates the achievement with the given name for the given user and game
13
+ # and achievement data
14
+ def initialize(steam_id64, app_id, achievement_data)
15
+ @app_id = app_id
16
+ @name = achievement_data.elements['name'].text
17
+ @steam_id64 = steam_id64
18
+ @unlocked = (achievement_data.attributes['closed'].to_i == 1)
19
+
20
+ if @unlocked && !achievement_data.elements['unlockTimestamp'].nil?
21
+ @timestamp = Time.at(achievement_data.elements['unlockTimestamp'].text.to_i)
22
+ end
19
23
  end
20
-
21
- # Returns whether this achievement has been done by its owner
22
- def done?
23
- @done
24
+
25
+ # Returns whether this achievement has been unlocked by its owner
26
+ def unlocked?
27
+ @unlocked
24
28
  end
25
-
29
+
26
30
  end
@@ -59,11 +59,11 @@ class GameStats
59
59
 
60
60
  @privacy_state = @xml_data.elements['privacyState'].text
61
61
  if public?
62
- @app_id = @xml_data.elements['game/gameLink'].text.match(/http:\/\/store.steampowered.com\/app\/([1-9][0-9]+)/)[1]
63
- @custom_url = @xml_data.elements['player/customURL'].text if @custom_url.nil?
64
- @game_name = @xml_data.elements['game/gameName'].text
65
- @hours_played = @xml_data.elements['stats/hoursPlayed'].text
66
- @steam_id64 = @xml_data.elements['player/steamID64'].text.to_i if @steam_id64.nil?
62
+ @app_id = @xml_data.elements['game/gameLink'].text.match(/http:\/\/store.steampowered.com\/app\/([1-9][0-9]+)/)[1]
63
+ @custom_url = @xml_data.elements['player/customURL'].text if @custom_url.nil?
64
+ @game_name = @xml_data.elements['game/gameName'].text
65
+ @hours_played = @xml_data.elements['stats/hoursPlayed'].text
66
+ @steam_id64 = @xml_data.elements['player/steamID64'].text.to_i if @steam_id64.nil?
67
67
  end
68
68
  end
69
69
 
@@ -74,11 +74,11 @@ class GameStats
74
74
 
75
75
  if @achievements.nil?
76
76
  @achievements = Array.new
77
- @xml_data.elements.each('achievements/achievement') do |achievement|
78
- @achievements << GameAchievement.new(@steam_id, @app_id, achievement.elements['name'].text, (achievement.attributes['closed'].to_i == 1))
77
+ @xml_data.elements.each('achievements/achievement') do |achievement_data|
78
+ @achievements << GameAchievement.new(@steam_id64, @app_id, achievement_data)
79
79
  end
80
80
 
81
- @achievements_done = @achievements.reject{ |a| !a.done? }.size
81
+ @achievements_done = @achievements.reject{ |a| !a.unlocked? }.size
82
82
  end
83
83
 
84
84
  @achievements
@@ -92,7 +92,7 @@ class GameStats
92
92
  end
93
93
 
94
94
  # Returns a float value representing the percentage of achievements done by
95
- # this player.
95
+ # this player. If achievements haven't been parsed yet, parsing is done now.
96
96
  def achievements_percentage
97
97
  achievements_done.to_f / @achievements.size
98
98
  end
@@ -12,7 +12,7 @@ class RCONExecResponse < RCONPacket
12
12
  end
13
13
 
14
14
  def response
15
- @content_data.data[0..-3]
15
+ @content_data.string[0..-3]
16
16
  end
17
17
 
18
18
  end
@@ -12,7 +12,7 @@ class RCONGoldSrcRequest < SteamPacket
12
12
  end
13
13
 
14
14
  def to_s
15
- [0xFFFFFFFF, @content_data.data].pack('Va*')
15
+ [0xFFFFFFFF, @content_data.string].pack('Va*')
16
16
  end
17
17
 
18
18
  end
@@ -12,7 +12,7 @@ class RCONGoldSrcResponse < SteamPacket
12
12
  end
13
13
 
14
14
  def response
15
- @content_data.data[0..-3]
15
+ @content_data.string[0..-3]
16
16
  end
17
17
 
18
18
  end
@@ -24,7 +24,7 @@ class RCONPacket < SteamPacket
24
24
  end
25
25
 
26
26
  def bytes
27
- [@content_data.length + 8, @request_id, @header_data, @content_data.data].pack('V3a*')
27
+ [@content_data.length + 8, @request_id, @header_data, @content_data.string].pack('V3a*')
28
28
  end
29
29
 
30
30
  end
@@ -20,7 +20,7 @@ class RCONPacketFactory < SteamPacketFactory
20
20
  byte_buffer.long
21
21
  request_id = byte_buffer.long
22
22
  header = byte_buffer.long
23
- data = byte_buffer.string
23
+ data = byte_buffer.cstring
24
24
 
25
25
  case header
26
26
  when RCONPacket::SERVERDATA_AUTH_RESPONSE then
@@ -8,7 +8,7 @@ module RequestWithChallenge
8
8
 
9
9
  # Returns a packed version of the request
10
10
  def to_s
11
- [0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.data.to_i].pack('c5l')
11
+ [0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.string.to_i].pack('c5l')
12
12
  end
13
13
 
14
14
  end
@@ -14,10 +14,10 @@ class S2A_INFO2_Packet < S2A_INFO_BasePacket
14
14
  super SteamPacket::S2A_INFO2_HEADER, data
15
15
 
16
16
  @protocol_version = @content_data.byte
17
- @server_name = @content_data.string
18
- @map_name = @content_data.string
19
- @game_directory = @content_data.string
20
- @game_description = @content_data.string
17
+ @server_name = @content_data.cstring
18
+ @map_name = @content_data.cstring
19
+ @game_directory = @content_data.cstring
20
+ @game_description = @content_data.cstring
21
21
  @app_id = @content_data.short
22
22
  @number_of_players = @content_data.byte
23
23
  @max_players = @content_data.byte
@@ -26,7 +26,7 @@ class S2A_INFO2_Packet < S2A_INFO_BasePacket
26
26
  @operating_system = @content_data.byte.chr
27
27
  @password_needed = @content_data.byte == 1
28
28
  @secure = @content_data.byte == 1
29
- @game_version = @content_data.string
29
+ @game_version = @content_data.cstring
30
30
  extra_data_flag = @content_data.byte
31
31
 
32
32
  @server_port = @content_data.short unless extra_data_flag & 0x80 == 0
@@ -37,10 +37,10 @@ class S2A_INFO2_Packet < S2A_INFO_BasePacket
37
37
 
38
38
  unless extra_data_flag & 0x40 == 0
39
39
  @tv_port = @content_data.short
40
- @tv_name = @content_data.string
40
+ @tv_name = @content_data.cstring
41
41
  end
42
42
 
43
- @server_tags = @content_data.string unless extra_data_flag & 0x20 == 0
43
+ @server_tags = @content_data.cstring unless extra_data_flag & 0x20 == 0
44
44
 
45
45
  generate_info_hash
46
46
  end
@@ -15,11 +15,11 @@ class S2A_INFO_DETAILED_Packet < S2A_INFO_BasePacket
15
15
  def initialize(data)
16
16
  super SteamPacket::S2A_INFO_DETAILED_HEADER, data
17
17
 
18
- @game_ip = @content_data.string
19
- @server_name = @content_data.string
20
- @map_name = @content_data.string
21
- @game_directory = @content_data.string
22
- @game_description = @content_data.string
18
+ @game_ip = @content_data.cstring
19
+ @server_name = @content_data.cstring
20
+ @map_name = @content_data.cstring
21
+ @game_directory = @content_data.cstring
22
+ @game_description = @content_data.cstring
23
23
  @number_of_players = @content_data.byte
24
24
  @max_players = @content_data.byte
25
25
  @network_version = @content_data.byte
@@ -30,8 +30,8 @@ class S2A_INFO_DETAILED_Packet < S2A_INFO_BasePacket
30
30
 
31
31
  if @is_mod
32
32
  @mod_info = {}
33
- @mod_info['url_info'] = @content_data.string
34
- @mod_info['url_dl'] = @content_data.string
33
+ @mod_info['url_info'] = @content_data.cstring
34
+ @mod_info['url_dl'] = @content_data.cstring
35
35
  @content_data.byte
36
36
  if @content_data.remaining == 12
37
37
  @mod_info['mod_version'] = @content_data.long
@@ -22,7 +22,7 @@ class S2A_PLAYER_Packet < SteamPacket
22
22
  @player_hash = {}
23
23
 
24
24
  while @content_data.remaining > 0
25
- player_data = @content_data.byte, @content_data.string, @content_data.signed_long, @content_data.float
25
+ player_data = @content_data.byte, @content_data.cstring, @content_data.signed_long, @content_data.float
26
26
  @player_hash[player_data[1]] = SteamPlayer.new(*player_data[0..3])
27
27
  end
28
28
  end
@@ -22,8 +22,8 @@ class S2A_RULES_Packet < SteamPacket
22
22
  @rules_hash = {}
23
23
 
24
24
  rules_count.times do
25
- rule = @content_data.string
26
- value = @content_data.string
25
+ rule = @content_data.cstring
26
+ value = @content_data.cstring
27
27
 
28
28
  # This is a workaround for servers sending corrupt replies
29
29
  break if rule.empty? or value.empty?
@@ -34,7 +34,7 @@ class SteamPacket
34
34
 
35
35
  # Returns a packed string representing the packet's data
36
36
  def to_s
37
- [0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.data].pack('c5a*')
37
+ [0xFF, 0xFF, 0xFF, 0xFF, @header_data, @content_data.string].pack('c5a*')
38
38
  end
39
39
 
40
40
  end
@@ -8,7 +8,7 @@ require 'steam/sockets/master_server_socket'
8
8
 
9
9
  class MasterServer
10
10
 
11
- GOLDSRC_MASTER_SERVER = 'hl1master.steampowered.com', 27013
11
+ GOLDSRC_MASTER_SERVER = 'hl1master.steampowered.com', 27010
12
12
  SOURCE_MASTER_SERVER = 'hl2master.steampowered.com', 27011
13
13
 
14
14
  REGION_US_EAST_COAST = 0x00
@@ -7,8 +7,6 @@ require 'stringio'
7
7
 
8
8
  class StringIO
9
9
 
10
- alias_method :data, :string
11
-
12
10
  def self.allocate(size)
13
11
  new "\0" * size
14
12
  end
@@ -41,7 +39,7 @@ class StringIO
41
39
  read(4).unpack('l')[0]
42
40
  end
43
41
 
44
- def string
42
+ def cstring
45
43
  gets("\0")[0..-2]
46
44
  end
47
45
 
@@ -33,7 +33,7 @@ class DatagramChannelTests < Test::Unit::TestCase
33
33
  channel.close
34
34
  socket.close
35
35
 
36
- received = buffer.data
36
+ received = buffer.string
37
37
 
38
38
  assert_equal(string, sent)
39
39
  assert_equal(string, received)
@@ -34,7 +34,7 @@ class SocketChannelTests < Test::Unit::TestCase
34
34
  channel.close
35
35
  socket.close
36
36
 
37
- received = buffer.data
37
+ received = buffer.string
38
38
 
39
39
  assert_equal(string, sent)
40
40
  assert_equal(string, received)
@@ -13,7 +13,7 @@ class StringIOAdditionsTests < Test::Unit::TestCase
13
13
 
14
14
  def test_allocate
15
15
  buffer = StringIO.allocate(10)
16
- assert_equal("\0" * 10, buffer.data)
16
+ assert_equal("\0" * 10, buffer.string)
17
17
  end
18
18
 
19
19
  def test_byte
@@ -48,17 +48,17 @@ class StringIOAdditionsTests < Test::Unit::TestCase
48
48
 
49
49
  def test_string
50
50
  buffer = StringIO.new("test\0test")
51
- assert_equal('test', buffer.string)
51
+ assert_equal('test', buffer.cstring)
52
52
  assert_equal(4, buffer.remaining)
53
53
  end
54
54
 
55
55
  def test_put
56
56
  buffer = StringIO.new('te')
57
57
  buffer.write('st')
58
- assert_equal('st', buffer.data)
58
+ assert_equal('st', buffer.string)
59
59
  buffer = StringIO.allocate(4)
60
60
  buffer.write('test')
61
- assert_equal('test', buffer.data)
61
+ assert_equal('test', buffer.string)
62
62
  end
63
63
 
64
64
  def test_rewind
@@ -71,7 +71,7 @@ class StringIOAdditionsTests < Test::Unit::TestCase
71
71
  def test_wrap
72
72
  string = 'test'
73
73
  buffer = StringIO.new(string)
74
- assert_equal(string, buffer.data)
74
+ assert_equal(string, buffer.string)
75
75
  end
76
76
 
77
77
  end
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: 49
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 1
10
- version: 0.11.1
9
+ - 2
10
+ version: 0.11.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sebastian Staudt
@@ -15,10 +15,24 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-05 00:00:00 +02:00
18
+ date: 2010-09-08 00:00:00 +02:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bzip2-ruby
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 0
32
+ - 2
33
+ version: "0.2"
34
+ type: :runtime
35
+ version_requirements: *id001
22
36
  description: A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers
23
37
  email: koraktor@gmail.com
24
38
  executables: []
@@ -41,6 +55,9 @@ files:
41
55
  - lib/exceptions/timeout_exception.rb
42
56
  - lib/socket_channel.rb
43
57
  - lib/steam-condenser.rb
58
+ - lib/steam-condenser/community.rb
59
+ - lib/steam-condenser/servers.rb
60
+ - lib/steam-condenser/version.rb
44
61
  - lib/steam/community/cacheable.rb
45
62
  - lib/steam/community/css/css_map.rb
46
63
  - lib/steam/community/css/css_stats.rb