ex_aequo_base 0.1.3 → 0.1.5

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: 46f5ec37896f313f3ee4edfc8bd1621f3ef01111fbb4ed80e55e5e0d3c95fb34
4
- data.tar.gz: 0653da343a7cfff30b9667dde6836dce10f9241361bfa3d77a2fb5ba60a1cb72
3
+ metadata.gz: 24a260aad0b858a285db2f96eccff1885c3755e12eed40c61a01d4100ecc40ed
4
+ data.tar.gz: 961b6557e5002df0ee9993399de00f4705ecf55561b048e8ef9c5927c924030b
5
5
  SHA512:
6
- metadata.gz: cad017a7d02b4823e436df3035ec128e9ebca3ed4d914a06ec046f464cee07ecdd36c1c3d9b736323c42ebf73bd1756936844c9ef3adf17e518998d42260b13c
7
- data.tar.gz: d19f2261d4ea8bef04d182ac411651e6353c9f2ff3ef886aa97bc67d3a092d33643ea7cb5e3afc7d902a45fd43b6dd7399bb55c7262c9044bc4b3f430ab055b8
6
+ metadata.gz: 7ba6c445f2dd6bfa21b20fd7e4bc5b83ce57ebc1b72c62049aad348f30ea36f32dc8e016bddf9cef180b29541ef900837124fb91a10b7e8364bb742e06dee4a1
7
+ data.tar.gz: d34123cb7cdf68a20195a4d95a408d30922ec129ab463d894360fecf76574f354bcb8f96c8c909882a09de50168a84696a164db7b8244f5e4d5b97c4899399f3
@@ -25,22 +25,22 @@ module ExAequo
25
25
  end
26
26
  end
27
27
 
28
- def colorize_file(file, reset: false)
28
+ def colorize_file(file, device: $stdout, reset: false)
29
29
  file = File.open(file, 'r') if String === file
30
30
 
31
31
  at_exit do
32
32
  file.close rescue nil
33
33
  end
34
- colorize_lines( file.readlines(chomp: true) )
34
+ colorize_lines( file.readlines(chomp: true), device:, reset: )
35
35
  end
36
36
 
37
- def colorize_lines(lines, reset: false)
37
+ def colorize_lines(lines, reset: false, device: $stdout)
38
38
  lines = lines.split(%r{\n\r?}) if String === lines
39
39
  lines
40
40
  .each_with_index do | line, idx |
41
41
  case colorize(line, reset:)
42
42
  in {ok: true, result:}
43
- puts result
43
+ device.puts result
44
44
  in {ok: false, error:}
45
45
  $stderr.puts("ERROR in line #{idx.succ} ** #{error} **")
46
46
  end
@@ -3,14 +3,13 @@
3
3
  require_relative 'constants'
4
4
  module ExAequo::Base::KernelHelper extend self
5
5
 
6
- def require_subdir(file, descend:, &blk)
7
-
8
- raise ArgumentError, "must not provide positional file parameter #{file.inspect} and a block" if file && blk
9
- raise ArgumentError, "must provide file or block" unless file || blk
10
- if file
11
- req_subdir_file(file, descend:)
12
- else
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?
13
10
  req_subdir_blk(descend:, &blk)
11
+ else
12
+ req_subdir_file(File.join(files), descend:)
14
13
  end
15
14
  end
16
15
 
@@ -46,8 +45,8 @@ module ExAequo::Base::KernelHelper extend self
46
45
  end
47
46
 
48
47
  module Kernel
49
- def require_subdir(file=nil, descend: false, &blk)
50
- ExAequo::Base::KernelHelper.require_subdir(file, descend:, &blk)
48
+ def require_subdir(*files, descend: false, &blk)
49
+ ExAequo::Base::KernelHelper.require_subdir(*files, descend:, &blk)
51
50
  end
52
51
  end
53
52
  # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -4,7 +4,13 @@ require 'ostruct'
4
4
  require 'forwarder'
5
5
  class OpenStruct
6
6
  extend Forwarder
7
- forward_all :deconstruct_keys, :empty?, :fetch, to: :to_h
7
+ forward_all :deconstruct_keys, :empty?, :fetch, :has_key?, to: :to_h
8
+
9
+ def self.to_proc
10
+ -> hashy do
11
+ new hashy
12
+ end
13
+ end
8
14
 
9
15
  def update(hashy)
10
16
  hashy.to_h.each do |k, v|
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../colorize/colorizer'
4
+ class String
5
+ def colored(color, reset: true)
6
+ colors = [color, self, (reset ? :reset : nil)].compact
7
+ Colorize::Colorizer.colored(*colors)
8
+ end
9
+
10
+ def pcolored(color, device: $stdout) = Colorize::Colorizer.pcolored(color, self, device:)
11
+ end
12
+ # 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.3'
5
+ VERSION = '0.1.5'
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -68,6 +68,7 @@ files:
68
68
  - lib/ex_aequo/base/kernel.rb
69
69
  - lib/ex_aequo/base/match_data.rb
70
70
  - lib/ex_aequo/base/open_struct.rb
71
+ - lib/ex_aequo/base/string/colorize.rb
71
72
  - lib/ex_aequo/base/version.rb
72
73
  homepage: https://codeberg.org/lab419/rb_ex_aequo_base
73
74
  licenses: