steam-client 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/steam-client/client.rb +18 -4
- data/lib/steam-client/version.rb +1 -1
- metadata +3 -3
data/lib/steam-client/client.rb
CHANGED
@@ -12,19 +12,19 @@ module SteamClient
|
|
12
12
|
|
13
13
|
def find_profile_by_name(name)
|
14
14
|
url = "http://steamcommunity.com/id/#{name}?xml=1"
|
15
|
-
xml =
|
15
|
+
xml = get_with_retries url
|
16
16
|
return Profile.from_xml(xml)
|
17
17
|
end
|
18
18
|
|
19
19
|
def find_profile_by_id(id)
|
20
20
|
url = "http://steamcommunity.com/profiles/#{id}?xml=1"
|
21
|
-
xml =
|
21
|
+
xml = get_with_retries url
|
22
22
|
return Profile.from_xml(xml)
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_friends_from_profile(profile)
|
26
26
|
url = "http://steamcommunity.com/profiles/#{profile.steamID64}/friends?xml=1"
|
27
|
-
xml =
|
27
|
+
xml = get_with_retries url
|
28
28
|
hFriends = Crack::XML.parse xml
|
29
29
|
friends = []
|
30
30
|
hFriends['friendsList']['friends']['friend'].each do |friendID|
|
@@ -36,7 +36,7 @@ module SteamClient
|
|
36
36
|
|
37
37
|
def get_games_from_profile(profile)
|
38
38
|
url = "http://steamcommunity.com/profiles/#{profile.steamID64}/games\?xml\=1"
|
39
|
-
xml =
|
39
|
+
xml = get_with_retries url
|
40
40
|
hGames = Crack::XML.parse xml
|
41
41
|
games = []
|
42
42
|
hGames['gamesList']['games']['game'].each do |game|
|
@@ -45,5 +45,19 @@ module SteamClient
|
|
45
45
|
profile.games = games
|
46
46
|
return games
|
47
47
|
end
|
48
|
+
|
49
|
+
def get_with_retries(url, retries = 10)
|
50
|
+
attempt = 0
|
51
|
+
while attempt < retries
|
52
|
+
begin
|
53
|
+
resp = RestClient.get url
|
54
|
+
return resp
|
55
|
+
rescue RestClient::ServiceUnavailable
|
56
|
+
attempt += 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
throw new RestClient::ServiceUnavailable
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
data/lib/steam-client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steam-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Steam Client
|
15
15
|
email:
|
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
hash:
|
55
|
+
hash: 4571460617524873844
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|