ex_aequo_base 0.1.6 → 0.1.8

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: b7be94a3d045e4154e3e27b72c7e1a6234ea4d9230d2cd21ba3cefa09e2980bf
4
+ data.tar.gz: cb28876bfb5512ff06482c92a15369294744626f3b606f9076c90ef5d222cce5
5
5
  SHA512:
6
- metadata.gz: ca06e3932d06661ed25f7dc43ea57fd5edb47ed21a4aed9bbabd55e66c74f46546e20ce833f614244d8ad2a10a3bbc1aed51a658362cf0b19e3a12d46de4e44c
7
- data.tar.gz: c27d73f78cbbc1820b9e55a66ba9115e7717006135e9d57148831060e37fe56a272c103e7cd6a986728fd87f393fa91c3facdbe4f0980d3d544fa115c70a2369
6
+ metadata.gz: e0f99f3fb9db02de91db98649948eacfe1a248044190c0b6b422c02e44bc57165c6618a96a3f615c4efe70afa14abcd5e5f3edb4bfcd192ddf33c40a536685d3
7
+ data.tar.gz: efe7bde37b17b0f65aba95bf789288699a21be322cd82e0ccf6a2e9d0fcf25f3b8c4ad90ac10add31c53a50901cc9e099570dedb43d2c65b29d6267b2e946006
@@ -2,6 +2,7 @@
2
2
  require_relative 'colorize'
3
3
  require_relative 'enumerable'
4
4
  require_relative 'fn'
5
+ require_relative 'forwarder'
5
6
  require_relative 'kernel'
6
7
  require_relative 'open_struct'
7
8
  require_relative 'regexp'
@@ -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,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers'
4
+ require_relative '../forwarder'
5
+ module ExAequo
6
+ module Base
7
+ module Fn extend self
8
+ extend Forwarder
9
+ forward_all :curry, to: Helpers
10
+ end
11
+ end
12
+ end
13
+ # 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
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+ module ExAequo
5
+ module Base
6
+ module Forwarder
7
+ include Forwardable
8
+
9
+ def forward_all(*messages, to:)
10
+ def_delegators(to, *messages)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../constants'
4
+ module ExAequo::Base::KernelHelper extend self
5
+
6
+ def require_subdir(*files, descend:, &blk)
7
+ raise ArgumentError, "must not provide positional file parameter #{files} and a block" if !files.empty? && blk
8
+ raise ArgumentError, "must provide file or block" unless !files.empty? || blk
9
+ if files.empty?
10
+ req_subdir_blk(descend:, &blk)
11
+ else
12
+ req_subdir_file(File.join(files), descend:)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def check_file(file)
19
+ return file if File.directory?(file)
20
+
21
+ file = file.sub(ExAequo::Base::RbExtensionRgx, '')
22
+ return file if File.directory?(file)
23
+
24
+ raise ArgumentError, "#{file} is not a directory nor does a subdirectory named after this ruby file ('.rb' removed) exist"
25
+ end
26
+
27
+ def req_subdir_blk(descend:, &blk)
28
+ subdir = blk.()
29
+ blk.source_location => src, _
30
+ if subdir
31
+ dir = File.dirname(src)
32
+ req_subdir_file(File.join(dir, subdir), descend:, exclude: src)
33
+ else
34
+ req_subdir_file(src, descend:, exclude: src)
35
+ end
36
+ end
37
+
38
+ def req_subdir_file(file, descend:, exclude: nil)
39
+ dir = check_file(file)
40
+ wc = descend ? '/**/*.rb' : '/*.rb'
41
+ Dir.glob(File.join(dir, wc)).each do |f|
42
+ require f.sub(ExAequo::Base::RbExtensionRgx, '') unless f == exclude
43
+ end
44
+ end
45
+ end
46
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -1,49 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'constants'
4
- module ExAequo::Base::KernelHelper extend self
5
-
6
- def require_subdir(*files, descend:, &blk)
7
- raise ArgumentError, "must not provide positional file parameter #{files} and a block" if !files.empty? && blk
8
- raise ArgumentError, "must provide file or block" unless !files.empty? || blk
9
- if files.empty?
10
- req_subdir_blk(descend:, &blk)
11
- else
12
- req_subdir_file(File.join(files), descend:)
13
- end
14
- end
15
-
16
- private
17
-
18
- def check_file(file)
19
- return file if File.directory?(file)
20
-
21
- file = file.sub(ExAequo::Base::RbExtensionRgx, '')
22
- return file if File.directory?(file)
23
-
24
- raise ArgumentError, "#{file} is not a directory nor does a subdirectory named after this ruby file ('.rb' removed) exist"
25
- end
26
-
27
- def req_subdir_blk(descend:, &blk)
28
- subdir = blk.()
29
- blk.source_location => src, _
30
- if subdir
31
- dir = File.dirname(src)
32
- req_subdir_file(File.join(dir, subdir), descend:, exclude: src)
33
- else
34
- req_subdir_file(src, descend:, exclude: src)
35
- end
36
- end
37
-
38
- def req_subdir_file(file, descend:, exclude: nil)
39
- dir = check_file(file)
40
- wc = descend ? '/**/*.rb' : '/*.rb'
41
- Dir.glob(File.join(dir, wc)).each do |f|
42
- require f.sub(ExAequo::Base::RbExtensionRgx, '') unless f == exclude
43
- end
44
- end
45
- end
46
-
3
+ require_relative 'kernel/kernel_helper'
47
4
  module Kernel
48
5
  def require_subdir(*files, descend: false, &blk)
49
6
  ExAequo::Base::KernelHelper.require_subdir(*files, descend:, &blk)
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ostruct'
4
- require 'forwarder'
4
+ require_relative 'forwarder'
5
5
  class OpenStruct
6
- extend Forwarder
6
+ extend ExAequo::Base::Forwarder
7
7
  forward_all :deconstruct_keys, :empty?, :fetch, :has_key?, to: :to_h
8
8
 
9
9
  def self.to_proc
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module Base
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.8'
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.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -9,20 +9,6 @@ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: forwarder
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: 0.1.0
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: 0.1.0
26
12
  - !ruby/object:Gem::Dependency
27
13
  name: ostruct
28
14
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +54,12 @@ files:
68
54
  - lib/ex_aequo/base/enumerable.rb
69
55
  - lib/ex_aequo/base/enumerable_helper.rb
70
56
  - lib/ex_aequo/base/fn.rb
57
+ - lib/ex_aequo/base/fn/all.rb
58
+ - lib/ex_aequo/base/fn/curry.rb
59
+ - lib/ex_aequo/base/fn/helpers.rb
60
+ - lib/ex_aequo/base/forwarder.rb
71
61
  - lib/ex_aequo/base/kernel.rb
62
+ - lib/ex_aequo/base/kernel/kernel_helper.rb
72
63
  - lib/ex_aequo/base/match_data.rb
73
64
  - lib/ex_aequo/base/open_struct.rb
74
65
  - lib/ex_aequo/base/regexp.rb
@@ -97,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
88
  - !ruby/object:Gem::Version
98
89
  version: '0'
99
90
  requirements: []
100
- rubygems_version: 3.6.8
91
+ rubygems_version: 3.7.1
101
92
  specification_version: 4
102
93
  summary: The code I use all the time
103
94
  test_files: []