ex_aequo 0.2.0 → 0.2.3

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: 93c6e147aed9d019eca15bd2ef01eca0a963865edc3836b62ade5ac56a33ac78
4
+ data.tar.gz: f3ada2a623e9f50109f64ca3e6c711e394ccbf7ef3b5f135ff8ece55fc832081
5
5
  SHA512:
6
- metadata.gz: c4ee1ab2d221d3fe055f3e9a4d27c76fef3237af11718a3fef986702f5a08511cb43a30a439fd3e896b8a86d785691d3aab01327dbbca8d54026f6c87292b390
7
- data.tar.gz: e038d29057424cf6f2f45139562c060b76221eca5fe6c55eaf3ae0bb0bf58b9b68666122e11d5eedf8aff396c241b1e11f1fa87892ee710e85dd02cdfd883812
6
+ metadata.gz: 9a74c191b8f1a45e81536e64c715611a2629a9a0a4c79418bdf1ab5f56c20fee4cadb6a4486c81888c8fafac68ec1b8a79f020eae7efc7c28d42a2897685cba0
7
+ data.tar.gz: c857b6f53336633ae930a6d0f0d2616bfae956baaa8353107ce1d00564261ebb1eb196f9f683cfc50d953ec72955dcd21b6986e99f53f0939287f0577aea4546
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,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExAequo
4
+ module Color
5
+ module Text extend self
6
+
7
+ def put_col(*segments, to: $stdout)
8
+ to.puts(colorized_text(segments))
9
+ end
10
+
11
+ def colorized_text(*segments)
12
+ if ENV['NO_COLOR']
13
+ segments.flatten.filter { String === _1 }.join
14
+ else
15
+ segments.flatten.map(&_color_or_text).join
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+
22
+ def _color_or_text
23
+ -> color_or_text do
24
+ case color_or_text
25
+ when Symbol
26
+ _colorize(color_or_text)
27
+ else
28
+ color_or_text
29
+ end
30
+ end
31
+ end
32
+
33
+ def _colorize(color)
34
+ case ExAequo::Color::Ansi::AnsiColorEscape[color]
35
+ when nil
36
+ if color == :reset
37
+ ExAequo::Color.reset
38
+ else
39
+ raise ArgumentError, "#{color} not yet implemented"
40
+ end
41
+ else
42
+ ExAequo::Color::Ansi.ansi(color)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ # 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.3'
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.3
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: