sorare-rewards 1.1.0 → 1.1.1

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: dd12e11f5b4eb146655a6944d6ffd4b541a3cfe926e38b5bb77e7235d4cc92fd
4
- data.tar.gz: 12acbcb47c3d6f366855278b96d75ab787414f802cbbfe9c597f98a96867c8ae
3
+ metadata.gz: f6897c498226e4f66e5b2a8aa93cd8b46478cc5d48d445950313224fae955922
4
+ data.tar.gz: 6a317d2b7767bb86bba95b485516923c1f4fe04780507d068b8d5ebd4a34a836
5
5
  SHA512:
6
- metadata.gz: 858689cacfc5e20404a485c5500266c613c47ec4838fbf909b7975594a6e1eb59cc96d0e3fa14cdc3cfdf4cea2b0f1ad9cd01adc215d02c0369d3ef02a3a7351
7
- data.tar.gz: ba9f2aa66b4332ba1611f38a9b7fad80582bc1d03f67530bb356d203d4a71f9405ac353461ea4f6383775a03145adb923ade0762b9f1d89041299f7aa2b27e74
6
+ metadata.gz: d0000887adec07808ab805e1045b196cd413015dd4e99a0b7df65fcf08a6cdf1f7cadd34c976a8da21cbbe72b583f5166e970a624645f02e64c5a77dbc1b119b
7
+ data.tar.gz: 72f565145aade90fc49552c1940da0e6f93f9e4f80dc179fb90ff9c20ed2c287ab241e5755bab1f750b3e9a8f4a61425b262729cf0e326465be201a35dfdfccc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorare-rewards (1.1.0)
4
+ sorare-rewards (1.1.1)
5
5
  activesupport (~> 6.1)
6
6
  interactor (~> 3.0)
7
7
  json (~> 2)
@@ -17,10 +17,8 @@ module Sorare
17
17
  end
18
18
 
19
19
  def allocate_and_format!
20
- allocations = allocate!
21
-
22
- allocations.keys.index_with do |rarity|
23
- allocations[rarity].first.keys.index_with do |division|
20
+ each_rarity_allocation do |rarity|
21
+ (allocations[rarity].first || {}).keys.index_with do |division|
24
22
  allocations[rarity].each_with_index.map do |qualified_allocations, tier|
25
23
  [Sorare::Rewards.configuration.transform_tier.call(tier), qualified_allocations[division]]
26
24
  end.to_h
@@ -28,8 +26,12 @@ module Sorare
28
26
  end
29
27
  end
30
28
 
31
- def allocate!
32
- (config || {}).keys.index_with do |rarity|
29
+ def each_rarity_allocation(&block)
30
+ allocations.keys.index_with(&block)
31
+ end
32
+
33
+ def allocations
34
+ @allocations ||= (config || {}).keys.index_with do |rarity|
33
35
  ComputeForRarity.call!(**context.to_h, supply: supply[rarity], config: config[rarity]).rarity_allocations
34
36
  end
35
37
  end
@@ -15,7 +15,13 @@ module Sorare
15
15
  def call
16
16
  context.fail!(error: 'Invalid config') unless config
17
17
 
18
- context.rarity_allocations = supply.each_with_index.map do |tier_supply, tier|
18
+ context.rarity_allocations = allocations
19
+ end
20
+
21
+ def allocations
22
+ return [] unless supply
23
+
24
+ supply.each_with_index.map do |tier_supply, tier|
19
25
  ComputeForQuality.call!(
20
26
  **context.to_h,
21
27
  supply: tier_supply,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sorare
4
4
  module Rewards
5
- VERSION = '1.1.0'
5
+ VERSION = '1.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorare-rewards
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pierre