formatador 1.2.0 → 1.2.2

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: cf29b39c71a7f045ff085d5a31127c714b96e2c59b8fbaebff931084a1499a4d
4
- data.tar.gz: 4b165f7014636a0e333c2140fb89667d9203862d960f1fc7f91ca6d8087cb929
3
+ metadata.gz: 979f3f1634d89f9407a8409589b9d6a1d8edff7684851b0990c520fa89c92019
4
+ data.tar.gz: d976da618e69016c3d567f7b8ace3619e14effd3ec85b15a45e69481499a7a0d
5
5
  SHA512:
6
- metadata.gz: 611aebde13dcc7ce85d0f9033bcd42519d19a94ea6427aacf4f43c5800ecc2d655660fa5de146e4acd0c3106dc9f383def09d57ca4dcdbd6016bbc5831cd2411
7
- data.tar.gz: 5ba6a7f4bb3fb80e95c8b941ad12f2d937819b65cfa651d985bc080affe30723447309bb5ce0c1baf02777f70e849ba3108ed60d6f22c1e75cf0db3fcb92306c
6
+ metadata.gz: 408843aac667785e14869ef4acc64905803490337b654b15c3f7609fde0c10f8f0afa4aaef2194731a3cc3111865ca12f4b3539f511b9bfed63f2e8a7278f7d5
7
+ data.tar.gz: 793ea9a1eb0b08cb7623de23184be9b1c687331e65340efc0502fe9b08ba5e9c44f66d881c5a321e27ed5136c9bf11079568bda228cf2d98f9a8552f6223083b
data/changelog.txt CHANGED
@@ -1,3 +1,14 @@
1
+ v1.2.2 10/28/25
2
+ ===============
3
+
4
+ add faint
5
+
6
+ v1.2.1 09/17/25
7
+ ===============
8
+
9
+ add color output support for github actions
10
+ fix most lints
11
+
1
12
  v1.2.0 08/08/25
2
13
  ===============
3
14
 
data/formatador.gemspec CHANGED
@@ -7,14 +7,14 @@
7
7
  Gem::Specification.new do |s|
8
8
  s.specification_version = 2 if s.respond_to? :specification_version=
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
- s.rubygems_version = '1.3.5'
10
+ s.rubygems_version = '3.6.9'
11
11
 
12
12
  ## Leave these as is they will be modified for you by the rake gemspec task.
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'formatador'
16
- s.version = '1.2.0'
17
- s.date = '2025-08-08'
16
+ s.version = '1.2.2'
17
+ s.date = '2025-10-28'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
data/lib/formatador.rb CHANGED
@@ -1,62 +1,64 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'formatador', 'table')
2
4
  require File.join(File.dirname(__FILE__), 'formatador', 'progressbar')
3
5
 
4
6
  require 'reline' # for table char width calculations
5
7
 
6
8
  class Formatador
7
-
8
- VERSION = '1.2.0'
9
+ VERSION = '1.2.2'
9
10
 
10
11
  STYLES = {
11
- :"\/" => "0",
12
- :reset => "0",
13
- :bold => "1",
14
- :underline => "4",
15
- :blink_slow => "5",
16
- :blink_fast => "6",
17
- :negative => "7", # invert color/color
18
- :normal => "22",
19
- :underline_none => "24",
20
- :blink_off => "25",
21
- :positive => "27", # revert color/color
22
- :_black_ => "40",
23
- :_red_ => "41",
24
- :_green_ => "42",
25
- :_yellow_ => "43",
26
- :_blue_ => "44",
27
- :_magenta_ => "45",
28
- :_purple_ => "45",
29
- :_cyan_ => "46",
30
- :_white_ => "47",
31
- :_light_black_ => "100",
32
- :_light_red_ => "101",
33
- :_light_green_ => "102",
34
- :_light_yellow_ => "103",
35
- :_light_blue_ => "104",
36
- :_light_magenta_ => "105",
37
- :_light_purple_ => "105",
38
- :_light_cyan_ => "106",
39
- :black => "30",
40
- :red => "31",
41
- :green => "32",
42
- :yellow => "33",
43
- :blue => "34",
44
- :magenta => "35",
45
- :purple => "35",
46
- :cyan => "36",
47
- :white => "37",
48
- :light_black => "90",
49
- :light_red => "91",
50
- :light_green => "92",
51
- :light_yellow => "93",
52
- :light_blue => "94",
53
- :light_magenta => "95",
54
- :light_purple => "95",
55
- :light_cyan => "96",
56
- }
57
-
58
- PARSE_REGEX = /\[(#{ STYLES.keys.join('|') })\]/ix
59
- INDENT_REGEX = /\[indent\]/ix
12
+ "\/": '0',
13
+ reset: '0',
14
+ bold: '1',
15
+ faint: '2',
16
+ underline: '4',
17
+ blink_slow: '5',
18
+ blink_fast: '6',
19
+ negative: '7', # invert color/color
20
+ normal: '22',
21
+ underline_none: '24',
22
+ blink_off: '25',
23
+ positive: '27', # revert color/color
24
+ _black_: '40',
25
+ _red_: '41',
26
+ _green_: '42',
27
+ _yellow_: '43',
28
+ _blue_: '44',
29
+ _magenta_: '45',
30
+ _purple_: '45',
31
+ _cyan_: '46',
32
+ _white_: '47',
33
+ _light_black_: '100',
34
+ _light_red_: '101',
35
+ _light_green_: '102',
36
+ _light_yellow_: '103',
37
+ _light_blue_: '104',
38
+ _light_magenta_: '105',
39
+ _light_purple_: '105',
40
+ _light_cyan_: '106',
41
+ black: '30',
42
+ red: '31',
43
+ green: '32',
44
+ yellow: '33',
45
+ blue: '34',
46
+ magenta: '35',
47
+ purple: '35',
48
+ cyan: '36',
49
+ white: '37',
50
+ light_black: '90',
51
+ light_red: '91',
52
+ light_green: '92',
53
+ light_yellow: '93',
54
+ light_blue: '94',
55
+ light_magenta: '95',
56
+ light_purple: '95',
57
+ light_cyan: '96'
58
+ }.freeze
59
+
60
+ PARSE_REGEX = /\[(#{STYLES.keys.join('|')})\]/ix.freeze
61
+ INDENT_REGEX = /\[indent\]/ix.freeze
60
62
 
61
63
  def initialize
62
64
  @indent = 1
@@ -75,21 +77,21 @@ class Formatador
75
77
  end
76
78
 
77
79
  def display_lines(lines = [])
78
- for line in [*lines]
80
+ [*lines].each do |line|
79
81
  display_line(line)
80
82
  end
81
83
  nil
82
84
  end
83
85
 
84
86
  def parse(string)
85
- if $stdout.tty?
86
- string.gsub(PARSE_REGEX) { "\e[#{STYLES[$1.to_sym]}m" }.gsub(INDENT_REGEX) { indentation }
87
+ if color_support
88
+ string.gsub(PARSE_REGEX) { "\e[#{STYLES[::Regexp.last_match(1).to_sym]}m" }.gsub(INDENT_REGEX) { indentation }
87
89
  else
88
90
  strip(string)
89
91
  end
90
92
  end
91
93
 
92
- def indent(&block)
94
+ def indent
93
95
  @indent += 1
94
96
  yield
95
97
  ensure
@@ -102,7 +104,7 @@ class Formatador
102
104
 
103
105
  def redisplay(string = '', width = 120)
104
106
  print("\r#{' ' * width}\r")
105
- display("#{string}")
107
+ display(string.to_s)
106
108
  nil
107
109
  end
108
110
 
@@ -121,7 +123,7 @@ class Formatador
121
123
  string.gsub(PARSE_REGEX, '').gsub(INDENT_REGEX) { indentation }
122
124
  end
123
125
 
124
- %w{display display_line display_lines indent parse redisplay redisplay_line new_line redisplay_progressbar}.each do |method|
126
+ %w[display display_line display_lines indent parse redisplay redisplay_line new_line redisplay_progressbar].each do |method|
125
127
  eval <<-DEF
126
128
  def self.#{method}(*args, &block)
127
129
  Thread.current[:formatador] ||= new
@@ -130,7 +132,7 @@ class Formatador
130
132
  DEF
131
133
  end
132
134
 
133
- %w{display_table display_compact_table}.each do |method|
135
+ %w[display_table display_compact_table].each do |method|
134
136
  eval <<-DEF
135
137
  def self.#{method}(*args, **kwargs, &block)
136
138
  Thread.current[:formatador] ||= new
@@ -139,4 +141,9 @@ class Formatador
139
141
  DEF
140
142
  end
141
143
 
144
+ private
145
+
146
+ def color_support
147
+ @color_support ||= $stdout.tty? || ENV['GITHUB_ACTIONS'] == 'true'
148
+ end
142
149
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatador
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-08 00:00:00.000000000 Z
10
+ date: 2025-10-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: reline
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.7.1
109
+ rubygems_version: 3.6.9
110
110
  specification_version: 2
111
111
  summary: Ruby STDOUT text formatting
112
112
  test_files: []