foobara-util 1.0.0 → 1.0.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 +13 -0
- data/lib/foobara/util/array.rb +10 -0
- data/lib/foobara/util/proc.rb +25 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f2492a2c2bcf6ae3801d6117d831065dfa7797cc832988209d76c224fb0582b
|
4
|
+
data.tar.gz: a0d20bde313cab91ccc58c2ea0fe83416fadcd8db1d5cf155d88a21c97cafdc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41b4a6db1749ea211819b2279e838334e9b367c6ebeba232aa5b247cab8ffa66fcdf020cc459a1708c520ac62224796b3a850786ccc7d27297bd29059af4b6d
|
7
|
+
data.tar.gz: 8eff1b615db6f938c7f04c11f15b9ad5bb7c77cff8d82a1aa9f32624b86b42ec06ccb7b46fd748ce4306798f8c7f297fb35edfa95ec684eb43f8fc89ca34cb29
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## [1.0.2] - 2025-07-25
|
2
|
+
|
3
|
+
- Add .remove_arity_check to help with using lambdas in DSLs
|
4
|
+
|
5
|
+
## [1.0.1] - 2025-07-07
|
6
|
+
|
7
|
+
- Add Util.start_with? for array comparisons
|
8
|
+
|
9
|
+
## [1.0.0] - 2025-06-06
|
10
|
+
|
11
|
+
- Add + unary operator to a couple strings that are mutated for forward-compatibility
|
12
|
+
with upcoming frozen string literals
|
13
|
+
|
1
14
|
## [0.0.12] - 2025-05-03
|
2
15
|
|
3
16
|
- Add .deep_symbolize_keys
|
data/lib/foobara/util/array.rb
CHANGED
@@ -36,5 +36,15 @@ module Foobara
|
|
36
36
|
)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
def start_with?(large_array, small_array)
|
41
|
+
return false unless large_array.size >= small_array.size
|
42
|
+
|
43
|
+
small_array.each.with_index do |item, index|
|
44
|
+
return false unless large_array[index] == item
|
45
|
+
end
|
46
|
+
|
47
|
+
true
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Util
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def remove_arity_check(lambda)
|
6
|
+
arity = lambda.arity
|
7
|
+
|
8
|
+
if arity == 0
|
9
|
+
proc { |*, **opts, &block| lambda.call(**opts, &block) }
|
10
|
+
else
|
11
|
+
proc do |*args, **opts, &block|
|
12
|
+
args = args[0...arity]
|
13
|
+
|
14
|
+
remaining = arity - args.size
|
15
|
+
|
16
|
+
if remaining > 0
|
17
|
+
args += [nil] * remaining
|
18
|
+
end
|
19
|
+
|
20
|
+
lambda.call(*args, **opts, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-07-25 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
email:
|
13
13
|
- azimux@gmail.com
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/foobara/util/hash.rb
|
29
29
|
- lib/foobara/util/meta.rb
|
30
30
|
- lib/foobara/util/module.rb
|
31
|
+
- lib/foobara/util/proc.rb
|
31
32
|
- lib/foobara/util/require.rb
|
32
33
|
- lib/foobara/util/string.rb
|
33
34
|
- lib/foobara/util/structured.rb
|
@@ -55,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
56
|
- !ruby/object:Gem::Version
|
56
57
|
version: '0'
|
57
58
|
requirements: []
|
58
|
-
rubygems_version: 3.6.
|
59
|
+
rubygems_version: 3.6.2
|
59
60
|
specification_version: 4
|
60
61
|
summary: Utility functions used across various Foobara projects
|
61
62
|
test_files: []
|