Ryze 0.1.0 → 0.2.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: 9c1ffc8a0a48b952413020566a3adfc125fe69acd7b15286fb6649383683a6b6
4
- data.tar.gz: 167af25e1e8087b48e9f67b359cbeb0202347e7a79d4e8990ddcc2248cd88747
3
+ metadata.gz: 9cfbeff4b1caa0fe79b4a7e1fcb47b219f332e4fc8e2835461fa2b08dd88c4ca
4
+ data.tar.gz: cb693eb925b0fe22305f35ec8f97260b45c537450534e15c2bd34b8e364abcac
5
5
  SHA512:
6
- metadata.gz: c7483f8ad68979857238802950ce017e8445b8643617d695b9a242c4aba1910525207b1d9e640ffdd1652aa1b478b4a9ddfed78027bac86c2e275103fcd449a7
7
- data.tar.gz: 86e97a917c1cc8099610434c1026de42788e72c4a8c651830848be935f9792eb8899b9605cc6014613c2fdf01229dbfa814afaefd7b7b6f3ea58e7f1468cc666
6
+ metadata.gz: 1e819e04cf37c7dbb378365a6f6b0b7f0b3cff02f340f3ca456b9c06272b67891dae413a89db88332e60918baebbf6b0fd4e46308e3000097b5d8c884691a393
7
+ data.tar.gz: 1fd6a0705e23a9cdd85235113de6a50a93f42c5d1521e59346d14b5f7d646ca7c0d06cd4e3540b9bb60801b0e0faf10ca4373a3ea225ec25413b4174c0b6061b
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
- TargetRubyVersion: 2.6
4
+ TargetRubyVersion: 3.0
3
5
 
4
6
  Style/StringLiterals:
5
7
  Enabled: true
@@ -13,7 +15,7 @@ Layout/LineLength:
13
15
  Max: 120
14
16
 
15
17
  Metrics/BlockLength:
16
- ExcludedMethods:
18
+ AllowedMethods:
17
19
  - 'describe'
18
20
  - 'context'
19
21
  - 'it'
@@ -22,3 +24,13 @@ Naming/FileName:
22
24
  Exclude:
23
25
  - 'lib/Ryze.rb'
24
26
  - 'spec/Ryze_spec.rb'
27
+
28
+ RSpec/NestedGroups:
29
+ Enabled: false
30
+
31
+ RSpec/FilePath:
32
+ Enabled: false
33
+
34
+ RSpec/MultipleMemoizedHelpers:
35
+ Max: 7
36
+ AllowSubject: true
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## [Unreleased]
1
+ ## [0.2.0] - 2023-04-12
2
+
3
+ - Lots of changes
2
4
 
3
5
  ## [0.1.0] - 2023-05-07
4
6
 
data/Gemfile CHANGED
@@ -10,3 +10,9 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
+
14
+ gem "rubocop-rspec", "~> 2.29"
15
+
16
+ gem "racc"
17
+
18
+ gem "addressable"
data/Gemfile.lock CHANGED
@@ -1,22 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Ryze (0.1.0)
5
- faraday (~> 2.7.4)
4
+ Ryze (0.2.0)
5
+ addressable (~> 2.7)
6
+ faraday (~> 2.9.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ addressable (2.8.6)
12
+ public_suffix (>= 2.0.2, < 6.0)
10
13
  ast (2.4.2)
11
14
  diff-lcs (1.5.0)
12
- faraday (2.7.4)
13
- faraday-net_http (>= 2.0, < 3.1)
14
- ruby2_keywords (>= 0.0.4)
15
+ faraday (2.9.0)
16
+ faraday-net_http (>= 2.0, < 3.2)
15
17
  faraday-net_http (3.0.2)
16
18
  json (2.6.3)
17
19
  parallel (1.23.0)
18
20
  parser (3.2.2.1)
19
21
  ast (~> 2.4.1)
22
+ public_suffix (5.0.5)
23
+ racc (1.7.3)
20
24
  rainbow (3.1.1)
21
25
  rake (13.0.6)
22
26
  regexp_parser (2.8.0)
@@ -46,19 +50,33 @@ GEM
46
50
  unicode-display_width (>= 2.4.0, < 3.0)
47
51
  rubocop-ast (1.28.1)
48
52
  parser (>= 3.2.1.0)
53
+ rubocop-capybara (2.20.0)
54
+ rubocop (~> 1.41)
55
+ rubocop-factory_bot (2.25.1)
56
+ rubocop (~> 1.41)
57
+ rubocop-rspec (2.29.1)
58
+ rubocop (~> 1.40)
59
+ rubocop-capybara (~> 2.17)
60
+ rubocop-factory_bot (~> 2.22)
61
+ rubocop-rspec_rails (~> 2.28)
62
+ rubocop-rspec_rails (2.28.3)
63
+ rubocop (~> 1.40)
49
64
  ruby-progressbar (1.13.0)
50
- ruby2_keywords (0.0.5)
51
65
  unicode-display_width (2.4.2)
52
66
 
53
67
  PLATFORMS
54
68
  x86_64-darwin-22
69
+ x86_64-darwin-23
55
70
  x86_64-linux
56
71
 
57
72
  DEPENDENCIES
58
73
  Ryze!
74
+ addressable
75
+ racc
59
76
  rake (~> 13.0)
60
77
  rspec (~> 3.0)
61
78
  rubocop (~> 1.21)
79
+ rubocop-rspec (~> 2.29)
62
80
 
63
81
  BUNDLED WITH
64
82
  2.4.1
data/README.md CHANGED
@@ -8,11 +8,16 @@ Ryze is a Ruby gem that provides a simple interface to the League of Legends Rio
8
8
 
9
9
  Install the gem and add to the application's Gemfile by executing:
10
10
 
11
- $ bundle add ryze
11
+ $ bundle add Ryze
12
12
 
13
13
  If bundler is not being used to manage dependencies, install the gem by executing:
14
14
 
15
- $ gem install ryze
15
+ $ gem install Ryze
16
+
17
+
18
+ ## Documentation
19
+
20
+ The documentation for this gem can be found [here](https://rubydoc.info/github/clement0910/Ryze/master)
16
21
 
17
22
  ## Usage
18
23
 
@@ -24,7 +29,7 @@ Than, you can create a new client by passing your API key as an argument:
24
29
  ```ruby
25
30
  require 'ryze'
26
31
 
27
- client = Client.new(api_key: 'YOUR_API_KEY')
32
+ client = Ryze::Client.new(api_key: 'YOUR_API_KEY')
28
33
  ```
29
34
 
30
35
  You can then use the client to make requests to the Riot API:
data/lib/Ryze/client.rb CHANGED
@@ -27,10 +27,20 @@ module Ryze
27
27
  MatchResource.new(self)
28
28
  end
29
29
 
30
+ # @return [AccountResource] A new instance of AccountResource.
31
+ def account
32
+ AccountResource.new(self)
33
+ end
34
+
35
+ # @return [SpectatorResource] A new instance of SpectatorResource.
36
+ def spectator
37
+ SpectatorResource.new(self)
38
+ end
39
+
30
40
  # @return [Faraday::Connection] A new instance of Faraday::Connection or the current instance.
31
41
  def connection
32
42
  @connection ||= Faraday.new do |conn|
33
- conn.request :json
43
+ conn.headers["X-Riot-Token"] = @api_key
34
44
  conn.response :json, content_type: "application/json"
35
45
  conn.adapter adapter, @stubs
36
46
  end
data/lib/Ryze/object.rb CHANGED
@@ -5,9 +5,8 @@ require "ostruct"
5
5
  module Ryze
6
6
  # Object is a base class for all objects returned from the Riot API.
7
7
  class Object < OpenStruct
8
- def initialize(attributes, client = nil)
8
+ def initialize(attributes)
9
9
  super to_ostruct(attributes)
10
- @client = client
11
10
  end
12
11
 
13
12
  private
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryze
4
+ # Match is a class corresponding to the AccountDto Riot API object.
5
+ class Account < Object; end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryze
4
+ # Spectator is a class corresponding to the CurrentGameInfo Riot API object.
5
+ class Spectator < Object; end
6
+ end
@@ -2,13 +2,5 @@
2
2
 
3
3
  module Ryze
4
4
  # Summoner is a class corresponding to the SummonerDto Riot API object.
5
- class Summoner < Object
6
- # Retrieve the last match of the summoner.
7
- #
8
- # @return [Match] Match object.
9
- def retrieve_last_match
10
- match_id = MatchResource.new(@client).retrieve_match_list_by_puuid(puuid: puuid, count: 1).first
11
- MatchResource.new(@client).retrieve_match(match_id: match_id)
12
- end
13
- end
5
+ class Summoner < Object; end
14
6
  end
data/lib/Ryze/resource.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "addressable/uri"
4
+
3
5
  module Ryze
4
6
  # Resource is a class that provides a base for all Riot API resources.
5
7
  class Resource
@@ -15,10 +17,9 @@ module Ryze
15
17
  #
16
18
  # @param url [String] The URL to make the request to.
17
19
  # @param params [Hash] The parameters to pass to the request.
18
- # @param headers [Hash] The headers to pass to the request additional to the default headers.
19
20
  # @return [Faraday::Response] The response from the Riot API trailed by the Ryze response handler.
20
- def get_request(url, params: {}, headers: {})
21
- handle_response client.connection.get(@base_url + url, params, default_headers.merge(headers))
21
+ def get_request(url, params: {})
22
+ handle_response client.connection.get(Addressable::URI.encode(url), params)
22
23
  end
23
24
 
24
25
  private
@@ -34,9 +35,5 @@ module Ryze
34
35
 
35
36
  response
36
37
  end
37
-
38
- def default_headers
39
- { "X-Riot-Token" => client.api_key }
40
- end
41
38
  end
42
39
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryze
4
+ # AccountResource is a class corresponding to the AccountV1 Riot API endpoint.
5
+ class AccountResource < Resource
6
+ BASE_URL = "https://europe.api.riotgames.com/riot/account/v1/accounts"
7
+
8
+ # Retrieve an account by Riot ID.
9
+ #
10
+ # @param game_name [String] Game name of the account.
11
+ # @param tag_line [String] Tag line of the account.
12
+ # @return [Account] Account object.
13
+ def retrieve_account_by_riot_id(game_name:, tag_line:)
14
+ Account.new get_request("#{BASE_URL}/by-riot-id/#{game_name}/#{tag_line}").body
15
+ end
16
+ end
17
+ end
@@ -3,17 +3,14 @@
3
3
  module Ryze
4
4
  # MatchResource is a class corresponding to the MatchV5 Riot API endpoint.
5
5
  class MatchResource < Resource
6
- def initialize(client)
7
- super
8
- @base_url = "https://europe.api.riotgames.com/lol/match/v5"
9
- end
6
+ BASE_URL = "https://europe.api.riotgames.com/lol/match/v5"
10
7
 
11
8
  # Retrieve a match by match ID.
12
9
  #
13
10
  # @param match_id [String] Match ID.
14
11
  # @return [Match] Match object.
15
12
  def retrieve_match(match_id:)
16
- Match.new get_request("/matches/#{match_id}").body
13
+ Match.new get_request("#{BASE_URL}/matches/#{match_id}").body
17
14
  end
18
15
 
19
16
  # Retrieve a match list by account puuid.
@@ -22,7 +19,7 @@ module Ryze
22
19
  # @param params [Hash] Parameters to pass to the request.
23
20
  # @return [Array<String>] Match IDs.
24
21
  def retrieve_match_list_by_puuid(puuid:, **params)
25
- Array.new get_request("/matches/by-puuid/#{puuid}/ids", params: params).body
22
+ Array.new get_request("#{BASE_URL}/matches/by-puuid/#{puuid}/ids", params: params).body
26
23
  end
27
24
  end
28
25
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryze
4
+ # SpectatorResource is a class corresponding to the SpectatorV5 Riot API endpoint.
5
+ class SpectatorResource < Resource
6
+ BASE_URL = "https://euw1.api.riotgames.com/lol/spectator/v5"
7
+
8
+ # Retrieve a current game by summoner puuid.
9
+ #
10
+ # @param puuid [String] Summoner puuid.
11
+ # @return [Spectator] Spectator object.
12
+ def retrieve_current_game_by_puuid(puuid:)
13
+ Spectator.new get_request("#{BASE_URL}/active-games/by-summoner/#{puuid}").body
14
+ end
15
+ end
16
+ end
@@ -3,25 +3,14 @@
3
3
  module Ryze
4
4
  # SummonerResource is a class corresponding to the SummonerV4 Riot API endpoint.
5
5
  class SummonerResource < Resource
6
- def initialize(client)
7
- super
8
- @base_url = "https://euw1.api.riotgames.com/lol/summoner/v4"
9
- end
10
-
11
- # Retrieve a summoner by summoner name.
12
- #
13
- # @param summoner_name [String] Summoner name.
14
- # @return [Summoner] Summoner object.
15
- def retrieve_summoner_by_name(summoner_name:)
16
- Summoner.new get_request("/summoners/by-name/#{summoner_name}").body, @client
17
- end
6
+ BASE_URL = "https://euw1.api.riotgames.com/lol/summoner/v4"
18
7
 
19
8
  # Retrieve a summoner by summoner puuid.
20
9
  #
21
10
  # @param puuid [String] Summoner puuid.
22
11
  # @return [Summoner] Summoner object.
23
12
  def retrieve_summoner_by_puuid(puuid:)
24
- Summoner.new get_request("/summoners/by-puuid/#{puuid}").body, @client
13
+ Summoner.new get_request("#{BASE_URL}/summoners/by-puuid/#{puuid}").body
25
14
  end
26
15
 
27
16
  # Retrieve a summoner by summoner account ID.
@@ -29,7 +18,7 @@ module Ryze
29
18
  # @param account_id [String] Summoner account ID.
30
19
  # @return [Summoner] Summoner object.
31
20
  def retrieve_summoner_by_account_id(account_id:)
32
- Summoner.new get_request("/summoners/by-account/#{account_id}").body, @client
21
+ Summoner.new get_request("#{BASE_URL}/summoners/by-account/#{account_id}").body
33
22
  end
34
23
 
35
24
  # Retrieve a summoner by summoner ID.
@@ -37,7 +26,7 @@ module Ryze
37
26
  # @param summoner_id [String] Summoner ID.
38
27
  # @return [Summoner] Summoner object.
39
28
  def retrieve_summoner_by_summoner_id(summoner_id:)
40
- Summoner.new get_request("/summoners/#{summoner_id}").body, @client
29
+ Summoner.new get_request("#{BASE_URL}/summoners/#{summoner_id}").body
41
30
  end
42
31
  end
43
32
  end
data/lib/Ryze/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Ryze
4
4
  # The current version of the Ryze gem.
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
data/lib/Ryze.rb CHANGED
@@ -11,7 +11,11 @@ module Ryze
11
11
 
12
12
  autoload :Summoner, "Ryze/objects/summoner"
13
13
  autoload :Match, "Ryze/objects/match"
14
+ autoload :Account, "Ryze/objects/account"
15
+ autoload :Spectator, "Ryze/objects/spectator"
14
16
 
15
17
  autoload :SummonerResource, "Ryze/resources/summoner"
16
18
  autoload :MatchResource, "Ryze/resources/match"
19
+ autoload :AccountResource, "Ryze/resources/account"
20
+ autoload :SpectatorResource, "Ryze/resources/spectator"
17
21
  end
@@ -0,0 +1,4 @@
1
+ module Ryze
2
+ class Account
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Ryze
2
+ class AccountResource
3
+ BASE_URL: String
4
+
5
+ def retrieve_account_by_riot_id: (game_name: String, tag_line: String) -> Account
6
+ end
7
+ end
@@ -1,6 +1,6 @@
1
1
  module Ryze
2
2
  class MatchResource
3
- @base_url: String
3
+ BASE_URL: String
4
4
 
5
5
  def retrieve_match: (match_id: String) -> Match
6
6
 
@@ -0,0 +1,4 @@
1
+ module Ryze
2
+ class Spectator
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Ryze
2
+ class SpectatorResource
3
+ BASE_URL: String
4
+
5
+ def retrieve_current_game_by_puuid: (puuid: String) -> Spectator
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
1
  module Ryze
2
- class Sumonner
2
+ class Summoner
3
3
  end
4
4
  end
@@ -1,13 +1,13 @@
1
1
  module Ryze
2
- class SummonerResource < Resource
3
- @base_url: String
2
+ class SummonerResource
3
+ BASE_URL: String
4
4
 
5
- def retrieve_summoner_by_name: (summoner_name: String) -> Sumonner
5
+ def retrieve_summoner_by_name: (summoner_name: String) -> Summoner
6
6
 
7
- def retrieve_summoner_by_puuid: (puuid: String) -> Sumonner
7
+ def retrieve_summoner_by_puuid: (puuid: String) -> Summoner
8
8
 
9
- def retrieve_summoner_by_account_id: (account_id: String) -> Sumonner
9
+ def retrieve_summoner_by_account_id: (account_id: String) -> Summoner
10
10
 
11
- def retrieve_summoner_by_summoner_id: (summoner_id: String) -> Sumonner
11
+ def retrieve_summoner_by_summoner_id: (summoner_id: String) -> Summoner
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ryze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clément Sapt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
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
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 2.7.4
33
+ version: 2.9.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 2.7.4
40
+ version: 2.9.0
27
41
  description: 'Ruby wrapper for the Riot Games API. Riot Games API can be found here:
28
42
  https://developer.riotgames.com/apis'
29
43
  email:
@@ -41,23 +55,30 @@ files:
41
55
  - LICENSE.txt
42
56
  - README.md
43
57
  - Rakefile
44
- - Ryze.gemspec
45
58
  - lib/Ryze.rb
46
59
  - lib/Ryze/client.rb
47
60
  - lib/Ryze/error.rb
48
61
  - lib/Ryze/object.rb
62
+ - lib/Ryze/objects/account.rb
49
63
  - lib/Ryze/objects/match.rb
64
+ - lib/Ryze/objects/spectator.rb
50
65
  - lib/Ryze/objects/summoner.rb
51
66
  - lib/Ryze/resource.rb
67
+ - lib/Ryze/resources/account.rb
52
68
  - lib/Ryze/resources/match.rb
69
+ - lib/Ryze/resources/spectator.rb
53
70
  - lib/Ryze/resources/summoner.rb
54
71
  - lib/Ryze/version.rb
55
72
  - sig/Ryze.rbs
56
- - sig/ryze/client.rbs
57
- - sig/ryze/match.rbs
58
- - sig/ryze/match_resource.rbs
59
- - sig/ryze/summoner.rbs
60
- - sig/ryze/summoner_resource.rbs
73
+ - sig/Ryze/account.rbs
74
+ - sig/Ryze/account_resource.rbs
75
+ - sig/Ryze/client.rbs
76
+ - sig/Ryze/match.rbs
77
+ - sig/Ryze/match_resource.rbs
78
+ - sig/Ryze/spectator.rbs
79
+ - sig/Ryze/spectator_resource.rbs
80
+ - sig/Ryze/summoner.rbs
81
+ - sig/Ryze/summoner_resource.rbs
61
82
  homepage: https://github.com/clement0910/Ryze
62
83
  licenses:
63
84
  - MIT
@@ -73,14 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
94
  requirements:
74
95
  - - ">="
75
96
  - !ruby/object:Gem::Version
76
- version: 2.6.0
97
+ version: '3.0'
77
98
  required_rubygems_version: !ruby/object:Gem::Requirement
78
99
  requirements:
79
100
  - - ">="
80
101
  - !ruby/object:Gem::Version
81
102
  version: '0'
82
103
  requirements: []
83
- rubygems_version: 3.4.1
104
+ rubygems_version: 3.5.3
84
105
  signing_key:
85
106
  specification_version: 4
86
107
  summary: Simple Ruby wrapper for the Riot Games API.
data/Ryze.gemspec DELETED
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/Ryze/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "Ryze"
7
- spec.version = Ryze::VERSION
8
- spec.authors = ["Clément Sapt"]
9
- spec.email = ["clementsapt@gmail.com"]
10
-
11
- spec.summary = "Simple Ruby wrapper for the Riot Games API."
12
- spec.description = "Ruby wrapper for the Riot Games API. Riot Games API can be found here: https://developer.riotgames.com/apis"
13
- spec.homepage = "https://github.com/clement0910/Ryze"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/clement0910/Ryze"
19
- spec.metadata["changelog_uri"] = "https://github.com/clement0910/Ryze/blob/master/CHANGELOG.md"
20
-
21
- spec.files = Dir.chdir(__dir__) do
22
- `git ls-files -z`.split("\x0").reject do |f|
23
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
24
- end
25
- end
26
-
27
- spec.require_paths = ["lib"]
28
-
29
- spec.add_dependency "faraday", "~> 2.7.4"
30
- end
File without changes
File without changes