formatador 1.1.0 → 1.1.1
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 +4 -4
- data/SECURITY.md +6 -0
- data/changelog.txt +22 -0
- data/formatador.gemspec +3 -2
- data/lib/formatador/table.rb +5 -5
- data/lib/formatador.rb +1 -1
- data/tests/table_tests.rb +11 -0
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f775eb2a13c13d00ecb5b23150628a0336716adcf9b3125c35b6d6ca3e12827
|
4
|
+
data.tar.gz: f9cfbb270ef4f89f465bbc09711329e379329c84ba603721c736c8ea59146c42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39fe3363f0bb482dc4709c37323f13cfd4422d6e3ad493f4913d9da7f76683c629c61e1d4cf8bc02e89e0bbad6d72b3fa9d4dab6abcab124f7e1289ad0ee9255
|
7
|
+
data.tar.gz: 30d4ea6d8fd9acb1908c39851fd288b215ae11c8c4aebb089e0b1564fa0ee6a93939252f2c4a15e8ecc23e744e21850aaa0f56cb8a345d01ed43eeab96527ae2
|
data/SECURITY.md
ADDED
data/changelog.txt
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
v1.1.1 07/11/25
|
2
|
+
===============
|
3
|
+
|
4
|
+
update actions/stale
|
5
|
+
update actions/checkout
|
6
|
+
improve unicode support
|
7
|
+
update ruby versions in test matrix
|
8
|
+
add funding info
|
9
|
+
move scheduled CI to weekly
|
10
|
+
update tested ruby versions
|
11
|
+
more consistently use length method in tables
|
12
|
+
adjust expected test output for Ruby 3.4+
|
13
|
+
|
14
|
+
v1.1.0 01/24/22
|
15
|
+
===============
|
16
|
+
|
17
|
+
fixes to support ruby 3+
|
18
|
+
add options for right justifying numerics
|
19
|
+
drop unused gemspec directive
|
20
|
+
use https for rubygems.org in gemspec
|
21
|
+
drop duplicate bundle install from CI setup
|
22
|
+
|
1
23
|
v1.0.0 01/20/21
|
2
24
|
===============
|
3
25
|
|
data/formatador.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
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.1.
|
17
|
-
s.date = '
|
16
|
+
s.version = '1.1.1'
|
17
|
+
s.date = '2025-07-11'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -67,6 +67,7 @@ Gem::Specification.new do |s|
|
|
67
67
|
LICENSE.md
|
68
68
|
README.md
|
69
69
|
Rakefile
|
70
|
+
SECURITY.md
|
70
71
|
changelog.txt
|
71
72
|
formatador.gemspec
|
72
73
|
lib/formatador.rb
|
data/lib/formatador/table.rb
CHANGED
@@ -14,7 +14,7 @@ class Formatador
|
|
14
14
|
# Calculate Widths
|
15
15
|
if hashes.empty? && keys
|
16
16
|
keys.each do |key|
|
17
|
-
widths[key] = key
|
17
|
+
widths[key] = length(key)
|
18
18
|
end
|
19
19
|
else
|
20
20
|
hashes.each do |hash|
|
@@ -24,7 +24,7 @@ class Formatador
|
|
24
24
|
if !keys
|
25
25
|
headers << key
|
26
26
|
end
|
27
|
-
widths[key] = [
|
27
|
+
widths[key] = [length(key), widths[key] || 0, length(calculate_datum(key, hash)) || 0].max
|
28
28
|
end
|
29
29
|
headers = headers.uniq
|
30
30
|
end
|
@@ -52,7 +52,7 @@ class Formatador
|
|
52
52
|
# Display data row
|
53
53
|
columns = []
|
54
54
|
headers.each do |header|
|
55
|
-
columns << "[bold]#{header}[/]#{' ' * (widths[header] - header
|
55
|
+
columns << "[bold]#{header}[/]#{' ' * (widths[header] - length(header))}"
|
56
56
|
end
|
57
57
|
display_line("| #{columns.join(' | ')} |")
|
58
58
|
display_line(split)
|
@@ -70,7 +70,7 @@ class Formatador
|
|
70
70
|
else
|
71
71
|
if hash == :split
|
72
72
|
display_line(split)
|
73
|
-
end
|
73
|
+
end
|
74
74
|
end
|
75
75
|
nil
|
76
76
|
end
|
@@ -80,7 +80,7 @@ class Formatador
|
|
80
80
|
private
|
81
81
|
|
82
82
|
def length(value)
|
83
|
-
if Module.const_defined?(:Unicode)
|
83
|
+
if Module.const_defined?(:Unicode) && Unicode.respond_to?(:width)
|
84
84
|
Unicode.width(value.to_s.gsub(PARSE_REGEX, ''))
|
85
85
|
else
|
86
86
|
value.to_s.gsub(PARSE_REGEX, '').chars.reduce(0) { |sum, char| sum += char.bytesize > 1 ? 2 : 1 }
|
data/lib/formatador.rb
CHANGED
data/tests/table_tests.rb
CHANGED
@@ -64,6 +64,16 @@ output = Formatador.parse(output)
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
|
68
|
+
if (RUBY_VERSION.split('.').map(&:to_i) <=> [3, 4, 0]).positive?
|
69
|
+
output = <<-OUTPUT
|
70
|
+
+---+----------------+
|
71
|
+
| [bold]a[/] | [bold]nested[/] |
|
72
|
+
+---+----------------+
|
73
|
+
| 1 | {key: "value"} |
|
74
|
+
+---+----------------+
|
75
|
+
OUTPUT
|
76
|
+
else
|
67
77
|
output = <<-OUTPUT
|
68
78
|
+---+-----------------+
|
69
79
|
| [bold]a[/] | [bold]nested[/] |
|
@@ -71,6 +81,7 @@ output = <<-OUTPUT
|
|
71
81
|
| 1 | {:key=>"value"} |
|
72
82
|
+---+-----------------+
|
73
83
|
OUTPUT
|
84
|
+
end
|
74
85
|
output = Formatador.parse(output)
|
75
86
|
|
76
87
|
tests("#display_table([{:a => 1, :nested => {:key => 'value'}}])").returns(output) do
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatador
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus (Wesley Beary)
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-07-11 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -65,6 +64,7 @@ files:
|
|
65
64
|
- LICENSE.md
|
66
65
|
- README.md
|
67
66
|
- Rakefile
|
67
|
+
- SECURITY.md
|
68
68
|
- changelog.txt
|
69
69
|
- formatador.gemspec
|
70
70
|
- lib/formatador.rb
|
@@ -77,7 +77,6 @@ homepage: https://github.com/geemus/formatador
|
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
81
80
|
rdoc_options:
|
82
81
|
- "--charset=UTF-8"
|
83
82
|
require_paths:
|
@@ -93,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
92
|
- !ruby/object:Gem::Version
|
94
93
|
version: '0'
|
95
94
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
97
|
-
signing_key:
|
95
|
+
rubygems_version: 3.6.9
|
98
96
|
specification_version: 2
|
99
97
|
summary: Ruby STDOUT text formatting
|
100
98
|
test_files: []
|