sorare-rewards 1.4.2 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +1 -1
  3. data/.rubocop.yml +4 -0
  4. data/Gemfile.lock +24 -12
  5. data/lib/sorare/rewards/configuration.rb +1 -1
  6. data/lib/sorare/rewards/game_week.rb +2 -1
  7. data/lib/sorare/rewards/interactors/allocations/compute_for_game_week.rb +2 -1
  8. data/lib/sorare/rewards/interactors/allocations/compute_for_league.rb +4 -3
  9. data/lib/sorare/rewards/interactors/allocations/compute_for_quality.rb +4 -3
  10. data/lib/sorare/rewards/interactors/allocations/compute_for_rarity.rb +2 -1
  11. data/lib/sorare/rewards/interactors/build.rb +2 -1
  12. data/lib/sorare/rewards/interactors/cards/pick_for_division.rb +2 -1
  13. data/lib/sorare/rewards/interactors/cards/pick_for_division_and_rarity.rb +2 -1
  14. data/lib/sorare/rewards/interactors/cards/pick_for_division_rarity_and_quality.rb +3 -1
  15. data/lib/sorare/rewards/interactors/cards/pick_for_game_week.rb +2 -1
  16. data/lib/sorare/rewards/interactors/cards/pick_for_league.rb +3 -1
  17. data/lib/sorare/rewards/interactors/pick.rb +2 -1
  18. data/lib/sorare/rewards/interactors/prize_pools/compute_for_division.rb +2 -1
  19. data/lib/sorare/rewards/interactors/prize_pools/compute_for_game_week.rb +2 -1
  20. data/lib/sorare/rewards/interactors/prize_pools/compute_for_league.rb +4 -3
  21. data/lib/sorare/rewards/interactors/supply/compute_for_game_week.rb +2 -1
  22. data/lib/sorare/rewards/interactors/supply/compute_for_quality.rb +2 -1
  23. data/lib/sorare/rewards/interactors/supply/compute_for_rarity.rb +3 -2
  24. data/lib/sorare/rewards/interactors/tiers/qualify_players.rb +2 -1
  25. data/lib/sorare/rewards/interactors/tiers/qualify_supply.rb +2 -1
  26. data/lib/sorare/rewards/version.rb +1 -1
  27. data/sorare-rewards.gemspec +6 -4
  28. metadata +26 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6d8d21c6c8da818dfecacdb8ff179dfa81e39d01f8470f1009b36afe45a06c2
4
- data.tar.gz: 0303c1e4e365b4879712cab90da1553e60cc07b78d0810b2790720e31365be2a
3
+ metadata.gz: 34c346533b8e45eb7b3ab31ac8d7480e163b46217ffa83e360b57725d7183fe7
4
+ data.tar.gz: 783c5f5fb8f09d033d144ed23139957e934055a063defb0755969f677a238e55
5
5
  SHA512:
6
- metadata.gz: 5facf11a38d2ec192177f46f4b13b2a3f4d63379b8d586266255f5dae906b7a0ed660d0cf3166b68399c1269dd271e0f63711569744587839ce63b52934416ee
7
- data.tar.gz: de7c3eed4459e498e528c419ade463e1972082d251559ce75908152ca6869e9535f2334e86604fa51a79c1dbc2de09efebbe0e2eee4450b213e37a8c8da3df54
6
+ metadata.gz: e2cc95273ce7a36b4048f1be07487a82bd729391677b4cfa6ff210ea5907b98dbaa0242a52e07931ac84a121e1e1d56f5f4fbf010ab3284a44eaab3bac81f1a6
7
+ data.tar.gz: 21dce2b8e32dee2c43268c251760b45a66f697a8caecb2e78668a3729595cdc37ecd12abdba74f0df506e2ea9b69fc61627284a935c2437a8a1a3efbea508658
data/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: ruby:3.0
1
+ image: ruby:3.1.0
2
2
 
3
3
  workflow:
4
4
  rules:
data/.rubocop.yml CHANGED
@@ -14,6 +14,7 @@ Metrics/BlockLength:
14
14
  - "Rakefile"
15
15
  - "**/*.rake"
16
16
  - "spec/**/*.rb"
17
+ - "sorare-rewards.gemspec"
17
18
 
18
19
  Metrics/ClassLength:
19
20
  Max: 120
@@ -85,3 +86,6 @@ RSpec/StubbedMock:
85
86
  Style/ExpandPathArguments:
86
87
  Exclude:
87
88
  - "*.gemspec"
89
+
90
+ Style/OpenStructUse:
91
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,36 +1,43 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorare-rewards (1.4.2)
4
+ sorare-rewards (1.4.6)
5
5
  activesupport (~> 6.1.4)
6
- interactor (~> 3.1.2)
6
+ interactor_with_steroids (>= 1.0.0)
7
7
  json (~> 2)
8
8
  yaml (~> 0.2.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.1.4.3)
13
+ activesupport (6.1.4.4)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
18
  zeitwerk (~> 2.3)
19
+ addressable (2.8.0)
20
+ public_suffix (>= 2.0.2, < 5.0)
19
21
  ast (2.4.2)
20
22
  concurrent-ruby (1.1.9)
23
+ crack (0.4.5)
24
+ rexml
21
25
  diff-lcs (1.4.4)
26
+ hashdiff (1.0.1)
22
27
  i18n (1.8.11)
23
28
  concurrent-ruby (~> 1.0)
24
- interactor (3.1.2)
25
- json (2.6.0)
29
+ interactor_with_steroids (1.1.2)
30
+ activesupport
31
+ json (2.6.1)
26
32
  minitest (5.15.0)
27
33
  ostruct (0.4.0)
28
34
  parallel (1.21.0)
29
- parser (3.0.2.0)
35
+ parser (3.1.0.0)
30
36
  ast (~> 2.4.1)
37
+ public_suffix (4.0.6)
31
38
  rainbow (3.0.0)
32
39
  rake (12.3.3)
33
- regexp_parser (2.1.1)
40
+ regexp_parser (2.2.0)
34
41
  rexml (3.2.5)
35
42
  rspec (3.10.0)
36
43
  rspec-core (~> 3.10.0)
@@ -45,16 +52,16 @@ GEM
45
52
  diff-lcs (>= 1.2.0, < 2.0)
46
53
  rspec-support (~> 3.10.0)
47
54
  rspec-support (3.10.2)
48
- rubocop (1.22.1)
55
+ rubocop (1.24.1)
49
56
  parallel (~> 1.10)
50
57
  parser (>= 3.0.0.0)
51
58
  rainbow (>= 2.2.2, < 4.0)
52
59
  regexp_parser (>= 1.8, < 3.0)
53
60
  rexml
54
- rubocop-ast (>= 1.12.0, < 2.0)
61
+ rubocop-ast (>= 1.15.1, < 2.0)
55
62
  ruby-progressbar (~> 1.7)
56
63
  unicode-display_width (>= 1.4.0, < 3.0)
57
- rubocop-ast (1.12.0)
64
+ rubocop-ast (1.15.1)
58
65
  parser (>= 3.0.1.1)
59
66
  rubocop-rake (0.6.0)
60
67
  rubocop (~> 1.0)
@@ -64,8 +71,12 @@ GEM
64
71
  tzinfo (2.0.4)
65
72
  concurrent-ruby (~> 1.0)
66
73
  unicode-display_width (2.1.0)
74
+ webmock (3.14.0)
75
+ addressable (>= 2.8.0)
76
+ crack (>= 0.3.2)
77
+ hashdiff (>= 0.4.0, < 2.0.0)
67
78
  yaml (0.2.0)
68
- zeitwerk (2.5.1)
79
+ zeitwerk (2.5.3)
69
80
 
70
81
  PLATFORMS
71
82
  ruby
@@ -74,10 +85,11 @@ DEPENDENCIES
74
85
  ostruct (~> 0.4.0)
75
86
  rake (~> 12.0)
76
87
  rspec (~> 3.10)
77
- rubocop (~> 1.22.1)
88
+ rubocop (~> 1.24.1)
78
89
  rubocop-rake (~> 0.6.0)
79
90
  rubocop-rspec (~> 2.5.0)
80
91
  sorare-rewards!
92
+ webmock (~> 3.14.0)
81
93
 
82
94
  BUNDLED WITH
83
95
  2.2.30
@@ -19,7 +19,7 @@ module Sorare
19
19
  end
20
20
 
21
21
  def load_yaml_configuration_file(filename)
22
- YAML.safe_load(File.read("#{File.dirname(__FILE__)}/#{filename}"), [], [], true)
22
+ YAML.safe_load(File.read("#{File.dirname(__FILE__)}/#{filename}"), aliases: true)
23
23
  .with_indifferent_access
24
24
  end
25
25
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'active_support/core_ext/module/delegation'
5
+ require 'open-uri'
5
6
 
6
7
  module Sorare
7
8
  module Rewards
@@ -22,7 +23,7 @@ module Sorare
22
23
  end
23
24
 
24
25
  def data
25
- @data ||= JSON.parse(@uri.open)
26
+ @data ||= JSON.parse(@uri.open.read)
26
27
  end
27
28
 
28
29
  def config
@@ -10,7 +10,8 @@ module Sorare
10
10
  class ComputeForGameWeek
11
11
  include Interactor
12
12
 
13
- delegate :supply, :randomizer, :public_seed, :salt, to: :context
13
+ receive :supply, :public_seed, :salt
14
+ hold :randomizer, :game_week_allocations
14
15
 
15
16
  def call
16
17
  context.randomizer = Sorare::Rewards::Random.new(public_seed, salt)
@@ -10,7 +10,8 @@ module Sorare
10
10
  class ComputeForLeague
11
11
  include Interactor
12
12
 
13
- delegate :supply, :config, to: :context
13
+ receive :supply, :config, :randomizer
14
+ hold :league_allocations
14
15
 
15
16
  def call
16
17
  context.league_allocations = allocate_and_format!
@@ -19,9 +20,9 @@ module Sorare
19
20
  def allocate_and_format!
20
21
  each_rarity_allocation do |rarity|
21
22
  (allocations[rarity].first || {}).keys.index_with do |division|
22
- allocations[rarity].each_with_index.map do |qualified_allocations, tier|
23
+ allocations[rarity].each_with_index.to_h do |qualified_allocations, tier|
23
24
  [Sorare::Rewards.configuration.transform_tier.call(tier), qualified_allocations[division]]
24
- end.to_h
25
+ end
25
26
  end
26
27
  end
27
28
  end
@@ -9,7 +9,8 @@ module Sorare
9
9
  class ComputeForQuality
10
10
  include Interactor
11
11
 
12
- delegate :supply, :config, :randomizer, :allocated, to: :context
12
+ receive :supply, :config, :randomizer
13
+ hold :allocated, :quality_allocations
13
14
 
14
15
  def call
15
16
  check_config!
@@ -20,9 +21,9 @@ module Sorare
20
21
  end
21
22
 
22
23
  def allocations
23
- config.length.times.map do |division|
24
+ config.length.times.to_h do |division|
24
25
  [Sorare::Rewards.configuration.transform_division.call(division + 1), allocated[division]]
25
- end.to_h
26
+ end
26
27
  end
27
28
 
28
29
  def allocate!
@@ -10,7 +10,8 @@ module Sorare
10
10
  class ComputeForRarity
11
11
  include Interactor
12
12
 
13
- delegate :supply, :config, to: :context
13
+ receive :supply, :config, :randomizer
14
+ hold :rarity_allocations
14
15
 
15
16
  def call
16
17
  context.fail!(error: 'Invalid config') unless config
@@ -8,7 +8,8 @@ module Sorare
8
8
  class Build
9
9
  include Interactor
10
10
 
11
- delegate :game_week, to: :context
11
+ receive :game_week
12
+ hold :card_allocations, :prize_pools
12
13
 
13
14
  def call
14
15
  context.card_allocations = allocate!
@@ -22,7 +22,8 @@ module Sorare
22
22
  class PickForDivision
23
23
  include Interactor
24
24
 
25
- delegate :league, :allocations, :pickers, :qualified_players, to: :context
25
+ receive :league, :allocations, :pickers
26
+ hold :cards_picked
26
27
 
27
28
  def call
28
29
  context.cards_picked = allocations.keys.index_with do |rarity|
@@ -17,7 +17,8 @@ module Sorare
17
17
  class PickForDivisionAndRarity
18
18
  include Interactor
19
19
 
20
- delegate :league, :rarity, :allocations, :pickers, to: :context
20
+ receive :league, :rarity, :allocations, :pickers
21
+ hold :cards_picked
21
22
 
22
23
  def call
23
24
  context.cards_picked = supply!
@@ -15,7 +15,9 @@ module Sorare
15
15
 
16
16
  MISSING_CARDS = 'There are not enough cards to fulfill the requirements'
17
17
 
18
- delegate :picker, :allocations, :league, :rarity, :force, :cards_picked, to: :context
18
+ receive :picker, :allocations, :league, :rarity, force: false
19
+ hold :cards_picked
20
+
19
21
  delegate :game_week, to: :league
20
22
 
21
23
  def call
@@ -19,7 +19,8 @@ module Sorare
19
19
  class PickForGameWeek
20
20
  include Interactor
21
21
 
22
- delegate :game_week, :allocations, :picks, to: :context
22
+ receive :game_week, :allocations
23
+ hold :cards_picked
23
24
 
24
25
  def call
25
26
  context.cards_picked = pick!
@@ -17,7 +17,9 @@ module Sorare
17
17
  class PickForLeague
18
18
  include Interactor
19
19
 
20
- delegate :league, :allocations, :pickers, to: :context
20
+ receive :league, :allocations
21
+ hold :pickers, :cards_picked
22
+
21
23
  delegate :game_week, to: :league
22
24
  delegate :public_seed, :salt, to: :game_week
23
25
 
@@ -19,7 +19,8 @@ module Sorare
19
19
  class Pick
20
20
  include Interactor
21
21
 
22
- delegate :card_allocations, :game_week, :salt, to: :context
22
+ receive :card_allocations, :game_week, :salt
23
+ hold :cards_picked
23
24
 
24
25
  # Depending on the way the allocations interpreter is implemented it could be done by him or we
25
26
  # update the allocations process to match the structure
@@ -9,7 +9,8 @@ module Sorare
9
9
  class ComputeForDivision
10
10
  include Interactor
11
11
 
12
- delegate :playing_rate, :available_prize_pools, to: :context
12
+ receive :playing_rate, :available_prize_pools
13
+ hold :division_prize_pools
13
14
 
14
15
  def call
15
16
  context.division_prize_pools = available_prize_pools.map do |available_prize_pool|
@@ -10,7 +10,8 @@ module Sorare
10
10
  class ComputeForGameWeek
11
11
  include Interactor
12
12
 
13
- delegate :game_week, to: :context
13
+ receive :game_week
14
+ hold :prize_pools
14
15
 
15
16
  def call
16
17
  context.prize_pools = prize_pools!
@@ -9,20 +9,21 @@ module Sorare
9
9
  class ComputeForLeague
10
10
  include Interactor
11
11
 
12
- delegate :league, to: :context
12
+ receive :league
13
+ hold :league_prize_pools
13
14
 
14
15
  def call
15
16
  context.league_prize_pools = prize_pools!
16
17
  end
17
18
 
18
19
  def prize_pools!
19
- league.each_division_prize_pools.map do |division, prize_pools|
20
+ league.each_division_prize_pools.to_h do |division, prize_pools|
20
21
  [
21
22
  Sorare::Rewards.configuration.transform_division.call(division),
22
23
  ComputeForDivision.call!(playing_rate: league.playing_rate, available_prize_pools: prize_pools)
23
24
  .division_prize_pools
24
25
  ]
25
- end.to_h
26
+ end
26
27
  end
27
28
  end
28
29
  end
@@ -10,7 +10,8 @@ module Sorare
10
10
  class ComputeForGameWeek
11
11
  include Interactor
12
12
 
13
- delegate :game_week, :game_week_supply, to: :context
13
+ receive :game_week
14
+ hold :game_week_supply
14
15
 
15
16
  def call
16
17
  context.game_week_supply = game_week_supply!
@@ -9,7 +9,8 @@ module Sorare
9
9
  class ComputeForQuality
10
10
  include Interactor
11
11
 
12
- delegate :randomizer, :total_supply, :tier_supply, :rewarded, :rewardable, to: :context
12
+ receive :randomizer, :total_supply, :tier_supply, :rewarded, :rewardable
13
+ hold :quality_supply
13
14
 
14
15
  def call
15
16
  context.quality_supply = total_supply.zero? ? 0 : quality_supply
@@ -9,8 +9,9 @@ module Sorare
9
9
  class ComputeForRarity
10
10
  include Interactor
11
11
 
12
- delegate :randomizer, :league, :rarity, :supply, :rewardable, :rarity_supply,
13
- :minimum_remaining_games, to: :context
12
+ receive :randomizer, :league, :rarity, :supply
13
+ hold :rarity_supply, :rewardable
14
+
14
15
  delegate :game_week, to: :league
15
16
 
16
17
  def call
@@ -10,7 +10,8 @@ module Sorare
10
10
  class QualifyPlayers
11
11
  include Interactor
12
12
 
13
- delegate :sorted_supply, to: :context
13
+ receive :sorted_supply
14
+ hold :players
14
15
 
15
16
  def call
16
17
  context.players = by_rank ? qualified_players_by_rank : qualified_players_by_tier
@@ -10,7 +10,8 @@ module Sorare
10
10
  class QualifySupply
11
11
  include Interactor
12
12
 
13
- delegate :sorted_supply, to: :context
13
+ receive :sorted_supply
14
+ hold :count, :supply
14
15
 
15
16
  def call
16
17
  context.count = sorted_supply.values.sum { |p| p['supply'] }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sorare
4
4
  module Rewards
5
- VERSION = '1.4.2'
5
+ VERSION = '1.4.6'
6
6
  end
7
7
  end
@@ -5,8 +5,8 @@ require_relative 'lib/sorare/rewards/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'sorare-rewards'
7
7
  spec.version = Sorare::Rewards::VERSION
8
- spec.authors = ['pierre']
9
- spec.email = ['pierre@sorare.com']
8
+ spec.authors = ['Sorare team']
9
+ spec.email = ['hello@sorare.com']
10
10
 
11
11
  spec.summary = %w[Sorare reward allocation algorithm]
12
12
  # spec.description = %q{TODO: Write a longer description or delete this line.}
@@ -30,12 +30,14 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ['lib']
31
31
 
32
32
  spec.add_dependency 'activesupport', '~> 6.1.4'
33
- spec.add_dependency 'interactor', '~> 3.1.2'
33
+ spec.add_dependency 'interactor_with_steroids', '>= 1.0.0'
34
34
  spec.add_dependency 'json', '~> 2'
35
35
  spec.add_dependency 'yaml', '~> 0.2.0'
36
36
  spec.add_development_dependency 'ostruct', '~> 0.4.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.10'
38
- spec.add_development_dependency 'rubocop', '~> 1.22.1'
38
+ spec.add_development_dependency 'rubocop', '~> 1.24.1'
39
39
  spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
40
40
  spec.add_development_dependency 'rubocop-rspec', '~> 2.5.0'
41
+ spec.add_development_dependency 'webmock', '~> 3.14.0'
42
+ spec.metadata['rubygems_mfa_required'] = 'true'
41
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorare-rewards
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
- - pierre
7
+ - Sorare team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-30 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 6.1.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: interactor
28
+ name: interactor_with_steroids
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.1.2
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.1.2
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.22.1
103
+ version: 1.24.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.22.1
110
+ version: 1.24.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -136,9 +136,23 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.5.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 3.14.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 3.14.0
139
153
  description:
140
154
  email:
141
- - pierre@sorare.com
155
+ - hello@sorare.com
142
156
  executables: []
143
157
  extensions: []
144
158
  extra_rdoc_files: []
@@ -197,6 +211,7 @@ licenses:
197
211
  metadata:
198
212
  homepage_uri: https://gitlab.com/sorare/sorare-rewards
199
213
  source_code_uri: https://gitlab.com/sorare/sorare-rewards
214
+ rubygems_mfa_required: 'true'
200
215
  post_install_message:
201
216
  rdoc_options: []
202
217
  require_paths: