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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 651fee9239497761fb48b5794e89687a1789de5aefd5d463527cf336b36c5f6d
4
- data.tar.gz: b191bce7fcd36aa4820557fc3cc45bdbe9719b91e035328a9db6566183538ab6
3
+ metadata.gz: 924bbe0dc0445b557f63850ebfd7650b3f41216d52789a48e0701ebe6afe7b3a
4
+ data.tar.gz: ec3e3ff23194b4d3de28190ca34cfba950460e1df1b778421733ecca6f2b2327
5
5
  SHA512:
6
- metadata.gz: ca06e3932d06661ed25f7dc43ea57fd5edb47ed21a4aed9bbabd55e66c74f46546e20ce833f614244d8ad2a10a3bbc1aed51a658362cf0b19e3a12d46de4e44c
7
- data.tar.gz: c27d73f78cbbc1820b9e55a66ba9115e7717006135e9d57148831060e37fe56a272c103e7cd6a986728fd87f393fa91c3facdbe4f0980d3d544fa115c70a2369
6
+ metadata.gz: 543c0c2a5159d23e0ceab290888bad113373c38c3b28c5c197e7a4a4ab10dfc7ee35a2b4034b7a442c4e88a8a0623654612b8130cb05ab26f22ba13db68e95ba
7
+ data.tar.gz: e0f75b5c0e3479d0d876236c35e481ac8d74e32bb14813d73532b72c63cfa79905c51945ba79f0100a04e1703ceb11f2b027a6618284fdb7cd3eee9b77848ed0
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../fn'
4
+ require_relative 'curry'
5
+
6
+ Fn = ExAequo::Base::Fn
7
+ Placeholder = Fn::Placeholder
8
+
9
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+ module ExAequo
5
+ module Base
6
+ module Fn extend self
7
+ extend Forwarder
8
+ forward_all :curry, to: Helpers
9
+ end
10
+ end
11
+ end
12
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module Base
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.7'
6
6
  end
7
7
  end
8
8
  # 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.6
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.8
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: []