steamwebapi 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 18246c0e9973ef30a728216a753ad8ae71344ab1
4
+ data.tar.gz: 584b05177f2ba66a996620a4f018a6af6705e387
5
+ SHA512:
6
+ metadata.gz: e5428af36f211c7c3ab89ffec092f5113f868456ec543599e2154d1ce647311544f5cbae78f7015274898b503386e72ecee84e325e4079a19ec70c59f3652974
7
+ data.tar.gz: c0b362774bba21b102496664538370ab68c358d2cec0d15a326c0c775c9c344320d19968ab5a2d88ead4bcd299ee114b78808507b75d399d0ceda40ab8c86b65
@@ -0,0 +1,38 @@
1
+ ### Ruby template
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+
37
+ ## RubyMine thing
38
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in steamwebapi.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 kuzmaa
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ Steamwebapi
2
+ ===
3
+
4
+ Steam Web API library in Ruby. Retrieves and parses JSON data. If you want more information about the API go to:
5
+
6
+ * http://steamcommunity.com/dev
7
+ * https://developer.valvesoftware.com/wiki/Steam_Web_API
8
+
9
+
10
+ ## TODO
11
+
12
+ * add a SteamID64 converter thingamajig so you don't have to use a user's SteamID64 only.
13
+
14
+ ## Installation
15
+
16
+ Open up your terminal or cmd or whatever and copypasta this code
17
+
18
+ $ gem install steamwebapi
19
+
20
+ To use it in your application, add the following to your Gemfile:
21
+
22
+ gem 'steamwebapi'
23
+
24
+ ## Usage
25
+
26
+ Retrieve a user's friend list:
27
+
28
+ # retrieve friend list of user with SteamID64 being 76561197960435530
29
+ SteamUser.key('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').friend_list('76561197960435530') # some functions require an api key(IPlayerService, ISteamUser, and some ISteamUserStats)
30
+
31
+ Retrieve news for a Steam app:
32
+
33
+ # retrieve news for Steam app
34
+ SteamApp.get_news('440', '1', '1') # this will retrieve 1 article of app 440 with the content's length being 1("A...")
35
+
36
+ You can also use the SteamAPI module's `get` function
37
+
38
+ # return news for a Steam app - this does the same thing as the example above, its just messier(IMO)
39
+ SteamAPI.get('ISteamNews', 'GetNewsForApp', 'v0002', args = {appid: '440', count: '1', maxlength: '1'})
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ require 'steamwebapi/steamapi'
2
+ require 'steamwebapi/user'
3
+ require 'steamwebapi/app'
@@ -0,0 +1,9 @@
1
+ require_relative 'steamapi'
2
+
3
+ module SteamApp
4
+ # ISteamNews
5
+ def self.get_news(appid, count='1', maxlength=nil)
6
+ args = {appid: appid, count: count, maxlength: maxlength}
7
+ SteamAPI.get('ISteamNews', 'GetNewsForApp', 'v0002', args)
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module SteamAPI
5
+ def self.get(interface, method, version, args = {})
6
+ json = true
7
+ if args.empty?
8
+ raise 'cannot retrieve data without arguments'
9
+ else
10
+ i = ''
11
+ args.each do |key, value|
12
+ # the first key needs ? in front of it
13
+ if key == args.keys[0]
14
+ i += "?#{key}=#{value}"
15
+ else
16
+ i += "&#{key}=#{value}"
17
+ end
18
+ end
19
+ domain = "http://api.steampowered.com/#{interface}/#{method}/#{version}/#{i}"
20
+ end
21
+ uri = Net::HTTP.get(URI(domain))
22
+ if json
23
+ JSON.parse(uri)
24
+ else
25
+ raise 'data not in JSON format'
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,79 @@
1
+ require_relative 'steamapi'
2
+
3
+ module SteamUser
4
+ def self.key(key)
5
+ @key = key
6
+ self
7
+ end
8
+
9
+ ## ISteamUser
10
+ def self.summaries(steamids=[])
11
+ args = {key: @key}
12
+ unless steamids.empty?
13
+ ids = ''
14
+ steamids.each do |id|
15
+ ids += "#{id},"
16
+ end
17
+ args[:steamids] = ids
18
+ end
19
+ SteamAPI.get('ISteamUser', 'GetPlayerSummaries', 'v0002', args)
20
+ end
21
+
22
+ def self.friend_list(steamid, relationship='friend')
23
+ args = {key: @key, steamid: steamid, relationship: relationship}
24
+ SteamAPI.get('ISteamUser', 'GetFriendList', 'v0001', args)
25
+ end
26
+
27
+ ## ISteamUserStats
28
+ def self.global_achievements_percent(gameid)
29
+ args = {gameid: gameid}
30
+ SteamAPI.get('ISteamUserStats', 'GetGlobalAchievementPercentagesForApp', 'v0002', args)
31
+ end
32
+
33
+ def self.global_stats(appid, count='1', name=[])
34
+ args = {appid: appid, count: count}
35
+ name.each do |v|
36
+ args.merge!("name[#{name.index(v)}]" => v)
37
+ end
38
+ SteamAPI.get('ISteamUserStats', 'GetGlobalStatsForGame', 'v0001', args)
39
+ end
40
+
41
+ def self.player_achievements(steamid, appid, language='english')
42
+ args = {key: @key, steamid: steamid, appid: appid, l: language}
43
+ SteamAPI.get('ISteamUserStats', 'GetPlayerAchievements', 'v0001', args)
44
+ end
45
+
46
+ def self.user_stats_for_game(steamid, appid, language='english')
47
+ args = {key: @key, steamid: steamid, appid: appid, l: language}
48
+ SteamAPI.get('ISteamUserStats', 'GetUserStatsForGame', 'v0002', args)
49
+ end
50
+
51
+ ## IPlayerService
52
+ def self.owned_games(steamid, appinfo=false, freegames=false)
53
+ args = {key: @key, steamid: steamid}
54
+
55
+ if appinfo
56
+ args[:include_appinfo] = '1'
57
+ else
58
+ args[:include_appinfo] = '0'
59
+ end
60
+
61
+ if freegames
62
+ args[:include_played_free_games] = '1'
63
+ else
64
+ args[:include_played_free_games] = '0'
65
+ end
66
+
67
+ SteamAPI.get('IPlayerService', 'GetOwnedGames', 'v0001', args)
68
+ end
69
+
70
+ def self.recently_played(steamid, count='1')
71
+ args = {key: @key, steamid: steamid, count: count}
72
+ SteamAPI.get('IPlayerService', 'GetRecentlyPlayedGames', 'v0001', args)
73
+ end
74
+
75
+ def self.is_playing_shared(steamid, appid)
76
+ args = {key: @key, steamid: steamid, appid_playing: appid}
77
+ SteamAPI.get('IPlayerService', 'IsPlayingSharedGame', 'v0001', args)
78
+ end
79
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "steamwebapi"
7
+ spec.version = "1.0.0"
8
+ spec.authors = ["kuzmaa"]
9
+ spec.email = [""]
10
+ spec.summary = %q{Steam Web API library in Ruby}
11
+ spec.description = %q{Retrieves and parses JSON data, which it retrieves from http://api.steampowered.com}
12
+ spec.homepage = "https://github.com/kuzmaa/steamwebapi"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steamwebapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - kuzmaa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Retrieves and parses JSON data, which it retrieves from http://api.steampowered.com
42
+ email:
43
+ - ''
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/steamwebapi.rb
54
+ - lib/steamwebapi/app.rb
55
+ - lib/steamwebapi/steamapi.rb
56
+ - lib/steamwebapi/user.rb
57
+ - steamwebapi.gemspec
58
+ homepage: https://github.com/kuzmaa/steamwebapi
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.0.14
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Steam Web API library in Ruby
82
+ test_files: []