ex_aequo_base 0.1.9 → 0.1.11

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: e92467b526715617cfc4936b88dbdd843195e0ddd474a94da9c52650fb7e6d4a
4
- data.tar.gz: 8545cb2f614673f13250d4deea5338baed5e78a7ccd1c89a9d6712527368029d
3
+ metadata.gz: 3a09bafbf0482a72a5c127e0eda323e0c685981353c1e1ccd93c4fcc4ace34c3
4
+ data.tar.gz: c0f572df0be6273763c45db5d163b15312d70eb6ec518baefa7f484955b3aa0d
5
5
  SHA512:
6
- metadata.gz: 934cec29d13da31c801ab3901e9484bafbcf48b2cc0dd47e22cbd850f48bfb382d529bba2b18a20a433d3c5cebab2c7824ce8c612dfcdd96b76cdb2390c5b8ef
7
- data.tar.gz: 05db10e7a72ea3140345cca0d480a4e8b927752f3760484cf87fcf5f0e152da62f51fc938e10055d65dd538819a94f500b1eb7bbee5a1071443b90326bc93fde
6
+ metadata.gz: ac0ccd3d9370a9a0f5bf1862ed29dfc90d009c1c537034ca8f60b28a76e873da16fd01c3343b3d8a7042228600de63a7f1628f844676cb0cfa53fa6ee9caec2b
7
+ data.tar.gz: af7e56c2823e7e40222afd136d10095768aac426bb177bf7ff36e4e106b0d2c47d41de2a677510ad002321426e45f8912c6d1e81d0f47e9f82d270c2c8632f5a
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module Base
5
+ module Enumerable
6
+ module Hash
7
+ def maph(&blk)
8
+ inject({}) do |r, (k, v)|
9
+ blk.(k, v) => [nk, nv]
10
+ r.update(nk => nv)
11
+ end
12
+ end
13
+
14
+ def mapv(&blk)
15
+ maph { |k, v| [k, blk.(v)] }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../fn'
4
+ module ExAequo
5
+ module Base
6
+ module Enumerable
7
+ module EnumerableHelper extend self
8
+ def reduce_until_with_trigger(enum, initial:, end_triggers:, &blk)
9
+ f = Fn.mk_fun_pipeline(end_triggers)
10
+ enum.each do
11
+ return initial if f.(initial)
12
+ initial = blk.(initial, it)
13
+ end
14
+ initial
15
+ end
16
+
17
+ def reduce_while_simple(enum, initial:, &blk)
18
+ enum.each do
19
+ val = blk.(initial, it)
20
+ if val
21
+ initial = val
22
+ else
23
+ return initial
24
+ end
25
+ end
26
+ initial
27
+ end
28
+
29
+ def reduce_while_with_trigger(enum, initial:, end_triggers:, &blk)
30
+ f = Fn.mk_fun_pipeline(end_triggers)
31
+ enum.each do
32
+ val = blk.(initial, it)
33
+ # p(val:, f: f.(val))
34
+ if f.(val)
35
+ initial = val
36
+ else
37
+ return initial
38
+ end
39
+ end
40
+ initial
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'enumerable_helper'
3
+ require_subdir __FILE__
4
4
  module Enumerable
5
5
  def find_value(&blk)
6
6
  each do
@@ -13,15 +13,19 @@ module Enumerable
13
13
  def reduce_until(initial, *end_triggers, &blk)
14
14
  raise ArgumentError, "missing end_trigger(s)" if end_triggers.empty?
15
15
 
16
- ExAequo::Base::EnumerableHelper.reduce_until_with_trigger(self, initial:, end_triggers:, &blk)
16
+ ExAequo::Base::Enumerable::EnumerableHelper.reduce_until_with_trigger(self, initial:, end_triggers:, &blk)
17
17
  end
18
18
 
19
19
  def reduce_while(initial, *end_triggers, &blk)
20
20
  if end_triggers.empty?
21
- ExAequo::Base::EnumerableHelper.reduce_while_simple(self, initial:, &blk)
21
+ ExAequo::Base::Enumerable::EnumerableHelper.reduce_while_simple(self, initial:, &blk)
22
22
  else
23
- ExAequo::Base::EnumerableHelper.reduce_while_with_trigger(self, initial:, end_triggers:, &blk)
23
+ ExAequo::Base::Enumerable::EnumerableHelper.reduce_while_with_trigger(self, initial:, end_triggers:, &blk)
24
24
  end
25
25
  end
26
26
  end
27
+
28
+ class Hash
29
+ include ExAequo::Base::Enumerable::Hash
30
+ end
27
31
  # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -6,6 +6,11 @@ module ExAequo
6
6
  module Forwarder
7
7
  include Forwardable
8
8
 
9
+ def forward(message, to:, as: nil)
10
+ as ||= message
11
+ def_delegator(to, as, message)
12
+ end
13
+
9
14
  def forward_all(*messages, to:)
10
15
  def_delegators(to, *messages)
11
16
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module Base
5
- VERSION = '0.1.9'
5
+ VERSION = '0.1.11'
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.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -52,6 +52,8 @@ files:
52
52
  - lib/ex_aequo/base/colorize/colorizer.rb
53
53
  - lib/ex_aequo/base/constants.rb
54
54
  - lib/ex_aequo/base/enumerable.rb
55
+ - lib/ex_aequo/base/enumerable/hash.rb
56
+ - lib/ex_aequo/base/enumerable/helper.rb
55
57
  - lib/ex_aequo/base/enumerable_helper.rb
56
58
  - lib/ex_aequo/base/fn.rb
57
59
  - lib/ex_aequo/base/fn/all.rb