steam-api 1.0.3 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: a420d8645cd116e9df469e837dfd32cab3385a09
4
- data.tar.gz: 40a66089d1cd4f233877a7eac8dd1dfa0874cbeb
2
+ SHA1:
3
+ metadata.gz: d50be04a9a091da6291a0a4590554e82c6442869
4
+ data.tar.gz: 9102de40d9ff1aee65fe88425b9b3d54eae74512
5
5
  SHA512:
6
- metadata.gz: 32d8f5be1ffe6d3918d4b3042d18992db77d2a978a59dee0be538418ece9ec533f41a3ac746778e03682eea2f9709011d424ed8c5752acfca1bc678cbac24c5e
7
- data.tar.gz: b5459282ca4b3e5828101123e6671071d146c6894efb9d99099495391cc38bce6956d31ad1c7c33926c9c0debb391d1a4718693cfe9c0571a49ac8ad981bf26c
6
+ metadata.gz: fc84ebf654572c2ede0f7cdbca6c529ba627a0683d50bc31440b06c78abf7e7d54666cd48a5be180663265957be109fedb5e53a970f397151f5bdbaaa3003727
7
+ data.tar.gz: 9d66c4b0587ee46f410261b761ad644edbb2383c05d3bfc94da247c016f5702ff0aeae25bc4d629dbb24aec07a9c492ff67c3c8df9482fd7dbf9cf95e50e2dd7
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -f d -c
@@ -1,12 +1,12 @@
1
1
  module Steam
2
+ # Helper Module
2
3
  module Helpers
3
4
  # Conveniance method to build clients
4
5
  # @param [String] api The endpoint of the API
5
6
  # @param [String] base_url the root uri for steam's API
6
7
  # @return [Steam::Client] The Client
7
- def build_client(api, base_url: 'http://api.steampowered.com')
8
+ def build_client(api, base_url: 'https://api.steampowered.com')
8
9
  Steam::Client.new([base_url, api].join('/'))
9
10
  end
10
11
  end
11
12
  end
12
-
@@ -1,12 +1,12 @@
1
1
  module Steam
2
2
  # Since the steam responses are so randomly inconsistant we're making a new
3
3
  # class to manage the responses.
4
- # FIXME move all hash extensions here once the gem is finished and make
4
+ # FIXME: move all hash extensions here once the gem is finished and make
5
5
  class Response < Hash
6
- # def parse_key(key)
7
- # fail Steam::JSONError unless self.key?(key)
8
- # self[key]
9
- # end
6
+ # def parse_key(key)
7
+ # fail Steam::JSONError unless self.key?(key)
8
+ # self[key]
9
+ # end
10
10
  end
11
11
  end
12
12
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  # Base class def
3
2
  module Steam
4
3
  @apikey = ENV['STEAM_API_KEY']
@@ -5,13 +5,13 @@ module Steam
5
5
  # @since 1.0.0
6
6
  module Apps
7
7
  # Get Steam Applications
8
- # @return [Hash] A list of objects containing the title and app ID of each program
9
- # available in the store.
8
+ # @return [Hash] A list of objects containing the title and app ID of
9
+ # each program available in the store.
10
10
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetAppList
11
11
  def self.get_all
12
12
  response = client.get('GetApplist/v2')
13
- .parse_key('applist')
14
- .parse_key('apps')
13
+ .parse_key('applist')
14
+ .parse_key('apps')
15
15
  response
16
16
  end
17
17
 
@@ -7,29 +7,35 @@ module Steam
7
7
  # Get Asset Class Info
8
8
  # @param [String] appid The application ID for the Steam Game.
9
9
  # @param [Hash] params Parameters to pass to the API
10
- # @option params [Fixnum] :class_count The number of classids passed to the request.
11
- # @option params [Fixnum] :classidN Where N can be a series of sequential numbers to form a list of class IDs. [1] [2]
12
- # @option params [Fixnum] :instanceidN Instance ID of the nth class. (Optional)
13
- # @option params [String] :language The ISO639-1 language code for the language all localized
14
- # strings should be returned in. Not all strings have been translated to every language.
15
- # If a language does not have a string, the English string will be returned instead. If this
16
- # parameter is omitted the string token will be returned for the strings. (Optional)
10
+ # @option params [Fixnum] :class_count The number of classids passed to
11
+ # the request.
12
+ # @option params [Fixnum] :classidN Where N can be a series of sequential
13
+ # numbers to form a list of class IDs. [1] [2]
14
+ # @option params [Fixnum] :instanceidN Instance ID of the nth class.
15
+ # @option params [String] :language The ISO639-1 language code for the
16
+ # language all localized strings should be returned in. Not all strings
17
+ # have been translated to every language.
18
+ # If a language does not have a string, the English string will be
19
+ # returned instead. If this parameter is omitted the string token will
20
+ # be returned for the strings.
17
21
  # @return [Hash] A hash containing the API response
18
22
  # @see http://wiki.teamfortress.com/wiki/WebAPI/UpToDateCheck
19
23
  def self.asset_info(appid, params: {})
20
24
  params[:appid] = appid
21
- response = client.get 'GetAssetClassInfo/v1',
22
- params: params
25
+ response = client.get 'GetAssetClassInfo/v1', params: params
23
26
  parse_response(response)
24
27
  end
25
28
 
26
29
  # Get Asset Prices
27
30
  # @param [String] appid The application ID for the Steam Game.
28
- # @param [String] language The ISO639-1 language code for the language all localized
29
- # strings should be returned in. Not all strings have been translated to every language.
30
- # If a language does not have a string, the English string will be returned instead. If this
31
- # parameter is omitted the string token will be returned for the strings. (Optional)
32
- # @param [String] currency The ISO 4217 code for currency specific filtering. (Optional)
31
+ # @param [String] language The ISO639-1 language code for the language
32
+ # all localized strings should be returned in. Not all strings have been
33
+ # translated to every language.
34
+ # If a language does not have a string, the English string will be
35
+ # returned instead. If this parameter is omitted the string token will
36
+ # be returned for the strings. (Optional)
37
+ # @param [String] currency The ISO 4217 code for currency specific
38
+ # filtering. (Optional)
33
39
  # @return [Hash] A hash containing the API response
34
40
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetAssetPrices
35
41
  def self.asset_prices(appid, language: nil, currency: nil)
@@ -37,7 +43,7 @@ module Steam
37
43
  params[:language] = language unless language.nil?
38
44
  params[:currency] = currency unless currency.nil?
39
45
  response = client.get 'GetAssetPrices/v1',
40
- params: params
46
+ params: params
41
47
  parse_response(response)
42
48
  end
43
49
 
@@ -8,11 +8,16 @@ module Steam
8
8
  # @param [Hash] params Parameters to pass to the API
9
9
  # @option params [String] :appid The application ID for the Steam Game.
10
10
  # @option params [String] :key Steam Api Key
11
- # @option params [Fixnum] :count How many news enties you want to get returned. (Optional)
12
- # @option params [Fixnum] :maxlength Maximum length of each news entry. (Optional)
13
- # @option params [Fixnum] :enddate Unix timestamp, returns posts before this date. (Optional)
14
- # @option params [String] :feeds Commma-seperated list of feed names to return news for. (Optional)
15
- # @return [Hash] A hash object of the latest news items for a game specified by its appID.
11
+ # @option params [Fixnum] :count How many news enties you want to get
12
+ # returned. (Optional)
13
+ # @option params [Fixnum] :maxlength Maximum length of each news
14
+ # entry. (Optional)
15
+ # @option params [Fixnum] :enddate Unix timestamp, returns posts before
16
+ # this date. (Optional)
17
+ # @option params [String] :feeds Commma-seperated list of feed names to
18
+ # return news for. (Optional)
19
+ # @return [Hash] A hash object of the latest news items for a game
20
+ # specified by its appID.
16
21
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetNewsForApp
17
22
  def self.get(appid, params: {})
18
23
  params[:appid] = appid
@@ -7,14 +7,16 @@ module Steam
7
7
  # Get Owned Games
8
8
  # @param [Hash] params Parameters to pass to the API
9
9
  # @option params [Fixnum] :steamid The 64 bit ID of the player. (Optional)
10
- # @option params [Boolean] :include_appinfo (false) Whether or not to include additional
11
- # details of apps - name and images.
12
- # @option params [Boolean] :include_played_free_games (false) Whether or not to list
13
- # free-to-play games in the results.
14
- # @option params [Array] :appids_filter You can optionally filter the list to a set of appids.
15
- # Note that these cannot be passed as a URL parameter, instead you must use the JSON format
16
- # described in Steam_Web_API#Calling_Service_interfaces. The expected input is an array of
17
- # integers (in JSON: "appids_filter: [ 440, 500, 550 ]" )
10
+ # @option params [Integer] :include_appinfo (0) Whether or not to include
11
+ # additional details of apps - name and images.
12
+ # @option params [Boolean] :include_played_free_games (false) Whether or
13
+ # not to list free-to-play games in the results.
14
+ # @option params [Array] :appids_filter You can optionally filter the list
15
+ # to a set of appids.
16
+ # Note that these cannot be passed as a URL parameter, instead you must
17
+ # use the JSON format described in
18
+ # Steam_Web_API#Calling_Service_interfaces. The expected input is an
19
+ # array of integers (in JSON: "appids_filter: [ 440, 500, 550 ]" )
18
20
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetOwnedGames
19
21
  def self.owned_games(steamid, params: {})
20
22
  params[:steamid] = steamid
@@ -25,8 +27,9 @@ module Steam
25
27
  # Get Recently Played Games
26
28
  # @param [Hash] params Parameters to pass to the API
27
29
  # @option params [String] :steamid The SteamID of the account.
28
- # @option params [String] :count Optionally limit to a certain number of games (the number of
29
- # games a person has played in the last 2 weeks is typically very small)
30
+ # @option params [String] :count Optionally limit to a certain number of
31
+ # games (the number of games a person has played in the last 2 weeks is
32
+ # typically very small)
30
33
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetRecentlyPlayedGames
31
34
  def self.recently_played_games(steamid, params: {})
32
35
  params[:steamid] = steamid
@@ -42,7 +45,7 @@ module Steam
42
45
  response = client.get 'GetSteamLevel/v1',
43
46
  params: { steamid: steamid }
44
47
  response.parse_key('response')
45
- .parse_key('player_level')
48
+ .parse_key('player_level')
46
49
  end
47
50
 
48
51
  # Get a player's Steam badges
@@ -61,7 +64,7 @@ module Steam
61
64
  response = client.get 'GetCommunityBadgeProgress/v1',
62
65
  params: { steamid: steamid }
63
66
  response.parse_key('response')
64
- .parse_key('quests')
67
+ .parse_key('quests')
65
68
  end
66
69
 
67
70
  private
@@ -5,7 +5,7 @@ module Steam
5
5
  # @since 1.0.0
6
6
  module User
7
7
  # Get User's Friend List
8
- # @param [String] steamid
8
+ # @param [String] steamid
9
9
  # @param [String] relationship Relationship filter.
10
10
  # Possibles values: all, friend.
11
11
  # @return [Hash] A hash object resulting from the API call; should
@@ -17,7 +17,7 @@ module Steam
17
17
  params: { steamid: steamid,
18
18
  relationship: relationship }
19
19
  response = response.parse_key('friendslist')
20
- .parse_key('friends')
20
+ .parse_key('friends')
21
21
  response
22
22
  end
23
23
 
@@ -54,7 +54,7 @@ module Steam
54
54
  response = client.get 'GetPlayerSummaries/v2/',
55
55
  params: { steamids: steamids.join(',') }
56
56
  response.parse_key('response')
57
- .parse_key('players')
57
+ .parse_key('players')
58
58
  end
59
59
 
60
60
  # Get User Groups
@@ -6,14 +6,14 @@ module Steam
6
6
  module UserStats
7
7
  # Get Global Achievement Percentages for App
8
8
  # @param [Fixnum] appid The ID of the game or application
9
- # @return [Hash] The hash object of information on the global achievements overview of
10
- # a specific game in percentages.
9
+ # @return [Hash] The hash object of information on the global achievements
10
+ # overview of a specific game in percentages.
11
11
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetGlobalAchievementPercentagesForApp
12
12
  def self.achievement_percentages(appid)
13
13
  response = client.get 'GetGlobalAchievementPercentagesForApp/v2',
14
14
  params: { gameid: appid }
15
15
  response = response.parse_key('achievementpercentages')
16
- .parse_key('achievements')
16
+ .parse_key('achievements')
17
17
  response
18
18
  end
19
19
 
@@ -21,12 +21,14 @@ module Steam
21
21
  # @param [Fixnum] appid The ID of the game or application
22
22
  # @param [Hash] params Parameters to pass to the API
23
23
  # @option params [Fixnum] :count Number of stats to get data for.
24
- # @option params [String] :name[0] Names of the stats to get. For more than one value, use
25
- # a parameter for each request. (name[0], name[1], ...) Not all stats are globally
26
- # aggregated. The developer of the game must mark the stat as globally aggregated.
24
+ # @option params [String] :name[0] Names of the stats to get. For more than
25
+ # one value, use a parameter for each request. (name[0], name[1], ...)
26
+ # Not all stats are globally aggregated. The developer of the game must
27
+ # mark the stat as globally aggregated.
27
28
  # @option params [String] :startdate Start date for daily totals
28
29
  # (unix epoch timestamp). (Optional)
29
- # @option params [String] :enddate End date for daily totals (unix epoch timestamp). (Optional)
30
+ # @option params [String] :enddate End date for daily totals (unix epoch
31
+ # timestamp). (Optional)
30
32
  # @return [Hash] A hash containing the API response
31
33
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetGlobalStatsForGame
32
34
  def self.global_for_game(appid, params: {})
@@ -53,16 +55,16 @@ module Steam
53
55
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetNumberOfCurrentPlayers
54
56
  def self.player_count(appid)
55
57
  response = client.get 'GetNumberOfCurrentPlayers/v1',
56
- params: { appid: appid }
58
+ params: { appid: appid }
57
59
  response.parse_key('response')
58
- .parse_key('player_count')
60
+ .parse_key('player_count')
59
61
  end
60
62
 
61
63
  # Get Player Achievements
62
64
  # @param [Fixnum] steamid 64 bit Steam ID to return Achievements list for.
63
65
  # @param [Fixnum] appid AppID to get achievements for
64
- # @param [String] language Language. If specified, it will return language data for
65
- # the requested language. (Optional)
66
+ # @param [String] language Language. If specified, it will return language
67
+ # data for the requested language. (Optional)
66
68
  # @return [Hash] A hash containing the API response
67
69
  # @see http://wiki.teamfortress.com/wiki/WebAPI/GetPlayerAchievements
68
70
  def self.player_achievements(appid, steamid, language: nil)
@@ -75,6 +77,17 @@ module Steam
75
77
  response
76
78
  end
77
79
 
80
+ # Get User Stats for Game
81
+ # @param [Fixnum] appid AppID to get stats for.
82
+ # @param [Fixnum] steamid 64 bit Steam ID to return stats for.
83
+ # @return [Hash] A hash containing the API response.
84
+ # @see https://developer.valvesoftware.com/wiki/Steam_Web_API#GetUserStatsForGame_.28v0002.29
85
+ def self.player_stats(appid, steamid)
86
+ params = { appid: appid, steamid: steamid }
87
+ response = client.get 'GetUserStatsForGame/v2', params: params
88
+ response.parse_key('playerstats')
89
+ end
90
+
78
91
  private
79
92
 
80
93
  def self.client
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  # Versioning Info
3
3
  module Steam
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -2,60 +2,73 @@ require 'spec_helper'
2
2
 
3
3
  describe Steam::Apps do
4
4
  describe '.get_all' do
5
- it 'should allow users to look up a list of all apps' do
6
- expect(Steam::Apps.get_all)
7
- .to_not be_nil
5
+ let(:result) { Steam::Apps.get_all }
6
+
7
+ it 'returns a list of apps' do
8
+ expect(result).to_not be_nil
9
+ end
10
+
11
+ it 'returns an appid for each game' do
12
+ expect(result.first).to have_key 'appid'
8
13
  end
9
14
 
10
- it 'should allow users to look up a list of all apps' do
11
- game = Steam::Apps.get_all.first
12
- expect(game).to have_key 'appid'
13
- expect(game).to have_key 'name'
15
+ it 'returns a name for each game' do
16
+ expect(result.first).to have_key 'name'
14
17
  end
15
18
  end
16
19
 
17
20
  describe '.get_servers' do
18
- it 'should allow users to look up a list of servers at an ip' do
19
- expect(Steam::Apps.get_servers(addr: '192.168.1.1'))
20
- .to_not be_nil
21
+ let(:result) { Steam::Apps.get_servers(addr: '192.168.1.1') }
22
+
23
+ it 'returns a valid response' do
24
+ expect(result).to_not be_nil
21
25
  end
22
26
 
23
- it 'should allow users to look up a list of servers at an ip' do
24
- expect(Steam::Apps.get_servers(addr: '192.168.1.1'))
25
- .to eq([])
27
+ it 'returns an empty array for an ip with no servers' do
28
+ expect(result).to eq([])
26
29
  end
27
30
  end
28
31
 
29
32
  describe '.up_to_date' do
30
- it 'should allow users to look up version info' do
31
- expect(Steam::Apps.up_to_date(appid: 440, version: 10))
32
- .to_not be_nil
33
- end
33
+ context 'when looking up out of date version info' do
34
+ let(:result) { Steam::Apps.up_to_date(appid: 440, version: 10) }
35
+
36
+ it 'does not return a nil response' do
37
+ expect(result).to_not be_nil
38
+ end
34
39
 
35
- it 'should return a false up to date value if the verion is out of date' do
36
- check = Steam::Apps.up_to_date(appid: 440, version: 10)
37
- expect(check['up_to_date'])
38
- .to be_falsey
39
- expect(check['version_is_listable'])
40
- .to be_falsey
41
- expect(check)
42
- .to have_key('required_version')
43
- expect(check['message'])
44
- .to eq('Your server is out of date, please upgrade')
40
+ it "returns a false value for 'up_to_date'" do
41
+ expect(result['up_to_date']).to be_falsey
42
+ end
43
+
44
+ it "returns a false value for 'version_is_listable'" do
45
+ expect(result['version_is_listable']).to be_falsey
46
+ end
47
+
48
+ it 'returns a required_version' do
49
+ expect(result).to have_key('required_version')
50
+ end
51
+
52
+ it 'returns an error message' do
53
+ expect(result['message']).to eq('Your server is out of date, please upgrade')
54
+ end
45
55
  end
46
56
 
47
- it 'should return a positive up to date value if the version is correct' do
48
- current = Steam::Apps.up_to_date(appid: 440, version: 10)['required_version']
49
- check = Steam::Apps.up_to_date(appid: 440, version: current)
50
- expect(check['up_to_date'])
51
- .to be_truthy
52
- expect(check['version_is_listable'])
53
- .to be_truthy
57
+ context 'when looking up current version info' do
58
+ let(:current) { Steam::Apps.up_to_date(appid: 440, version: 10)['required_version'] }
59
+ let(:check) { Steam::Apps.up_to_date(appid: 440, version: current) }
60
+
61
+ it 'returns a positive up to date value' do
62
+ expect(check['up_to_date']).to be_truthy
63
+ end
64
+
65
+ it 'returns a positive version_is_listable value' do
66
+ expect(check['version_is_listable']).to be_truthy
67
+ end
54
68
  end
55
69
 
56
70
  it 'should capture json errors' do
57
- expect(lambda { Steam::Apps.up_to_date(appid: nil, version: 'foo') })
58
- .to raise_error
71
+ expect { Steam::Apps.up_to_date(appid: nil, version: 'foo') }.to raise_error
59
72
  end
60
73
  end
61
74
  end
@@ -2,46 +2,42 @@ require 'spec_helper'
2
2
 
3
3
  describe Steam::Economy do
4
4
  describe '.asset_info' do
5
- it 'should allow users to look up a list of all apps' do
6
- asset = Steam::Economy.asset_info(440, params: { class_count: 2,
5
+ let(:result) { Steam::Economy.asset_info(440,
6
+ params: { class_count: 2,
7
7
  classid0: 195151,
8
- classid1: 16891096 })
9
- expect(asset).to_not be_nil
8
+ classid1: 16891096 })}
9
+
10
+ it 'returns data' do
11
+ expect(result).to_not be_nil
10
12
  end
11
13
 
12
- it 'should require class params' do
13
- expect(lambda { Steam::Economy.asset_info(440) })
14
- .to raise_error
14
+ it 'requires class params' do
15
+ expect { Steam::Economy.asset_info(440) }.to raise_error
15
16
  end
16
17
 
17
- it 'should allow users to query asset info' do
18
- result = Steam::Economy.asset_info(440, params: { class_count: 2,
19
- classid0: 195151,
20
- classid1: 16891096 })
18
+ it 'allows users to query asset info' do
21
19
  expect(result).to have_key('195151')
22
20
  expect(result).to have_key('16891096')
23
21
  end
24
22
  end
25
23
 
26
24
  describe '.asset_prices' do
27
- it 'should allow users to look up a list asset prices' do
28
- expect(Steam::Economy.asset_prices(440))
29
- .to_not be_nil
25
+ let(:result) { Steam::Economy.asset_prices(440) }
26
+
27
+ it 'allows users to look up a list asset prices' do
28
+ expect(result).to_not be_nil
30
29
  end
31
30
 
32
- it 'should allow return a list of assets' do
33
- expect(Steam::Economy.asset_prices(440))
34
- .to have_key('assets')
31
+ it 'returns a list of assets' do
32
+ expect(result).to have_key('assets')
35
33
  end
36
34
 
37
- it 'should allow return a list of asset tags' do
38
- expect(Steam::Economy.asset_prices(440))
39
- .to have_key('tags')
35
+ it 'returns a list of asset tags' do
36
+ expect(result).to have_key('tags')
40
37
  end
41
38
 
42
- it 'should allow return a list of asset tag ids' do
43
- expect(Steam::Economy.asset_prices(440))
44
- .to have_key('tag_ids')
39
+ it 'returns a list of asset tag ids' do
40
+ expect(result).to have_key('tag_ids')
45
41
  end
46
42
  end
47
43
  end
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe Steam::News do
4
4
  describe '.get' do
5
- it 'should allow users to look up a list news for an app' do
6
- expect(Steam::News.get(440))
7
- .to_not be_nil
5
+ let(:result) { Steam::News.get(440) }
6
+
7
+ it 'allow users to look up a news list' do
8
+ expect(result).to_not be_nil
8
9
  end
9
10
 
10
- it 'should allow users to look up a list news for an app' do
11
- news = Steam::News.get(440)
12
- expect(news.count).to eq(20)
11
+ it 'returns the first 20 articles' do
12
+ expect(result.count).to eq(20)
13
13
  end
14
14
  end
15
15
  end
@@ -1,93 +1,106 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Steam::Player do
4
- before(:each) do
5
- @playerid = 76561197993276293
6
- end
4
+ let(:playerid) { 76561197993276293 }
7
5
 
8
6
  describe '.owned_games' do
9
- it 'should allow users to retrieve a list of games' do
10
- expect(Steam::Player.owned_games(@playerid))
11
- .to_not be_nil
7
+ let(:result) { Steam::Player.owned_games(playerid) }
8
+
9
+ it 'allows users to retrieve a list of games' do
10
+ expect(result).to_not be_nil
12
11
  end
13
12
 
14
- it 'should allow users to retrieve a list of games' do
15
- expect(Steam::Player.owned_games(@playerid))
16
- .to have_key('game_count')
13
+ it 'returns a game_count' do
14
+ expect(result).to have_key('game_count')
17
15
  end
18
16
 
19
- it 'should allow users to retrieve a list of games' do
20
- expect(Steam::Player.owned_games(@playerid))
21
- .to have_key('games')
17
+ it 'returns a list of games' do
18
+ expect(result).to have_key('games')
22
19
  end
23
20
  end
24
21
 
25
22
  describe '.recently_played_games' do
26
- it 'should allow users to list a players recent games' do
27
- expect(Steam::Player.recently_played_games(@playerid))
28
- .to_not be_nil
23
+ let(:result) { Steam::Player.recently_played_games(playerid) }
24
+
25
+ it 'allows users to list a players recent games' do
26
+ expect(result).to_not be_nil
27
+ end
28
+
29
+ it 'returns total_count' do
30
+ expect(result).to have_key('total_count')
31
+ end
32
+
33
+ it 'returns the list of games' do
34
+ expect(result).to have_key('games')
35
+ end
36
+
37
+ it 'returns the recent playtime for games' do
38
+ expect(result['games'].first).to have_key('playtime_2weeks')
29
39
  end
30
40
 
31
- it 'should allow users to list a players recent games' do
32
- expect(Steam::Player.recently_played_games(@playerid))
33
- .to have_key 'total_count'
41
+ it 'returns the full playtime for games' do
42
+ expect(result['games'].first).to have_key('playtime_forever')
34
43
  end
35
44
  end
36
45
 
37
46
  describe '.steam_level' do
38
- it 'should allow users to retrieve a users steam level' do
39
- expect(Steam::Player.steam_level(@playerid))
40
- .to_not be_nil
47
+ let(:result) { Steam::Player.steam_level(playerid) }
48
+
49
+ it 'allows users to retrieve a users steam level' do
50
+ expect(result).to_not be_nil
41
51
  end
42
52
 
43
- it 'should allow users to retrieve a users steam level' do
44
- expect(Steam::Player.steam_level(@playerid))
45
- .to be_a(Fixnum)
53
+ it 'returns the level number' do
54
+ expect(result).to be_a(Fixnum)
46
55
  end
47
56
  end
48
57
 
49
58
  describe '.badges' do
50
- it 'should allow a user to retrieve badges for a player' do
51
- expect(Steam::Player.badges(@playerid))
52
- .to_not be_nil
59
+ let(:result) { Steam::Player.badges(playerid) }
60
+
61
+ it 'allows a user to retrieve badges for a player' do
62
+ expect(result).to_not be_nil
63
+ end
64
+
65
+ it 'returns a list of badges' do
66
+ expect(result).to have_key('badges')
53
67
  end
54
68
 
55
- it 'should allow a user to retrieve badges for a player' do
56
- expect(Steam::Player.badges(@playerid))
57
- .to have_key 'badges'
69
+ it 'returns the player level' do
70
+ expect(result).to have_key('player_level')
58
71
  end
59
72
 
60
- it 'should allow a user to retrieve badges for a player' do
61
- expect(Steam::Player.badges(@playerid))
62
- .to have_key 'player_level'
73
+ it 'returns the player level as a number' do
74
+ expect(result['player_level']).to be_a(Fixnum)
63
75
  end
64
76
 
65
- it 'should allow a user to retrieve badges for a player' do
66
- expect(Steam::Player.badges(@playerid))
67
- .to have_key 'player_xp'
77
+ it 'returns the players current xp' do
78
+ expect(result).to have_key('player_xp')
68
79
  end
69
80
 
70
- it 'should allow a user to retrieve badges for a player' do
71
- expect(Steam::Player.badges(@playerid))
72
- .to have_key 'player_xp_needed_current_level'
81
+ it 'returns the xp a player needed to reach thier current level' do
82
+ expect(result).to have_key('player_xp_needed_current_level')
73
83
  end
74
84
 
75
- it 'should allow a user to retrieve badges for a player' do
76
- expect(Steam::Player.badges(@playerid))
77
- .to have_key 'player_xp_needed_to_level_up'
85
+ it 'returns the xp a player needs to reach next level' do
86
+ expect(result).to have_key('player_xp_needed_to_level_up')
78
87
  end
79
88
  end
80
89
 
81
90
  describe '.community_badge_progress' do
82
- it 'should allow a user to retrieve community badge info for a player' do
83
- expect(Steam::Player.community_badge_progress(@playerid))
84
- .to_not be_nil
91
+ let(:result) { Steam::Player.community_badge_progress(playerid) }
92
+
93
+ it 'allows a user to retrieve community badge info for a player' do
94
+ expect(result).to_not be_nil
95
+ end
96
+
97
+ it 'returns a list of quests' do
98
+ expect(result).to be_a(Array)
85
99
  end
86
100
 
87
- it 'should allow a user to retrieve community badge info for a player' do
88
- quest = Steam::Player.community_badge_progress(@playerid).first
89
- expect(quest).to have_key 'questid'
90
- expect(quest).to have_key 'completed'
101
+ it 'returns a list of quests with ids and completion status' do
102
+ expect(result.first).to have_key('questid')
103
+ expect(result.first).to have_key('completed')
91
104
  end
92
105
  end
93
106
  end
@@ -2,88 +2,95 @@ require 'spec_helper'
2
2
 
3
3
  describe Steam::UserStats do
4
4
  describe '.achievement_percentages' do
5
- it 'should return achievement information' do
6
- expect(Steam::UserStats.achievement_percentages(440))
7
- .to_not be_nil
5
+ let(:result) { Steam::UserStats.achievement_percentages(440) }
6
+
7
+ it 'returns achievement information' do
8
+ expect(result).to_not be_nil
8
9
  end
9
10
 
10
- it 'should return all achievements for a game' do
11
- achs = Steam::UserStats.achievement_percentages(440)
12
- expect(achs.first).to have_key('name')
13
- expect(achs.first).to have_key('percent')
11
+ it 'returns all achievements for a game' do
12
+ expect(result.first).to have_key('name')
13
+ expect(result.first).to have_key('percent')
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.game_schema' do
18
- it 'should return global game stats' do
19
- expect(Steam::UserStats.game_schema(440))
20
- .to_not be_nil
21
- end
18
+ let(:result) { Steam::UserStats.game_schema(440) }
22
19
 
23
- it 'should return global game stats with proper schema' do
24
- expect(Steam::UserStats.game_schema(440))
25
- .to have_key('gameName')
20
+ it 'returns global game stats' do
21
+ expect(result).to_not be_nil
26
22
  end
27
23
 
28
- it 'should return global game stats with proper schema' do
29
- expect(Steam::UserStats.game_schema(440))
30
- .to have_key('gameName')
24
+ it 'returns global game stats with a gameName' do
25
+ expect(result).to have_key('gameName')
31
26
  end
32
27
 
33
- it 'should return global game stats with proper schema' do
34
- expect(Steam::UserStats.game_schema(440))
35
- .to have_key('gameVersion')
28
+ it 'returns global game stats with a gameVersion' do
29
+ expect(result).to have_key('gameVersion')
36
30
  end
37
31
 
38
- it 'should return global game stats with proper schema' do
39
- expect(Steam::UserStats.game_schema(440))
40
- .to have_key('availableGameStats')
32
+ it 'returns global game stats with availableGameStats' do
33
+ expect(result).to have_key('availableGameStats')
41
34
  end
42
35
  end
43
36
 
44
37
  describe '.global_for_game' do
45
- it 'should return global game stats' do
46
- expect(Steam::UserStats.global_for_game(201830,
47
- params: { 'name[0]' => 'totalDeaths',
48
- count: 10 }))
38
+ it 'returns global game stats' do
39
+ Steam::UserStats.global_for_game(201830, params: { 'name[0]' => 'totalDeaths', count: 10 })
49
40
  end
50
41
  end
51
42
 
52
43
  describe '.player_count' do
53
- it 'should return a player count' do
54
- expect(Steam::UserStats.player_count(440))
55
- .to be_a(Fixnum)
44
+ it 'returns a player count' do
45
+ expect(Steam::UserStats.player_count(440)).to be_a(Fixnum)
56
46
  end
57
47
  end
58
48
 
59
49
  describe '.get_player_achievements' do
60
- before(:each) do
61
- @achs = Steam::UserStats.player_achievements(440, 76561197969622382)
50
+ let(:achs) { Steam::UserStats.player_achievements(440, 76561197969622382) }
51
+
52
+ it 'returns a list of player achievements' do
53
+ expect(achs).to have_key('achievements')
54
+ end
55
+
56
+ it 'returns a gameName' do
57
+ expect(achs).to have_key('gameName')
58
+ end
59
+
60
+ it 'returns correct gameName' do
61
+ expect(achs['gameName']).to eq('Team Fortress 2')
62
62
  end
63
63
 
64
- it 'should return player achievements' do
65
- expect(@achs)
66
- .to have_key('achievements')
64
+ it 'returns a steamID' do
65
+ expect(achs).to have_key('steamID')
66
+ end
67
+
68
+ it 'returns the correct steamID' do
69
+ expect(achs['steamID']).to eq('76561197969622382')
70
+ end
71
+ end
72
+
73
+ describe '.player_stats' do
74
+ let(:stats) { Steam::UserStats.player_stats(440, 76561197969622382) }
75
+
76
+ it 'returns player stats' do
77
+ expect(stats).to have_key('stats')
67
78
  end
68
79
 
69
- it 'should return player achievements' do
70
- expect(@achs)
71
- .to have_key('gameName')
80
+ it 'returns a gameName' do
81
+ expect(stats).to have_key('gameName')
72
82
  end
73
83
 
74
- it 'should return player achievements' do
75
- expect(@achs['gameName'])
76
- .to eq('Team Fortress 2')
84
+ it 'returns the correct gameName' do
85
+ expect(stats['gameName']).to eq('Team Fortress 2')
77
86
  end
78
87
 
79
- it 'should return player achievements' do
80
- expect(Steam::UserStats.player_achievements(440, 76561197969622382))
81
- .to have_key('steamID')
88
+ it 'returns a steamID' do
89
+ expect(stats).to have_key('steamID')
82
90
  end
83
91
 
84
- it 'should return player achievements' do
85
- expect(Steam::UserStats.player_achievements(440, 76561197969622382)['steamID'])
86
- .to eq('76561197969622382')
92
+ it 'returns a correct steamID' do
93
+ expect(stats['steamID']).to eq('76561197969622382')
87
94
  end
88
95
  end
89
96
  end
@@ -1,89 +1,80 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Steam::User do
4
- before(:each) do
5
- @playerid = 76561197993276293
6
- @playerid2 = 76561197969622382
7
- end
4
+ let(:playerid) { 76561197993276293 }
5
+ let(:playerid2) { 76561197969622382 }
8
6
 
9
7
  describe '.friends' do
10
- it 'should allow users to check a friends for a user' do
11
- response = Steam::User.friends(@playerid)
12
- expect(response).to_not be_nil
8
+ let(:result) { Steam::User.friends(playerid) }
9
+
10
+ it 'allows users to check a friends for a user' do
11
+ expect(result).to_not be_nil
13
12
  end
14
13
 
15
- it 'should allow users to check a friends for a user' do
16
- expect(Steam::User.friends(@playerid).map { |friend| friend.first.last })
17
- .to include(@playerid2.to_s)
14
+ it 'returns a list of friends of a user' do
15
+ expect(result.map { |friend| friend.first.last }).to include(playerid2.to_s)
18
16
  end
19
17
 
20
- it 'should return an error on a bad friend id' do
21
- expect(lambda { Steam::User.friends('765611') })
22
- .to raise_error
18
+ it 'raises an error on a bad friend id' do
19
+ expect { Steam::User.friends('765611') }.to raise_error
23
20
  end
24
21
 
25
- it 'should return the same content for :friends and :all' do
26
- expect(Steam::User.friends(@playerid2, relationship: :friend))
27
- .to eq(Steam::User.friends(@playerid2, relationship: :all))
22
+ it 'returns the same content for :friends and :all' do
23
+ friends = Steam::User.friends(playerid2, relationship: :friend)
24
+ all_friends = Steam::User.friends(playerid2, relationship: :all)
25
+ expect(friends).to eq(all_friends)
28
26
  end
29
27
 
30
- it 'should return an error on a bad friend id' do
31
- expect(lambda { Steam::User.friends(@playerid2, relationship: :sadsad) })
32
- .to raise_error(Steam::JSONError)
28
+ it 'returns an error on a bad friend relationship' do
29
+ expect { Steam::User.friends(playerid2, relationship: :sadsad) }.to raise_error(Steam::JSONError)
33
30
  end
34
31
  end
35
32
 
36
33
  describe '.bans' do
37
- it 'should allow users to check bans for a user' do
38
- expect(Steam::User.bans(@playerid))
39
- .to_not be_nil
34
+ it 'allows users to check bans for a user' do
35
+ expect(Steam::User.bans(playerid)).to_not be_nil
40
36
  end
41
37
 
42
- it 'should return a blank list for bad ids' do
43
- expect(Steam::User.bans(7993276293))
44
- .to eq({ 'players' => [] })
38
+ it 'returns a blank list for bad ids' do
39
+ expect(Steam::User.bans(7993276293)).to eq({ 'players' => [] })
45
40
  end
46
41
 
47
- it 'should allow users to check a bans for multiple steamids' do
48
- expect(Steam::User.bans([@player, @player2]))
49
- .to_not be_nil
42
+ it 'allow users to check bans for multiple steamids' do
43
+ expect(Steam::User.bans([playerid, playerid2])).to_not be_nil
50
44
  end
51
45
  end
52
46
 
53
47
  describe '.summary' do
54
- it 'should allow users to get a summary for a user' do
55
- expect(Steam::User.summary(@playerid))
56
- .to_not be_nil
48
+ it 'allows users to get a summary for a user' do
49
+ expect(Steam::User.summary(playerid)).to_not be_nil
57
50
  end
58
51
 
59
- it 'should allow users to check summaries for multiple accounts' do
60
- expect(Steam::User.summaries([@player, @player2]))
61
- .to_not be_nil
52
+ it 'allows users to check summaries for multiple accounts' do
53
+ expect(Steam::User.summaries([playerid, playerid2])).to_not be_nil
62
54
  end
63
55
  end
64
56
 
65
57
  describe '.vanity_to_steamid' do
66
- it 'should return values when they look up vanity urls' do
67
- expect(Steam::User.vanity_to_steamid('asmeroth'))
68
- .to_not be_nil
58
+ let(:result) { Steam::User.vanity_to_steamid('asmeroth') }
59
+
60
+ it 'return values when they look up vanity urls' do
61
+ expect(result).to_not be_nil
69
62
  end
70
63
 
71
- it 'should return the correct id when users look up vanity urls' do
72
- expect(Steam::User.vanity_to_steamid('asmeroth'))
73
- .to eq(@playerid.to_s)
64
+ it 'returns the correct id when users look up vanity urls' do
65
+ expect(result).to eq(playerid.to_s)
74
66
  end
75
67
  end
76
68
 
77
69
  describe '.groups' do
78
- it 'should allow users to look groups a player is a member of' do
79
- expect(Steam::User.groups(@playerid))
80
- .to_not be_nil
70
+ let(:result) { Steam::User.groups(playerid) }
71
+
72
+ it 'allow users to look up a users groups' do
73
+ expect(result).to_not be_nil
81
74
  end
82
75
 
83
- it 'should return an accurate list of groups a player is a member of' do
84
- response = Steam::User.groups(@playerid)
85
- expect(response.map { |g| g.values.first })
86
- .to include '3640974'
76
+ it 'returns an accurate list of groups a player is a member of' do
77
+ expect(result.map { |g| g.values.first }).to include('3640974')
87
78
  end
88
79
  end
89
80
  end
@@ -1,38 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Steam do
4
- before(:all) do
5
- @apikey = Steam.apikey
6
- end
4
+ describe '.apikey' do
5
+ before(:all) do
6
+ @apikey = Steam.apikey
7
+ end
7
8
 
8
- after(:each) do
9
- Steam.apikey = @apikey
10
- end
9
+ after(:each) do
10
+ Steam.apikey = @apikey
11
+ end
11
12
 
12
- it 'should return a Steam API key if one is defined' do
13
- expect(Steam.apikey).to_not be_nil
14
- end
13
+ it 'returns a Steam API key if one is defined' do
14
+ expect(Steam.apikey).to_not be_nil
15
+ end
15
16
 
16
- it 'should return an error if the Steam Key is missing' do
17
- Steam.apikey = nil
18
- ENV['STEAM_API_KEY'] = nil
19
- expect(lambda { Steam.apikey })
20
- .to raise_error(ArgumentError, /Please set your Steam API key/)
21
- end
17
+ it 'returns an error if the Steam Key is missing' do
18
+ Steam.apikey = nil
19
+ ENV['STEAM_API_KEY'] = nil
20
+ expect { Steam.apikey }.to raise_error(ArgumentError, /Please set your Steam API key/)
21
+ end
22
22
 
23
- it 'should return a new value if set to a different API key' do
24
- old = Steam.apikey
25
- Steam.apikey = 'blah'
26
- expect(Steam.apikey).to_not eq(old)
27
- expect(Steam.apikey).to eq('blah')
28
- end
23
+ it 'returns a new value if set to a different API key' do
24
+ old = Steam.apikey
25
+ Steam.apikey = 'blah'
26
+ expect(Steam.apikey).to_not eq(old)
27
+ expect(Steam.apikey).to eq('blah')
28
+ end
29
29
 
30
- it 'should allow users to set the apikey post init using ENV' do
31
- Steam.apikey = nil
32
- ENV['STEAM_API_KEY'] = nil
33
- expect(lambda { Steam.apikey })
34
- .to raise_error(ArgumentError, /Please set your Steam API key/)
35
- ENV['STEAM_API_KEY'] = @apikey
36
- expect(Steam.apikey).to eq(@apikey)
30
+ it 'allows users to set the apikey post init using ENV' do
31
+ Steam.apikey = nil
32
+ ENV['STEAM_API_KEY'] = nil
33
+ expect { Steam.apikey }.to raise_error(ArgumentError, /Please set your Steam API key/)
34
+ ENV['STEAM_API_KEY'] = @apikey
35
+ expect(Steam.apikey).to eq(@apikey)
36
+ end
37
37
  end
38
38
  end
metadata CHANGED
@@ -1,109 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steam-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Haberer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2015-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: faraday
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.9'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: multi_json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.7'
76
- - - ! '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.7.7
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ~>
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '1.7'
86
- - - ! '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.7.7
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: json
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '1.7'
96
- - - ! '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 1.7.7
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
105
  version: '1.7'
106
- - - ! '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 1.7.7
109
109
  description: Simple Steam Gem
@@ -113,8 +113,9 @@ executables: []
113
113
  extensions: []
114
114
  extra_rdoc_files: []
115
115
  files:
116
- - .gitignore
117
- - .travis.yml
116
+ - ".gitignore"
117
+ - ".rspec"
118
+ - ".travis.yml"
118
119
  - Gemfile
119
120
  - LICENSE.txt
120
121
  - README.md
@@ -154,17 +155,17 @@ require_paths:
154
155
  - lib
155
156
  required_ruby_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
- - - ! '>='
158
+ - - ">="
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  required_rubygems_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - ! '>='
163
+ - - ">="
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  requirements: []
166
167
  rubyforge_project:
167
- rubygems_version: 2.4.4
168
+ rubygems_version: 2.4.8
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: Simple Gem to interact witht the Steam Web API
@@ -178,3 +179,4 @@ test_files:
178
179
  - spec/steam/users-stats_spec.rb
179
180
  - spec/steam/users_spec.rb
180
181
  - spec/steam_spec.rb
182
+ has_rdoc: