steamworks 1.0.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: 66e3130c3dd34ba2714b8a7514fa3280497caaaf346dd2e94c860d44e2d545b2
4
- data.tar.gz: '009b2c5edece72971ec32da7861280830c6e61a12e1a96b8df3fb4c86e229b73'
3
+ metadata.gz: 88601346707fc11c18002353b8e70d0e8375fd559c1a70a2d5ddb10eff13565f
4
+ data.tar.gz: 65ab3bf4f736e5984e221610607a45d87a9da12cc2a6fc671a0787a0a448b329
5
5
  SHA512:
6
- metadata.gz: 2f0b58ecf7313e380338c7b89a4ec3a83cf637021473fc1473d840faebf7a7ed001e88d91e1fc16f6f9c3ec9b2f4b83c1a435fab8357ee3344cfdea8a0a27425
7
- data.tar.gz: 381a60d5c29804536aee314717e9a922cb95fea8bcd33088908b54dbc0747e300c76a12a8269f16264383fbd31568dcb21f0676a722cc734a63f2c7034f2f471
6
+ metadata.gz: 8dd57be9464caeb61287788d4a7d751f3191bebde1c19c3eaf67fae0690270e44a94655f895d68f3c1aa78d9f66c4b60d5337652a896e05d748fc1211aea1d6f
7
+ data.tar.gz: 195a73fd61f26a0e9d058521691b9b98183bf3e95bd0a3033eaff4511954f5577e6ca97016fb10eac5a389177731bcd81260ce126783584b98e2ec2e2a8a1b8b
data/README.md CHANGED
@@ -12,16 +12,16 @@ Steamworks Web API client for Ruby.
12
12
  ## Example
13
13
 
14
14
  ```ruby
15
- require 'steamworks'
15
+ require "steamworks"
16
16
 
17
- api = Steamworks::API.new
18
-
19
- api.configure do |config|
20
- config.key = "your_steam_web_api_key"
21
- config.appid = "your_steam_app_id"
22
- config.identity = "your_steam_identity"
17
+ class Steamworks::Configure
18
+ set :key, "key"
19
+ set :appid, "appid"
20
+ set :identity, "identity"
23
21
  end
24
22
 
25
- puts api.authenticate_user_ticket(ticket: "ticket")
23
+ steamworks_api = Steamworks::API.new
24
+
25
+ steamworks_api.authenticate_user_ticket(ticket: params[:ticket]).to_json
26
26
 
27
27
  ```
@@ -2,12 +2,14 @@
2
2
 
3
3
  module Steamworks
4
4
  class API
5
- include Steamworks::Configureable
6
- attr_accessor :key, :appid, :identity
7
-
8
5
  def initialize
9
6
  @partner_conn = Steamworks::Connection.new(gateway: :partner)
10
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
11
13
  end
12
14
 
13
15
  # https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUserTicket
@@ -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,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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Steamworks
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/steamworks.rb CHANGED
@@ -4,7 +4,9 @@ require "faraday"
4
4
 
5
5
  require_relative "steamworks/version"
6
6
  require_relative "steamworks/errors"
7
- require_relative "steamworks/configurable"
8
- require_relative "steamworks/connection"
9
7
 
8
+ require_relative "steamworks/core_ext/configurable"
9
+ require_relative "steamworks/configure"
10
+
11
+ require_relative "steamworks/connection"
10
12
  require_relative "steamworks/api"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steamworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.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-06 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,8 +38,9 @@ files:
38
38
  - Rakefile
39
39
  - lib/steamworks.rb
40
40
  - lib/steamworks/api.rb
41
- - lib/steamworks/configurable.rb
41
+ - lib/steamworks/configure.rb
42
42
  - lib/steamworks/connection.rb
43
+ - lib/steamworks/core_ext/configurable.rb
43
44
  - lib/steamworks/errors.rb
44
45
  - lib/steamworks/version.rb
45
46
  homepage: https://github.com/yet-another-ai/steamworks.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Steamworks
4
- module Configureable
5
- def configure
6
- yield self
7
- end
8
- end
9
- end