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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/merginator/pattern_merge.rb +9 -6
- data/lib/merginator/version.rb +1 -1
- data/sig/{mergifier/pattern_merge.rbs → pattern_merge.rbs} +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec09691fc1e5abd0eb16409a89002e835b565c1f030235d58e01143a090419a
|
4
|
+
data.tar.gz: 84dc992b1e3567c82ef5d53d280d8708105a81186d71b4adc592d1284d75fec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4238899209c3d5fbf18a3f4d72ff0167ac0d4218f338f9ae09ef78cc798e9798456729d41ebcadd3fa01df75b0758fcf5096af3e3b4ba3eb1db024f2a0b06eb0
|
7
|
+
data.tar.gz: e1b1b285d7dee050ab08a2100794f82a0a993ac40f26dc12af30c98f04ab5cd2c1d4e1e6edf56ff595844490d44fda3d648edb7db2bab19dad761247729086b6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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 =
|
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 =
|
97
|
-
return if collections.
|
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}"
|
data/lib/merginator/version.rb
CHANGED
@@ -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.
|
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-
|
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
|