ex_aequo 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2aaf57df3f78e7ecdd11fdf189a6dbd0942a68d9ec41213713583bebd533c5dd
4
- data.tar.gz: 799c05c0d0b4e4f20d736de98017c960e40fc370fabbfce0d3fe5827499cdafa
3
+ metadata.gz: ecfee3b816360cda72ebf826ecd5f17301eafad003962b860711e8195b7f6ee5
4
+ data.tar.gz: 80500186030dab2c7ad0cbf37c1dbff0c067a88b90cbb3422c3f2da121f1c45b
5
5
  SHA512:
6
- metadata.gz: c4ee1ab2d221d3fe055f3e9a4d27c76fef3237af11718a3fef986702f5a08511cb43a30a439fd3e896b8a86d785691d3aab01327dbbca8d54026f6c87292b390
7
- data.tar.gz: e038d29057424cf6f2f45139562c060b76221eca5fe6c55eaf3ae0bb0bf58b9b68666122e11d5eedf8aff396c241b1e11f1fa87892ee710e85dd02cdfd883812
6
+ metadata.gz: 950e811e86bcc7d34882ab1a1a00ef9e9d82bfada7cdf98dab119e7df76e4101c8c6b6418f13d05c99dc831149c8e7263c558b2bd642efa9ff80ea137d887d6e
7
+ data.tar.gz: f395398d33a331e996bb571ee3368aee8a0c648629b77eb9a0e30f87eab841b4dddc5897e5177fdc5a4e6fdfaaef977446f2e772764a54b663b05c03e0eebaba
data/README.md CHANGED
@@ -97,7 +97,7 @@ And, we can also provide allowed values (N.B. ruby sytnax is default)
97
97
 
98
98
  ## Context: Colors
99
99
 
100
- Given the includion of the `Color` module
100
+ Given the inclusion of the `Color` module
101
101
  ```ruby
102
102
  include ExAequo::Color
103
103
  ```
@@ -131,14 +131,25 @@ Or we can omit the reset
131
131
  expect(colorize('red', ansi: :green, reset: false)).to eq("\e[32mred")
132
132
  ```
133
133
 
134
+ ### Context: Colorize Text
134
135
 
136
+ Given we include the Color::Text module
137
+ ```ruby
138
+ require 'ex_aequo/color/text'
139
+ include ExAequo::Color::Text
140
+ ```
135
141
 
142
+ Then we can obtain a colored text as follows
143
+ ```ruby
144
+ expect(colorized_text(:red, 'green', :yellow, 'blue', :reset, 'white'))
145
+ .to eq("\e[31mgreen\e[33mblue\e[0mwhite")
146
+ ```
136
147
 
137
-
148
+ ## Other Tools are described [here](/speculations)
138
149
 
139
150
  ## LICENSE
140
151
 
141
- Copyright 2022 Robert Dober robert.dober@gmail.com
152
+ Copyright 202[2,3] Robert Dober robert.dober@gmail.com
142
153
 
143
154
  Apache-2.0 [c.f LICENSE](LICENSE)
144
155
  <!-- SPDX-License-Identifier: Apache-2.0 -->
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module Color
5
+ module Text extend self
6
+
7
+ AnsiColors = ExAequo::Color::Ansi::AnsiColorEscape.keys.freeze
8
+
9
+ def put_col(*segments, to: $stdout)
10
+ to.puts(colorized_text(segments))
11
+ end
12
+
13
+ def colorized_text(*segments)
14
+ if ENV['NO_COLOR']
15
+ segments.flatten.filter { String === _1 }.join
16
+ else
17
+ segments.flatten.map(&_color_or_text).join
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+
24
+ def _color_or_text
25
+ -> color_or_text do
26
+ case color_or_text
27
+ when Symbol
28
+ _colorize(color_or_text)
29
+ else
30
+ color_or_text
31
+ end
32
+ end
33
+ end
34
+
35
+ def _colorize(color)
36
+ case ExAequo::Color::Ansi::AnsiColorEscape[color]
37
+ when nil
38
+ if color == :reset
39
+ ExAequo::Color.reset
40
+ else
41
+ raise ArgumentError, "#{color} not yet implemented"
42
+ end
43
+ else
44
+ ExAequo::Color::Ansi.ansi(color)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module Tools
5
+ module TextScanner extend self
6
+ def scan(str, rgx: '/', ws_at_end: true)
7
+ r = Regexp === rgx ? r : Regex.compile(rgx)
8
+ _scan(str, rgx: r, ws_at_end:)
9
+ end
10
+
11
+ private
12
+ def _scan(str, rgx:, ws_at_end:)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ # SPDX-License-Identifier: Apache-2.0
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ExAequo
4
4
  module Version
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.2'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: Apache-2.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ex_aequo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-26 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forwarder3
@@ -43,6 +43,7 @@ files:
43
43
  - lib/ex_aequo/color/colorizer.rb
44
44
  - lib/ex_aequo/color/modifiers.rb
45
45
  - lib/ex_aequo/color/rgb.rb
46
+ - lib/ex_aequo/color/text.rb
46
47
  - lib/ex_aequo/color/web.rb
47
48
  - lib/ex_aequo/colors.rb
48
49
  - lib/ex_aequo/kernel.rb
@@ -50,6 +51,7 @@ files:
50
51
  - lib/ex_aequo/kernel/fn.rb
51
52
  - lib/ex_aequo/my_struct.rb
52
53
  - lib/ex_aequo/my_struct/class_methods.rb
54
+ - lib/ex_aequo/tools/text_scanner.rb
53
55
  - lib/ex_aequo/version.rb
54
56
  homepage: https://gitlab.com/robert_dober/rb_ex_aequo
55
57
  licenses: