relic_link 0.1.1 → 0.1.2

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: b1a9653c0649e12019ff4063d809eda6a317fa0eb0dbc1bf7518df0dc2a92ef3
4
- data.tar.gz: 476e0b48c7753f552fbb1e0b33f1366c1683b75845f4244716574a39bb62c161
3
+ metadata.gz: d2c116d6c2b0d54175c3bd00e7989271a969cda9f449e9a4ed2cf39e9680a830
4
+ data.tar.gz: 7fc992b307a307571689b9b882a749f98b9b704e91c33e96a1efc2ab98283148
5
5
  SHA512:
6
- metadata.gz: a5337418bfd5336e1f1e2e521dab13ae49e5e711e94bee4b4b5499bf703344d8cc82e6515f75deae727c3718a425a2fe0ad3a7a88ffd7f2e1f926b726dd29b26
7
- data.tar.gz: e0d92805ae1aadba0cd464e12b2a056f9112d40f525f41982dafab433b04dd5c8ec0e9979c4fc4fab5b01a914b48b0a76d62f22a4cc56c7d4795e335eedff69a
6
+ metadata.gz: fe144e6f63b10cf4692c796860aa35d682d4e9738aab9ac0af471465ec7415628d36825581f2f505f07b40af7013052cfd8d82e647c5113b250325b8424127e8
7
+ data.tar.gz: 9c84ca93917faf1262bbdcd49446ec5d6bf813df88e984bf33c19c3665a37c3b7b34b6056485e8fb9cb45c06fb71a236c2a810633eeff6d8e63cd09b30260973
data/.rubocop.yml CHANGED
@@ -5,5 +5,11 @@ AllCops:
5
5
  Metrics/BlockLength:
6
6
  Enabled: false
7
7
 
8
+ Style/GlobalStdStream:
9
+ Enabled: false
10
+
11
+ Style/ModuleFunction:
12
+ Enabled: false
13
+
8
14
  Style/NumericLiterals:
9
15
  Enabled: false
data/Gemfile.lock CHANGED
@@ -59,6 +59,7 @@ GEM
59
59
 
60
60
  PLATFORMS
61
61
  arm64-darwin-21
62
+ x86_64-linux
62
63
 
63
64
  DEPENDENCIES
64
65
  rake (~> 13.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RelicLink
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/relic_link.svg)](https://badge.fury.io/rb/relic_link) [![Documentation](https://img.shields.io/badge/View-Documentation-blue.svg)](https://rubydoc.info/github/ryantaylor/relic_link/v0.1.1)
3
+ [![Gem Version](https://badge.fury.io/rb/relic_link.svg)](https://badge.fury.io/rb/relic_link) [![Documentation](https://img.shields.io/badge/View-Documentation-blue.svg)](https://rubydoc.info/github/ryantaylor/relic_link/v0.1.2)
4
4
 
5
5
  A client wrapper for Relic APIs. Currently supports the Company of Heroes 3 leaderboard, stats, and recent matches API.
6
6
 
@@ -29,7 +29,7 @@ client.recent_match_history(profile_ids: [8230])
29
29
  client.recent_match_history_by_profile_id(8230)
30
30
  client.personal_stats(profile_ids: [8230])
31
31
  ```
32
- Consult the [documentation](https://rubydoc.info/github/ryantaylor/relic_link/v0.1.1) for all endpoints that have been discovered and are currently queryable. Note that Relic does not publish official documentation for their endpoints, so the functionality here is based on best estimates and is subject to change without warning. Please open an issue if you are aware of endpoints that are not exposed in this library!
32
+ Consult the [documentation](https://rubydoc.info/github/ryantaylor/relic_link/v0.1.2) for all endpoints that have been discovered and are currently queryable. Note that Relic does not publish official documentation for their endpoints, so the functionality here is based on best estimates and is subject to change without warning. Please open an issue if you are aware of endpoints that are not exposed in this library!
33
33
 
34
34
  ## Contributing
35
35
 
@@ -13,6 +13,34 @@ module RelicLink
13
13
  include Faraday::Connection
14
14
  include Api::Endpoints
15
15
  include Util
16
+
17
+ attr_accessor(*RelicLink::Coh3::Config::ATTRIBUTES)
18
+
19
+ # Initializes a new client.
20
+ #
21
+ # @option options [Logger] :logger
22
+ # Instance of a logging class. If not provided, defaults to +STDOUT+ at +Logging::WARN+.
23
+ #
24
+ # @return [Client]
25
+ def initialize(options = {})
26
+ RelicLink::Coh3::Config::ATTRIBUTES.each do |key|
27
+ send("#{key}=", options.fetch(key, RelicLink::Coh3.config.send(key)))
28
+ end
29
+ @logger ||= RelicLink::Coh3::Config.logger || RelicLink::Logger.default
30
+ end
31
+
32
+ class << self
33
+ # Set configuration options. Can be set on the returned object
34
+ # directly or in a block.
35
+ def configure
36
+ block_given? ? yield(RelicLink::Coh3::Config) : RelicLink::Coh3::Config
37
+ end
38
+
39
+ # Current config module.
40
+ def config
41
+ RelicLink::Coh3::Config
42
+ end
43
+ end
16
44
  end
17
45
  end
18
46
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RelicLink
4
+ # Company of Heroes 3 API wrapper.
5
+ module Coh3
6
+ # Configuration options for the CoH3 API client.
7
+ module Config
8
+ extend self
9
+
10
+ # Configurable attributes
11
+ ATTRIBUTES = %i[
12
+ logger
13
+ ].freeze
14
+
15
+ attr_accessor(*ATTRIBUTES)
16
+
17
+ # Set all config options back to defaults.
18
+ def reset
19
+ self.logger = nil
20
+ end
21
+
22
+ module_function :reset
23
+ end
24
+
25
+ class << self
26
+ # Set configuration options. Can be set on the returned object
27
+ # directly or in a block.
28
+ def configure
29
+ block_given? ? yield(Config) : Config
30
+ end
31
+
32
+ # Current config module.
33
+ def config
34
+ Config
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ RelicLink::Coh3::Config.reset
@@ -16,7 +16,7 @@ module RelicLink
16
16
  ) do |f|
17
17
  f.params[:title] = 'coh3'
18
18
 
19
- f.response :logger
19
+ f.response :logger, logger if logger
20
20
  f.response :mashify
21
21
  f.response :json
22
22
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module RelicLink
6
+ # Default logging class.
7
+ class Logger < ::Logger
8
+ # Default logger, used when a logger is not provided in config.
9
+ # Default log output is +STDOUT+ and log level is +Logger::WARN+.
10
+ #
11
+ # @return [::Logger]
12
+ def self.default
13
+ return @default if @default
14
+
15
+ logger = new STDOUT
16
+ logger.level = Logger::WARN
17
+ @default = logger
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelicLink
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/relic_link.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
+ require 'hashie'
4
5
  require 'json'
5
6
 
7
+ require_relative 'relic_link/logger'
8
+ require_relative 'relic_link/coh3/config'
9
+
6
10
  require_relative 'relic_link/coh3/util'
7
11
  require_relative 'relic_link/coh3/api/endpoints'
8
12
  require_relative 'relic_link/faraday/request'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relic_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryantaylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-10 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -77,9 +77,11 @@ files:
77
77
  - lib/relic_link/coh3/api/endpoints/matches.rb
78
78
  - lib/relic_link/coh3/api/endpoints/stats.rb
79
79
  - lib/relic_link/coh3/client.rb
80
+ - lib/relic_link/coh3/config.rb
80
81
  - lib/relic_link/coh3/faraday/connection.rb
81
82
  - lib/relic_link/coh3/util.rb
82
83
  - lib/relic_link/faraday/request.rb
84
+ - lib/relic_link/logger.rb
83
85
  - lib/relic_link/version.rb
84
86
  - relic_link.gemspec
85
87
  - sig/relic_link.rbs