vapor 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Vapor
2
2
 
3
- TODO: Write a gem description
4
-
3
+ Vapor grants you an easy and straightforward access to Steam info.
5
4
  ## Installation
6
5
 
7
6
  Add this line to your application's Gemfile:
@@ -18,7 +17,17 @@ Or install it yourself as:
18
17
 
19
18
  ## Usage
20
19
 
21
- TODO: Write usage instructions here
20
+ ```ruby
21
+ Vapor::API.key = "MYSTEAMAPI"
22
+ Vapor::User.new('pedronascimento').games
23
+ #List of games
24
+ ```
25
+
26
+ ## Features/Problems
27
+
28
+ * It doesn't get lots of info, just the ones I need for now.
29
+ * It relies on the XML output on Steam, which is not reliable at all.
30
+ * It is way simples than steam-condenser.
22
31
 
23
32
  ## Contributing
24
33
 
data/lib/vapor/crawler.rb CHANGED
@@ -4,6 +4,11 @@ module Vapor
4
4
  def games_for(user)
5
5
  doc = fetch("#{user.profile_url}games")
6
6
  doc.gamesList.games.elements
7
+ rescue NoMethodError => e
8
+ if doc.gamesList.error.text =~ /profile is private/
9
+ raise UserPrivateError, user.steam_id
10
+ end
11
+ raise e
7
12
  end
8
13
  private
9
14
  def fetch(url)
@@ -14,4 +19,9 @@ module Vapor
14
19
  @client ||= HTTPClient.new
15
20
  end
16
21
  end
22
+ class UserPrivateError < RuntimeError
23
+ def initialize(username)
24
+ super("#{username} is private, cannot fetch games.")
25
+ end
26
+ end
17
27
  end
data/lib/vapor/user.rb CHANGED
@@ -5,6 +5,10 @@ module Vapor
5
5
  attr_reader :steam_id
6
6
 
7
7
  def initialize(steam_id)
8
+ if steam_id =~ /steamcommunity\.com/
9
+ steam_id = steam_id.match(/\/id\/(\w+)/)[1]
10
+ end
11
+ raise(InvalidUsernameError, steam_id) if steam_id =~ / /
8
12
  if steam_id.is_a? Integer || steam_id =~ /\A\d+\Z/
9
13
  @steam_id = steam_id
10
14
  else
@@ -30,11 +34,26 @@ module Vapor
30
34
  def fetch_real_id(username)
31
35
  user_page = client.get("http://steamcommunity.com/id/#{username}?xml=1")
32
36
  raise APINotAvailableError if user_page.status == 503
33
- REXML::Document.new(user_page.body).elements['profile/steamID64'].text
37
+ if id = REXML::Document.new(user_page.body).elements['profile/steamID64']
38
+ id.text
39
+ else
40
+ raise UserNotFoundError, username
41
+ end
34
42
  end
35
43
 
36
44
  def client
37
45
  Vapor.api.client
38
46
  end
39
47
  end
48
+
49
+ class UserNotFoundError < RuntimeError
50
+ def initialize(username)
51
+ super("#{username} does not appear to be a valid Steam ID.")
52
+ end
53
+ end
54
+ class InvalidUsernameError < RuntimeError
55
+ def initialize(username)
56
+ super("#{username} is an invalid username.")
57
+ end
58
+ end
40
59
  end
data/lib/vapor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vapor
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,142 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://steamcommunity.com/id/ggleytonb?xml=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: !binary |-
14
+ T0s=
15
+ headers:
16
+ !binary "U2VydmVy":
17
+ - !binary |-
18
+ QXBhY2hl
19
+ !binary "U2V0LUNvb2tpZQ==":
20
+ - !binary |-
21
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1Nb24sIDE4LURlYy0y
22
+ MDE3IDIwOjA3OjI3IEdNVDsgcGF0aD0v
23
+ - !binary |-
24
+ c2Vzc2lvbmlkPU1qQTFNRGcwTXpVNU1nJTNEJTNEOyBwYXRoPS8=
25
+ !binary "RXhwaXJlcw==":
26
+ - !binary |-
27
+ V2VkLCAxOSBEZWMgMjAxMiAyMTowNzoyNyBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ dGV4dC94bWw7IGNoYXJzZXQ9dXRmLTg=
31
+ !binary "Q29udGVudC1MZW5ndGg=":
32
+ - !binary |-
33
+ OTA3
34
+ !binary "RGF0ZQ==":
35
+ - !binary |-
36
+ V2VkLCAxOSBEZWMgMjAxMiAyMDowNzoyOCBHTVQ=
37
+ !binary "WC1WYXJuaXNo":
38
+ - !binary |-
39
+ MTk5ODk0NDU0NQ==
40
+ !binary "QWdl":
41
+ - !binary |-
42
+ MA==
43
+ !binary "Vmlh":
44
+ - !binary |-
45
+ MS4xIHZhcm5pc2g=
46
+ !binary "Q29ubmVjdGlvbg==":
47
+ - !binary |-
48
+ a2VlcC1hbGl2ZQ==
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><profile>\r\n\t<steamID64>76561198030421261</steamID64>\r\n\t<steamID><![CDATA[Gustavo]]></steamID>\r\n\t<onlineState>offline</onlineState>\r\n\t<stateMessage><![CDATA[]]></stateMessage>\r\n\t<privacyState>friendsonly</privacyState>\r\n\t<visibilityState>1</visibilityState>\r\n\t<avatarIcon><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12.jpg]]></avatarIcon>\r\n\t<avatarMedium><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12_medium.jpg]]></avatarMedium>\r\n\t<avatarFull><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12_full.jpg]]></avatarFull>\r\n\t<vacBanned>0</vacBanned>\r\n\t<tradeBanState>None</tradeBanState>\r\n\t<isLimitedAccount>0</isLimitedAccount>\r\n</profile>"
52
+ http_version:
53
+ recorded_at: Wed, 19 Dec 2012 20:07:28 GMT
54
+ - request:
55
+ method: get
56
+ uri: http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=8BDCBAAA1E46E207931AA2950110AEB2&steamids=76561198030421261
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers: {}
61
+ response:
62
+ status:
63
+ code: 200
64
+ message: !binary |-
65
+ T0s=
66
+ headers:
67
+ !binary "RGF0ZQ==":
68
+ - !binary |-
69
+ V2VkLCAxOSBEZWMgMjAxMiAyMDowNzo0NSBHTVQ=
70
+ !binary "RXhwaXJlcw==":
71
+ - !binary |-
72
+ V2VkLCAxOSBEZWMgMjAxMiAyMDowNzo0NSBHTVQ=
73
+ !binary "Q29udGVudC1UeXBl":
74
+ - !binary |-
75
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD1VVEYtOA==
76
+ !binary "Q29udGVudC1MZW5ndGg=":
77
+ - !binary |-
78
+ NzA4
79
+ body:
80
+ encoding: US-ASCII
81
+ string: ! "{\n\t\"response\": {\n\t\t\"players\": [\n\t\t\t{\n\t\t\t\t\"steamid\":
82
+ \"76561198030421261\",\n\t\t\t\t\"communityvisibilitystate\": 2,\n\t\t\t\t\"profilestate\":
83
+ 1,\n\t\t\t\t\"personaname\": \"Gustavo\",\n\t\t\t\t\"lastlogoff\": 1355936075,\n\t\t\t\t\"profileurl\":
84
+ \"http://steamcommunity.com/id/ggleytonb/\",\n\t\t\t\t\"avatar\": \"http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12.jpg\",\n\t\t\t\t\"avatarmedium\":
85
+ \"http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12_medium.jpg\",\n\t\t\t\t\"avatarfull\":
86
+ \"http://media.steampowered.com/steamcommunity/public/images/avatars/54/541927c4a76189cd1011df286a31601b12ce3f12_full.jpg\",\n\t\t\t\t\"personastate\":
87
+ 0\n\t\t\t}\n\t\t]\n\t\t\n\t}\n}"
88
+ http_version:
89
+ recorded_at: Wed, 19 Dec 2012 20:07:28 GMT
90
+ - request:
91
+ method: get
92
+ uri: http://steamcommunity.com/id/ggleytonb/games?xml=1
93
+ body:
94
+ encoding: US-ASCII
95
+ string: ''
96
+ headers: {}
97
+ response:
98
+ status:
99
+ code: 200
100
+ message: !binary |-
101
+ T0s=
102
+ headers:
103
+ !binary "U2VydmVy":
104
+ - !binary |-
105
+ QXBhY2hl
106
+ !binary "U2V0LUNvb2tpZQ==":
107
+ - !binary |-
108
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1Nb24sIDE4LURlYy0y
109
+ MDE3IDIwOjA3OjI5IEdNVDsgcGF0aD0v
110
+ - !binary |-
111
+ c2Vzc2lvbmlkPU5ESXlNelEyTlRBNDsgcGF0aD0v
112
+ !binary "RXhwaXJlcw==":
113
+ - !binary |-
114
+ V2VkLCAxOSBEZWMgMjAxMiAyMTowNzoyOSBHTVQ=
115
+ !binary "Q29udGVudC1UeXBl":
116
+ - !binary |-
117
+ dGV4dC94bWw=
118
+ !binary "Q29udGVudC1MZW5ndGg=":
119
+ - !binary |-
120
+ MjIw
121
+ !binary "RGF0ZQ==":
122
+ - !binary |-
123
+ V2VkLCAxOSBEZWMgMjAxMiAyMDowNzozMCBHTVQ=
124
+ !binary "WC1WYXJuaXNo":
125
+ - !binary |-
126
+ MjE3NzIzNDUwOQ==
127
+ !binary "QWdl":
128
+ - !binary |-
129
+ MA==
130
+ !binary "Vmlh":
131
+ - !binary |-
132
+ MS4xIHZhcm5pc2g=
133
+ !binary "Q29ubmVjdGlvbg==":
134
+ - !binary |-
135
+ a2VlcC1hbGl2ZQ==
136
+ body:
137
+ encoding: US-ASCII
138
+ string: ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><gamesList>\r\n\t<steamID64>76561198030421261</steamID64>\r\n\t<steamID><![CDATA[Gustavo]]></steamID>\r\n\t<error><![CDATA[This
139
+ profile is private.]]></error>\r\n</gamesList>\r\n"
140
+ http_version:
141
+ recorded_at: Wed, 19 Dec 2012 20:07:30 GMT
142
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://steamcommunity.com/id/http://steamcommunity.com/id/pedronascimento?xml=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: !binary |-
14
+ T0s=
15
+ headers:
16
+ !binary "U2VydmVy":
17
+ - !binary |-
18
+ QXBhY2hl
19
+ !binary "U2V0LUNvb2tpZQ==":
20
+ - !binary |-
21
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1Nb24sIDE4LURlYy0y
22
+ MDE3IDIwOjIyOjA5IEdNVDsgcGF0aD0v
23
+ - !binary |-
24
+ c2Vzc2lvbmlkPU16RTFNVE0xT1RrMDsgcGF0aD0v
25
+ !binary "RXhwaXJlcw==":
26
+ - !binary |-
27
+ V2VkLCAxOSBEZWMgMjAxMiAyMToyMjowOSBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ dGV4dC94bWw=
31
+ !binary "Q29udGVudC1MZW5ndGg=":
32
+ - !binary |-
33
+ MTQ0
34
+ !binary "RGF0ZQ==":
35
+ - !binary |-
36
+ V2VkLCAxOSBEZWMgMjAxMiAyMDoyMjoxMCBHTVQ=
37
+ !binary "WC1WYXJuaXNo":
38
+ - !binary |-
39
+ MjE3OTQwOTM3OQ==
40
+ !binary "QWdl":
41
+ - !binary |-
42
+ MA==
43
+ !binary "Vmlh":
44
+ - !binary |-
45
+ MS4xIHZhcm5pc2g=
46
+ !binary "Q29ubmVjdGlvbg==":
47
+ - !binary |-
48
+ a2VlcC1hbGl2ZQ==
49
+ body:
50
+ encoding: US-ASCII
51
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><error><![CDATA[The
52
+ specified profile could not be found.]]></error></response>
53
+ http_version:
54
+ recorded_at: Wed, 19 Dec 2012 20:22:12 GMT
55
+ - request:
56
+ method: get
57
+ uri: http://steamcommunity.com/id/pedronascimento?xml=1
58
+ body:
59
+ encoding: US-ASCII
60
+ string: ''
61
+ headers: {}
62
+ response:
63
+ status:
64
+ code: 200
65
+ message: !binary |-
66
+ T0s=
67
+ headers:
68
+ !binary "U2VydmVy":
69
+ - !binary |-
70
+ QXBhY2hl
71
+ !binary "U2V0LUNvb2tpZQ==":
72
+ - !binary |-
73
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1UdWUsIDE5LURlYy0y
74
+ MDE3IDE2OjE1OjE0IEdNVDsgcGF0aD0v
75
+ - !binary |-
76
+ c2Vzc2lvbmlkPU9EWTVOamd5T0RVMjsgcGF0aD0v
77
+ !binary "RXhwaXJlcw==":
78
+ - !binary |-
79
+ VGh1LCAyMCBEZWMgMjAxMiAxNzoxNToxNCBHTVQ=
80
+ !binary "Q29udGVudC1UeXBl":
81
+ - !binary |-
82
+ dGV4dC94bWw7IGNoYXJzZXQ9dXRmLTg=
83
+ !binary "Q29udGVudC1MZW5ndGg=":
84
+ - !binary |-
85
+ MjkwMA==
86
+ !binary "RGF0ZQ==":
87
+ - !binary |-
88
+ VGh1LCAyMCBEZWMgMjAxMiAxNjoxNToxNSBHTVQ=
89
+ !binary "WC1WYXJuaXNo":
90
+ - !binary |-
91
+ MjExOTcyMTI3MA==
92
+ !binary "QWdl":
93
+ - !binary |-
94
+ MA==
95
+ !binary "Vmlh":
96
+ - !binary |-
97
+ MS4xIHZhcm5pc2g=
98
+ !binary "Q29ubmVjdGlvbg==":
99
+ - !binary |-
100
+ a2VlcC1hbGl2ZQ==
101
+ body:
102
+ encoding: US-ASCII
103
+ string: ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><profile>\r\n\t<steamID64>76561198021477729</steamID64>\r\n\t<steamID><![CDATA[Lunks]]></steamID>\r\n\t<onlineState>online</onlineState>\r\n\t<stateMessage><![CDATA[Online]]></stateMessage>\r\n\t<privacyState>public</privacyState>\r\n\t<visibilityState>3</visibilityState>\r\n\t<avatarIcon><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/ac/acacd3fbbe1c9a38037575113f58d18981ed55eb.jpg]]></avatarIcon>\r\n\t<avatarMedium><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/ac/acacd3fbbe1c9a38037575113f58d18981ed55eb_medium.jpg]]></avatarMedium>\r\n\t<avatarFull><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/ac/acacd3fbbe1c9a38037575113f58d18981ed55eb_full.jpg]]></avatarFull>\r\n\t<vacBanned>0</vacBanned>\r\n\t<tradeBanState>None</tradeBanState>\r\n\t<isLimitedAccount>0</isLimitedAccount>\r\n\t<customURL><![CDATA[pedronascimento]]></customURL>\r\n\t<memberSince>February
104
+ 21, 2010</memberSince>\r\n\t<steamRating>3.5</steamRating>\r\n\t<hoursPlayed2Wk>11.2</hoursPlayed2Wk>\r\n\t<headline><![CDATA[]]></headline>\r\n\t<location><![CDATA[Brazil]]></location>\r\n\t<realname><![CDATA[]]></realname>\r\n\t<summary><![CDATA[No
105
+ information given.]]></summary>\r\n \t<mostPlayedGames>\r\n\t\t<mostPlayedGame>\r\n\t\t\t<gameName><![CDATA[Dota
106
+ 2]]></gameName>\r\n\t\t\t<gameLink><![CDATA[http://steamcommunity.com/app/570]]></gameLink>\r\n\t\t\t<gameIcon><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/570/0bbb630d63262dd66d2fdd0f7d37e8661a410075.jpg]]></gameIcon>\r\n\t\t\t<gameLogo><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/570/d4f836839254be08d8e9dd333ecc9a01782c26d2.jpg]]></gameLogo>\r\n\t\t\t<gameLogoSmall><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/570/d4f836839254be08d8e9dd333ecc9a01782c26d2_thumb.jpg]]></gameLogoSmall>\r\n\t\t\t<hoursPlayed>9.5</hoursPlayed>\r\n\t\t\t<hoursOnRecord>68.5</hoursOnRecord>\r\n\t\t</mostPlayedGame>\r\n\t\t<mostPlayedGame>\r\n\t\t\t<gameName><![CDATA[Awesomenauts]]></gameName>\r\n\t\t\t<gameLink><![CDATA[http://steamcommunity.com/app/204300]]></gameLink>\r\n\t\t\t<gameIcon><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/204300/4996933171d0804bd0ceb7b9a0e224b3139d18ba.jpg]]></gameIcon>\r\n\t\t\t<gameLogo><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/204300/a2eba6157703c60bfcc199f06df5f1568c9835bb.jpg]]></gameLogo>\r\n\t\t\t<gameLogoSmall><![CDATA[http://media.steampowered.com/steamcommunity/public/images/apps/204300/a2eba6157703c60bfcc199f06df5f1568c9835bb_thumb.jpg]]></gameLogoSmall>\r\n\t\t\t<hoursPlayed>1.8</hoursPlayed>\r\n\t\t\t<hoursOnRecord>1.8</hoursOnRecord>\r\n\t\t\t<statsName><![CDATA[204300]]></statsName>\r\n\t\t</mostPlayedGame>\r\n\t</mostPlayedGames>\r\n\r\n\r\n\t<weblinks>\r\n\t\t<weblink>\r\n\t\t\t<link><![CDATA[http://twitter.com/lunks/]]></link>\r\n\t\t\t<title><![CDATA[Twitter]]></title>\r\n\t\t</weblink>\r\n\t</weblinks>\r\n\r\n</profile>"
107
+ http_version:
108
+ recorded_at: Thu, 20 Dec 2012 16:15:15 GMT
109
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://steamcommunity.com/id/amaekjlkj?xml=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ Date:
13
+ - Wed, 19 Dec 2012 19:43:01 GMT
14
+ Host:
15
+ - steamcommunity.com
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "U2VydmVy":
23
+ - !binary |-
24
+ QXBhY2hl
25
+ !binary "U2V0LUNvb2tpZQ==":
26
+ - !binary |-
27
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1Nb24sIDE4LURlYy0y
28
+ MDE3IDE5OjQzOjA0IEdNVDsgcGF0aD0v
29
+ - !binary |-
30
+ c2Vzc2lvbmlkPU9UTTBNREl3T0RNejsgcGF0aD0v
31
+ !binary "RXhwaXJlcw==":
32
+ - !binary |-
33
+ V2VkLCAxOSBEZWMgMjAxMiAyMDo0MzowNCBHTVQ=
34
+ !binary "Q29udGVudC1UeXBl":
35
+ - !binary |-
36
+ dGV4dC94bWw=
37
+ !binary "Q29udGVudC1MZW5ndGg=":
38
+ - !binary |-
39
+ MTQ0
40
+ !binary "RGF0ZQ==":
41
+ - !binary |-
42
+ V2VkLCAxOSBEZWMgMjAxMiAxOTo0MzowNCBHTVQ=
43
+ !binary "WC1WYXJuaXNo":
44
+ - !binary |-
45
+ MTk5NTUxNDIzNA==
46
+ !binary "QWdl":
47
+ - !binary |-
48
+ MA==
49
+ !binary "Vmlh":
50
+ - !binary |-
51
+ MS4xIHZhcm5pc2g=
52
+ !binary "Q29ubmVjdGlvbg==":
53
+ - !binary |-
54
+ a2VlcC1hbGl2ZQ==
55
+ body:
56
+ encoding: US-ASCII
57
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><error><![CDATA[The
58
+ specified profile could not be found.]]></error></response>
59
+ http_version:
60
+ recorded_at: Wed, 19 Dec 2012 19:43:05 GMT
61
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://steamcommunity.com/id/iafjflkjalkfjlk?xml=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: !binary |-
14
+ T0s=
15
+ headers:
16
+ !binary "U2VydmVy":
17
+ - !binary |-
18
+ QXBhY2hl
19
+ !binary "U2V0LUNvb2tpZQ==":
20
+ - !binary |-
21
+ U3RlYW1fTGFuZ3VhZ2U9ZW5nbGlzaDsgZXhwaXJlcz1Nb24sIDE4LURlYy0y
22
+ MDE3IDE5OjUwOjA5IEdNVDsgcGF0aD0v
23
+ - !binary |-
24
+ c2Vzc2lvbmlkPU9ETXpOVEF6TXpjNDsgcGF0aD0v
25
+ !binary "RXhwaXJlcw==":
26
+ - !binary |-
27
+ V2VkLCAxOSBEZWMgMjAxMiAyMDo1MDowOSBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ dGV4dC94bWw=
31
+ !binary "Q29udGVudC1MZW5ndGg=":
32
+ - !binary |-
33
+ MTQ0
34
+ !binary "RGF0ZQ==":
35
+ - !binary |-
36
+ V2VkLCAxOSBEZWMgMjAxMiAxOTo1MDowOSBHTVQ=
37
+ !binary "WC1WYXJuaXNo":
38
+ - !binary |-
39
+ MjE3NDY5Njc1MQ==
40
+ !binary "QWdl":
41
+ - !binary |-
42
+ MA==
43
+ !binary "Vmlh":
44
+ - !binary |-
45
+ MS4xIHZhcm5pc2g=
46
+ !binary "Q29ubmVjdGlvbg==":
47
+ - !binary |-
48
+ a2VlcC1hbGl2ZQ==
49
+ body:
50
+ encoding: US-ASCII
51
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><error><![CDATA[The
52
+ specified profile could not be found.]]></error></response>
53
+ http_version:
54
+ recorded_at: Wed, 19 Dec 2012 19:50:09 GMT
55
+ recorded_with: VCR 2.3.0
@@ -10,6 +10,9 @@ module Vapor
10
10
  crawler.games_for(user).count.should == 109
11
11
  end
12
12
  end
13
+ it "raises a UserPrivateError if user is private", :vcr do
14
+ expect{crawler.games_for(User.new("ggleytonb"))}.to raise_error(UserPrivateError)
15
+ end
13
16
 
14
17
  end
15
18
  end
@@ -9,6 +9,18 @@ module Vapor
9
9
  it 'fetches the right Steam Id using the users webpage', :vcr do
10
10
  User.new("pedronascimento").steam_id.should == 76561198021477729
11
11
  end
12
+ it 'extracts the correct id if user inputs a full url', :vcr do
13
+ User.new("http://steamcommunity.com/id/pedronascimento").steam_id.should == 76561198021477729
14
+ end
15
+
16
+ context "invalid users", :vcr do
17
+ it "raises a UserNotFoundError if user is not found" do
18
+ expect{User.new('iafjflkjalkfjlk')}.to raise_error UserNotFoundError
19
+ end
20
+ it "raises an InvalidUsernameError if username has spaces" do
21
+ expect{User.new('nao lembro')}.to raise_error InvalidUsernameError
22
+ end
23
+ end
12
24
 
13
25
  describe "profile info", :vcr do
14
26
  it "has a profile url" do
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: vapor
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pedro Nascimento
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-16 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -168,13 +168,17 @@ files:
168
168
  - lib/vapor/version.rb
169
169
  - spec/cassettes/Vapor_API/fetches_player_summaries_for_an_user.yml
170
170
  - spec/cassettes/Vapor_Crawler/_games_for/fetches_a_games_list_for_an_user.yml
171
+ - spec/cassettes/Vapor_Crawler/raises_a_UserPrivateError_if_user_is_private.yml
171
172
  - spec/cassettes/Vapor_Game/finds_the_correct_id.yml
172
173
  - spec/cassettes/Vapor_Game/finds_the_correct_name.yml
173
174
  - spec/cassettes/Vapor_Game/finds_the_correct_time_spent_in_hours.yml
174
175
  - spec/cassettes/Vapor_GamesList/creates_game_objects.yml
175
176
  - spec/cassettes/Vapor_GamesList/has_the_right_amount_of_games.yml
177
+ - spec/cassettes/Vapor_User/extracts_the_correct_id_if_user_inputs_a_full_url.yml
176
178
  - spec/cassettes/Vapor_User/fetches_the_right_Steam_Id_using_the_users_webpage.yml
177
179
  - spec/cassettes/Vapor_User/games/fetches_the_right_amount_of_games.yml
180
+ - spec/cassettes/Vapor_User/invalid_users/raises_a_UserNotFoundError.yml
181
+ - spec/cassettes/Vapor_User/invalid_users/raises_a_UserNotFoundError_if_user_is_not_found.yml
178
182
  - spec/cassettes/Vapor_User/profile_info/has_a_profile_url.yml
179
183
  - spec/cassettes/Vapor_User/raises_a_valid_error_when_Steam_API_is_not_available.yml
180
184
  - spec/spec_helper.rb
@@ -197,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
201
  version: '0'
198
202
  segments:
199
203
  - 0
200
- hash: -3448431549947448972
204
+ hash: -681727609897504390
201
205
  none: false
202
206
  required_rubygems_version: !ruby/object:Gem::Requirement
203
207
  requirements:
@@ -206,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
210
  version: '0'
207
211
  segments:
208
212
  - 0
209
- hash: -3448431549947448972
213
+ hash: -681727609897504390
210
214
  none: false
211
215
  requirements: []
212
216
  rubyforge_project:
@@ -217,13 +221,17 @@ summary: Vapor shows what games an user has played on Steam, and for how long.
217
221
  test_files:
218
222
  - spec/cassettes/Vapor_API/fetches_player_summaries_for_an_user.yml
219
223
  - spec/cassettes/Vapor_Crawler/_games_for/fetches_a_games_list_for_an_user.yml
224
+ - spec/cassettes/Vapor_Crawler/raises_a_UserPrivateError_if_user_is_private.yml
220
225
  - spec/cassettes/Vapor_Game/finds_the_correct_id.yml
221
226
  - spec/cassettes/Vapor_Game/finds_the_correct_name.yml
222
227
  - spec/cassettes/Vapor_Game/finds_the_correct_time_spent_in_hours.yml
223
228
  - spec/cassettes/Vapor_GamesList/creates_game_objects.yml
224
229
  - spec/cassettes/Vapor_GamesList/has_the_right_amount_of_games.yml
230
+ - spec/cassettes/Vapor_User/extracts_the_correct_id_if_user_inputs_a_full_url.yml
225
231
  - spec/cassettes/Vapor_User/fetches_the_right_Steam_Id_using_the_users_webpage.yml
226
232
  - spec/cassettes/Vapor_User/games/fetches_the_right_amount_of_games.yml
233
+ - spec/cassettes/Vapor_User/invalid_users/raises_a_UserNotFoundError.yml
234
+ - spec/cassettes/Vapor_User/invalid_users/raises_a_UserNotFoundError_if_user_is_not_found.yml
227
235
  - spec/cassettes/Vapor_User/profile_info/has_a_profile_url.yml
228
236
  - spec/cassettes/Vapor_User/raises_a_valid_error_when_Steam_API_is_not_available.yml
229
237
  - spec/spec_helper.rb