merginator 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8d45708d09006490c77f0d2819b0fecc13e35a2a81e69a6f4c7fcf5c8a8bf7f
4
- data.tar.gz: c508d5dec15b52a26e3388130d9845a20b4821a1fb5f3f8c7acf735e48afc770
3
+ metadata.gz: cec09691fc1e5abd0eb16409a89002e835b565c1f030235d58e01143a090419a
4
+ data.tar.gz: 84dc992b1e3567c82ef5d53d280d8708105a81186d71b4adc592d1284d75fec4
5
5
  SHA512:
6
- metadata.gz: c85058dd8a0282a43ce46050c4ddba76c9d7f7bb6a2997f2bdf06bf10646f1797e4f1f13a98bd1ec740449dd6501c8b5990255e19d8e5b08eba7e6bc68e0aa81
7
- data.tar.gz: a4365f144da7520eecc9e18080aabe6cf16a3322778a5c08a7ff06832d6b85aa0e204629b667cd673d879f0244849da005b706e437897ddf266054c3bc92e13b
6
+ metadata.gz: 4238899209c3d5fbf18a3f4d72ff0167ac0d4218f338f9ae09ef78cc798e9798456729d41ebcadd3fa01df75b0758fcf5096af3e3b4ba3eb1db024f2a0b06eb0
7
+ data.tar.gz: e1b1b285d7dee050ab08a2100794f82a0a993ac40f26dc12af30c98f04ab5cd2c1d4e1e6edf56ff595844490d44fda3d648edb7db2bab19dad761247729086b6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.2] - 2023-06-30
2
+
3
+ - Updating ignore total behavior to actually ignore total when validating
4
+
1
5
  ## [0.2.1] - 2023-06-27
2
6
 
3
7
  - Configuration change version bump
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- merginator (0.2.1)
4
+ merginator (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -25,11 +25,10 @@ module Merginator
25
25
  end
26
26
 
27
27
  def merge(*collections, wrapper: @wrapper, ignore_total: false)
28
- validate_merge_collections(collections)
28
+ validate_merge_collections(collections, ignore_total: ignore_total)
29
29
  validate_wrapper wrapper
30
30
 
31
- total_to_use = @total
32
- total_to_use = collections.sum(&:size) if !total || ignore_total
31
+ total_to_use = total_to_use(collections, ignore_total: ignore_total)
33
32
 
34
33
  slices_for_collections = slice_collections(collections)
35
34
  merge_collections_into_wrapper(slices_for_collections, wrapper: wrapper, total: total_to_use)
@@ -75,6 +74,10 @@ module Merginator
75
74
  wrapper.replace wrapper.take(total)
76
75
  end
77
76
 
77
+ def total_to_use(collections, ignore_total: false)
78
+ !@total || ignore_total ? collections.sum(&:size) : @total.to_i
79
+ end
80
+
78
81
  def validate_pattern
79
82
  raise ArgumentError, 'there must be more than one collection in the pattern' if @pattern.count <= 1
80
83
  raise ArgumentError, 'pattern must be all integers' unless @pattern.all? { |n| n.is_a? Integer }
@@ -86,15 +89,15 @@ module Merginator
86
89
  raise ArgumentError, 'total must be at least 1'
87
90
  end
88
91
 
89
- def validate_merge_collections(collections)
92
+ def validate_merge_collections(collections, ignore_total: false)
90
93
  unless @pattern.count == collections.count
91
94
  message = 'number of collections must match pattern; '
92
95
  message += "expected #{@pattern.count} collections, actual: #{collections.count}"
93
96
  raise ArgumentError, message
94
97
  end
95
98
 
96
- total_to_use = @total || collections.flatten.count
97
- return if collections.flatten.count >= total_to_use
99
+ total_to_use = total_to_use(collections, ignore_total: ignore_total)
100
+ return if collections.sum(&:size) >= total_to_use
98
101
 
99
102
  message = 'total number of elements in collections must be >= provided total; '
100
103
  message += "expected #{@total} elements, actual: #{collections.flatten.count}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Merginator
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
@@ -17,8 +17,9 @@ class Merginator::PatternMerge
17
17
  def generate_pattern_counts: (total) -> Array[Integer]?
18
18
  def slice_collections: (Array[collection]) -> Array[Array[untyped]]
19
19
  def merge_collections_into_wrapper: (Array[Array[untyped]], wrapper: wrapper, total: Integer) -> wrapper
20
+ def total_to_use: (Array[collection], ?ignore_total: bool) -> Integer
20
21
  def validate_pattern: () -> void
21
22
  def validate_total: () -> void
22
- def validate_merge_collections: (Array[collection]) -> void
23
+ def validate_merge_collections: (Array[collection], ?ignore_total: bool) -> void
23
24
  def validate_wrapper: (?wrapper) -> void
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merginator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Verhey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2023-06-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Merge 2 or more collections based on a repeating pattern.
14
14
  email:
@@ -33,8 +33,8 @@ files:
33
33
  - merginator.gemspec
34
34
  - rbs_collection.lock.yaml
35
35
  - rbs_collection.yaml
36
- - sig/mergifier/pattern_merge.rbs
37
36
  - sig/merginator.rbs
37
+ - sig/pattern_merge.rbs
38
38
  homepage: https://github.com/RyanVerhey/merginator
39
39
  licenses:
40
40
  - MIT