steamworks 0.1.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c4799de857fa2c26896db50b3bda719056184eb9d7fd403599cc1d094e65748
4
- data.tar.gz: 3cbed9886f461c0be772d656c9a0bab73f691ad5dcb8e2c883a88d13cf9cd411
3
+ metadata.gz: 88601346707fc11c18002353b8e70d0e8375fd559c1a70a2d5ddb10eff13565f
4
+ data.tar.gz: 65ab3bf4f736e5984e221610607a45d87a9da12cc2a6fc671a0787a0a448b329
5
5
  SHA512:
6
- metadata.gz: e5b24e0c7d5e129b611bd64a2af5444145d648c74cd8e0fa3585d0929bdfa2d8b502f6c220fe10054137ce99cf3257fc8c8095b7085ff5e25c3eee775f55a27d
7
- data.tar.gz: 8e146d88dfa763a8f4f82288c3970dc0ce293b02db7e1b029f22f58aa661f799520986b336b4f98b5ea4195fcee9068319ec5fff1b11f1f057d9ebd01b29eea1
6
+ metadata.gz: 8dd57be9464caeb61287788d4a7d751f3191bebde1c19c3eaf67fae0690270e44a94655f895d68f3c1aa78d9f66c4b60d5337652a896e05d748fc1211aea1d6f
7
+ data.tar.gz: 195a73fd61f26a0e9d058521691b9b98183bf3e95bd0a3033eaff4511954f5577e6ca97016fb10eac5a389177731bcd81260ce126783584b98e2ec2e2a8a1b8b
data/.rubocop.yml CHANGED
@@ -13,5 +13,8 @@ Style/StringLiteralsInInterpolation:
13
13
  Enabled: true
14
14
  EnforcedStyle: double_quotes
15
15
 
16
+ Style/Documentation:
17
+ Enabled: false
18
+
16
19
  Layout/LineLength:
17
20
  Max: 120
data/Gemfile CHANGED
@@ -12,3 +12,7 @@ gem "minitest", "~> 5.0"
12
12
  gem "rubocop", "~> 1.21"
13
13
  gem "rubocop-minitest"
14
14
  gem "rubocop-rake"
15
+
16
+ gem "falcon", "~> 0.39"
17
+ gem "rack-cors", "~> 1.1"
18
+ gem "sinatra", "~>3.0"
data/README.md CHANGED
@@ -1,39 +1,27 @@
1
1
  # Steamworks
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Steamworks Web API client for Ruby.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/steamworks`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ [Steam official documentation](https://partner.steamgames.com/doc/webapi)
6
6
 
7
- ## Installation
7
+ ## Supported APIs
8
8
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
9
+ - [ISteamUserAuth Interface](https://partner.steamgames.com/doc/webapi/ISteamUserAuth)
10
+ - AuthenticateUserTicket
10
11
 
11
- Install the gem and add to the application's Gemfile by executing:
12
+ ## Example
12
13
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+ ```ruby
15
+ require "steamworks"
14
16
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
17
+ class Steamworks::Configure
18
+ set :key, "key"
19
+ set :appid, "appid"
20
+ set :identity, "identity"
21
+ end
16
22
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
23
+ steamworks_api = Steamworks::API.new
18
24
 
19
- ## Usage
25
+ steamworks_api.authenticate_user_ticket(ticket: params[:ticket]).to_json
20
26
 
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/steamworks. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/steamworks/blob/main/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the Steamworks project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/steamworks/blob/main/CODE_OF_CONDUCT.md).
27
+ ```
data/Rakefile CHANGED
@@ -13,4 +13,8 @@ require "rubocop/rake_task"
13
13
 
14
14
  RuboCop::RakeTask.new
15
15
 
16
+ task :serve do
17
+ exec "bin/server"
18
+ end
19
+
16
20
  task default: %i[test rubocop]
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Steamworks
4
+ class API
5
+ def initialize
6
+ @partner_conn = Steamworks::Connection.new(gateway: :partner)
7
+ @public_conn = Steamworks::Connection.new(gateway: :public)
8
+
9
+ config = Steamworks::Configure
10
+ @key = config.key
11
+ @appid = config.appid
12
+ @identity = config.identity
13
+ end
14
+
15
+ # https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUserTicket
16
+ # GET https://partner.steam-api.com/ISteamUserAuth/AuthenticateUserTicket/v1/
17
+ # key: string
18
+ # appid: uint32
19
+ # ticket: string
20
+ # identity: string
21
+ def authenticate_user_ticket(ticket: nil)
22
+ resp = @partner_conn.get("/ISteamUserAuth/AuthenticateUserTicket/v1/") do |req|
23
+ req.params = {
24
+ key: @key,
25
+ appid: @appid,
26
+ ticket: ticket,
27
+ identity: @identity
28
+ }
29
+ end
30
+
31
+ JSON.parse(resp.body)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Steamworks
4
+ class Configure
5
+ extend Configurable
6
+
7
+ set :key, "key"
8
+ set :appid, "appid"
9
+ set :identity, "identity"
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Steamworks
4
+ class Connection
5
+ def initialize(gateway: :partner)
6
+ raise ArgumentError, "Invalid gateway: #{gateway}" unless %i[partner public].include?(gateway)
7
+
8
+ @connection = Faraday.new(
9
+ url: gateway == :partner ? "https://partner.steam-api.com" : "https://api.steampowered.com",
10
+ headers: { "Content-Type" => "application/x-www-form-urlencoded" }
11
+ )
12
+ end
13
+
14
+ def get(path)
15
+ @connection.get(path) do |req|
16
+ yield(req) if block_given?
17
+ end
18
+ end
19
+
20
+ def post(path)
21
+ @connection.post(path) do |req|
22
+ yield(req) if block_given?
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # From https://github.com/midori-rb/midori.rb/blob/master/lib/midori/core_ext/configurable.rb
4
+
5
+ module Configurable
6
+ # Sets an option to the given value.
7
+ # @param [Symbol] option the name of config
8
+ # @param [Object] value value to the name
9
+ # @param [Boolean] read_only Generate option= method or not
10
+ # @return [nil] nil
11
+ def set(option, value = (not_set = true), read_only: false)
12
+ raise ArgumentError if not_set
13
+
14
+ setter = proc { |val| set option, val }
15
+ getter = proc { value }
16
+
17
+ define_singleton("#{option}=", setter) unless read_only
18
+ define_singleton(option, getter)
19
+ define_singleton("#{option}?", "!!#{option}") unless method_defined? "#{option}?"
20
+
21
+ self
22
+ end
23
+
24
+ private
25
+
26
+ # Dynamically defines a method on settings.
27
+ # @param [String] name method name
28
+ # @param [Proc] content method content
29
+ # @return [nil] nil
30
+ def define_singleton(name, content = Proc.new)
31
+ singleton_class.class_eval do
32
+ undef_method(name) if method_defined? name
33
+ if content.is_a?(String)
34
+ # rubocop:disable Style/DocumentDynamicEvalDefinition
35
+ class_eval("def #{name}() #{content}; end", __FILE__, __LINE__)
36
+ # rubocop:enable Style/DocumentDynamicEvalDefinition
37
+ else
38
+ define_method(name, &content)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Steamworks
4
+ class Error < StandardError; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Steamworks
4
- VERSION = "0.1.0"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/steamworks.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "faraday"
4
+
3
5
  require_relative "steamworks/version"
6
+ require_relative "steamworks/errors"
7
+
8
+ require_relative "steamworks/core_ext/configurable"
9
+ require_relative "steamworks/configure"
4
10
 
5
- module Steamworks
6
- class Error < StandardError; end
7
- # Your code goes here...
8
- end
11
+ require_relative "steamworks/connection"
12
+ require_relative "steamworks/api"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steamworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kowalski Dark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
13
27
  description:
14
28
  email:
15
29
  - github@akenonet.com
@@ -18,12 +32,16 @@ extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
34
  - ".rubocop.yml"
21
- - CODE_OF_CONDUCT.md
22
35
  - Gemfile
23
36
  - LICENSE.txt
24
37
  - README.md
25
38
  - Rakefile
26
39
  - lib/steamworks.rb
40
+ - lib/steamworks/api.rb
41
+ - lib/steamworks/configure.rb
42
+ - lib/steamworks/connection.rb
43
+ - lib/steamworks/core_ext/configurable.rb
44
+ - lib/steamworks/errors.rb
27
45
  - lib/steamworks/version.rb
28
46
  homepage: https://github.com/yet-another-ai/steamworks.rb
29
47
  licenses:
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at nemo.zhang@yetanother.ai. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.