ex_aequo_base 0.1.6 → 0.1.7
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/lib/ex_aequo/base/fn/all.rb +9 -0
- data/lib/ex_aequo/base/fn/curry.rb +12 -0
- data/lib/ex_aequo/base/fn/helpers.rb +57 -0
- data/lib/ex_aequo/base/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 924bbe0dc0445b557f63850ebfd7650b3f41216d52789a48e0701ebe6afe7b3a
|
4
|
+
data.tar.gz: ec3e3ff23194b4d3de28190ca34cfba950460e1df1b778421733ecca6f2b2327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 543c0c2a5159d23e0ceab290888bad113373c38c3b28c5c197e7a4a4ab10dfc7ee35a2b4034b7a442c4e88a8a0623654612b8130cb05ab26f22ba13db68e95ba
|
7
|
+
data.tar.gz: e0f75b5c0e3479d0d876236c35e481ac8d74e32bb14813d73532b72c63cfa79905c51945ba79f0100a04e1703ceb11f2b027a6618284fdb7cd3eee9b77848ed0
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ExAequo
|
4
|
+
module Base
|
5
|
+
module Fn
|
6
|
+
Placeholder = BasicObject.new
|
7
|
+
|
8
|
+
module Helpers extend self
|
9
|
+
def curry(rcv, *positionals, **keywords, &blk)
|
10
|
+
return _send_curry(*positionals, **keywords, &blk) if rcv == Placeholder
|
11
|
+
|
12
|
+
_send_to(rcv, *positionals, **keywords, &blk)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def _make_actual_params(positionals, args, keywords, kwds, offset:)
|
17
|
+
as = []
|
18
|
+
ks = {}
|
19
|
+
n = 0
|
20
|
+
|
21
|
+
positionals.each do
|
22
|
+
if it == Placeholder
|
23
|
+
as << args[n]
|
24
|
+
n += 1
|
25
|
+
else
|
26
|
+
as << it
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
keywords.each do |k, v|
|
31
|
+
if v == Placeholder
|
32
|
+
ks[k] = args[n]
|
33
|
+
n += 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
as += Array(args[positionals.length-offset..])
|
37
|
+
[as, keywords.merge(ks).merge(kwds)]
|
38
|
+
end
|
39
|
+
|
40
|
+
def _send_curry(*positionals, **keywords, &b)
|
41
|
+
-> (rcv, *args, **kwds, &blk) do
|
42
|
+
_make_actual_params(positionals, args, keywords, kwds, offset: 1) => actual_pos, actual_kwds
|
43
|
+
rcv.send(*actual_pos, **actual_kwds, &(blk || b))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def _send_to(rcv, *positionals, **keywords, &b)
|
48
|
+
-> (*args, **kwds, &blk) do
|
49
|
+
_make_actual_params(positionals, args, keywords, kwds, offset: 0) => actual_pos, actual_kwds
|
50
|
+
rcv.send(*actual_pos, **actual_kwds, &(blk || b))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ex_aequo_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
@@ -68,6 +68,9 @@ files:
|
|
68
68
|
- lib/ex_aequo/base/enumerable.rb
|
69
69
|
- lib/ex_aequo/base/enumerable_helper.rb
|
70
70
|
- lib/ex_aequo/base/fn.rb
|
71
|
+
- lib/ex_aequo/base/fn/all.rb
|
72
|
+
- lib/ex_aequo/base/fn/curry.rb
|
73
|
+
- lib/ex_aequo/base/fn/helpers.rb
|
71
74
|
- lib/ex_aequo/base/kernel.rb
|
72
75
|
- lib/ex_aequo/base/match_data.rb
|
73
76
|
- lib/ex_aequo/base/open_struct.rb
|
@@ -97,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
100
|
- !ruby/object:Gem::Version
|
98
101
|
version: '0'
|
99
102
|
requirements: []
|
100
|
-
rubygems_version: 3.6.
|
103
|
+
rubygems_version: 3.6.9
|
101
104
|
specification_version: 4
|
102
105
|
summary: The code I use all the time
|
103
106
|
test_files: []
|