ex_aequo_base 0.1.3 → 0.1.4

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: 2f42430967e4c2f9e06b956df55783e74a92a1e820d226b580517f21f50c00e2
4
+ data.tar.gz: fb27b96a0dcabf3730527c162013114a465c00ac4a369595c25ac17fc9d032ad
5
5
  SHA512:
6
- metadata.gz: cad017a7d02b4823e436df3035ec128e9ebca3ed4d914a06ec046f464cee07ecdd36c1c3d9b736323c42ebf73bd1756936844c9ef3adf17e518998d42260b13c
7
- data.tar.gz: d19f2261d4ea8bef04d182ac411651e6353c9f2ff3ef886aa97bc67d3a092d33643ea7cb5e3afc7d902a45fd43b6dd7399bb55c7262c9044bc4b3f430ab055b8
6
+ metadata.gz: 84104dce64e79d0fe8945d1aeaac2f63bbb14329933eb4e9f84aefbfae68f2b842c9c0de5c82dca1c1c1cfddc3d2060dd532f7d03001efeffe5d3625b15b8a23
7
+ data.tar.gz: ce17b03ae58f71e3b0d9c2c45d9c7e55a32b1ad7788f1c31163f4fd263879c340a1a6558495026060caf950dcf0a394eb43ccef3b1112f1164165e8b3a241343
@@ -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
@@ -4,7 +4,7 @@ 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
8
 
9
9
  def update(hashy)
10
10
  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.4'
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.4
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: