Skip to content

Commit

Permalink
Merge branch '1.3-stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
koraktor committed Oct 27, 2013
2 parents f80cb00 + ca4ede4 commit c3a466a
Show file tree
Hide file tree
Showing 6 changed files with 342 additions and 255 deletions.
8 changes: 5 additions & 3 deletions lib/core_ext/stringio.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010-2011, Sebastian Staudt
# Copyright (c) 2010-2013, Sebastian Staudt

require 'stringio'

Expand Down Expand Up @@ -73,12 +73,14 @@ def signed_long
# Reads a zero-byte terminated string from the current position of the byte
# stream
#
# This reads the stream up until the first occurance of a zero-byte or the
# This reads the stream up until the first occurrence of a zero-byte or the
# end of the stream. The zero-byte is not included in the returned string.
#
# @return [String] The zero-byte terminated string read from the byte stream
def cstring
gets("\0")[0..-2]
string = gets("\0")[0..-2]
string.force_encoding 'UTF-8' if string.respond_to? :force_encoding
string
end

end
69 changes: 56 additions & 13 deletions lib/steam-condenser/community/steam_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SteamGroup

include XMLData

AVATAR_URL = 'http://media.steampowered.com/steamcommunity/public/images/avatars/%s/%s%s.jpg'

# Returns the custom URL of this group
#
# The custom URL is a admin specified unique string that can be used
Expand All @@ -33,6 +35,21 @@ class SteamGroup
# @return [Fixnum] This group's 64bit SteamID
attr_reader :group_id64

# Returns this group's headline text
#
# @return [String] This group's headline text
attr_reader :headline

# Returns this group's name
#
# @return [String] This group's name
attr_reader :name

# Returns this group's summary text
#
# @return [String] This group's summary text
attr_reader :summary

# Creates a new `SteamGroup` instance for the group with the given ID
#
# @param [String, Fixnum] id The custom URL of the group specified by the
Expand All @@ -47,6 +64,27 @@ def initialize(id)
@members = []
end

# Returns the URL to this group's full avatar
#
# @return [String] The URL to this group's full avatar
def avatar_full_url
AVATAR_URL % [ @avatar_hash[0..1], @avatar_hash, '_full' ]
end

# Returns the URL to this group's icon avatar
#
# @return [String] The URL to this group's icon avatar
def avatar_icon_url
AVATAR_URL % [ @avatar_hash[0..1], @avatar_hash, '' ]
end

# Returns the URL to this group's medium avatar
#
# @return [String] The URL to this group's medium avatar
def avatar_medium_url
AVATAR_URL % [ @avatar_hash[0..1], @avatar_hash, '_medium' ]
end

# Returns the base URL for this group's page
#
# This URL is different for groups having a custom URL.
Expand Down Expand Up @@ -114,22 +152,27 @@ def members
def fetch_page(page)
member_data = parse "#{base_url}/memberslistxml?p=#{page}"

begin
@group_id64 = member_data['groupID64'].to_i if page == 1
@member_count = member_data['memberCount'].to_i
total_pages = member_data['totalPages'].to_i

member_data['members']['steamID64'].each do |member|
@members << SteamId.new(member.to_i, false)
end

total_pages
rescue
raise $! if $!.is_a? SteamCondenser::Error
raise SteamCondenser::Error, 'XML data could not be parsed.'
@member_count = member_data['memberCount'].to_i
total_pages = member_data['totalPages'].to_i

if page == 1
member_data['groupDetails']['avatarIcon'] =~ /\/([0-9a-f]+)\.jpg$/
@avatar_hash = $1
@custom_url = member_data['groupDetails']['groupURL']
@group_id64 = member_data['groupID64'].to_i
@headline = member_data['groupDetails']['headline']
@name = member_data['groupDetails']['groupName']
@summary = member_data['groupDetails']['summary']
end

member_data['members']['steamID64'].each do |member|
@members << SteamId.new(member.to_i, false)
end

total_pages
rescue
raise $! if $!.is_a? SteamCondenser::Error
raise SteamCondenser::Error, 'XML data could not be parsed.'
end

end
Expand Down
1 change: 1 addition & 0 deletions lib/steam-condenser/community/steam_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright (c) 2008-2013, Sebastian Staudt

require 'cgi'
require 'time'

require 'steam-condenser/community/cacheable'
require 'steam-condenser/community/game_stats'
Expand Down
2 changes: 1 addition & 1 deletion lib/steam-condenser/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
module SteamCondenser

# The current version of Steam Condenser
VERSION = '1.3.7'
VERSION = '1.3.8'

end
Loading

0 comments on commit c3a466a

Please sign in to comment.