texttable 1.1.11 → 1.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/texttable.rb +11 -2
- data/texttable.gemspec +2 -2
- metadata +3 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d22a3cfda2785ea934f180cb298d54b83baa252bcc9196e3747e539d1a46e0
|
4
|
+
data.tar.gz: 746d582a99f08acf7b968af2d86a480e6795eca0164400ce3196e7794dd6536d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be1a9b690c8a01457dffe6d5b140379e3f8fb998d9f7987ed2437b04ee157a3b9db2a14827554ce48811d189ade7a081c869b9f059b4030d9aa490a01c18584f
|
7
|
+
data.tar.gz: 03d5e2dd612f2a48f98e212419fde36d7435f29fedf435dda683364cc049d93349e9d0be8795c9069c5255c589a9533ecba9f2c189a551ed63903f42ed99c3ae
|
data/lib/texttable.rb
CHANGED
@@ -123,6 +123,11 @@ class TextTable
|
|
123
123
|
@cols.each {|col, pos| yield col, @values[pos] }
|
124
124
|
end
|
125
125
|
|
126
|
+
def map
|
127
|
+
@rows or raise "no rows defined"
|
128
|
+
@rows.map.with_index {|values, row| yield(row(row)) }
|
129
|
+
end
|
130
|
+
|
126
131
|
def [](field, val=nil)
|
127
132
|
index = index(field)
|
128
133
|
value = vals[index] if index
|
@@ -170,7 +175,7 @@ class TextTable
|
|
170
175
|
|
171
176
|
def show!(list=nil)
|
172
177
|
meth = list.is_a?(Array) ? list.method(:push) : method(:puts)
|
173
|
-
join = "
|
178
|
+
join = " │ "
|
174
179
|
size = @cols.size
|
175
180
|
full = [@cols.keys] + rows
|
176
181
|
full.each_with_index do |vals, i| # only when asymmetric
|
@@ -181,7 +186,7 @@ class TextTable
|
|
181
186
|
lens = full.map {|r| r.map {|c| c.to_s.size}}.transpose.map(&:max)
|
182
187
|
pict = lens.map {|len| "%-#{len}.#{len}s" }.join(join)
|
183
188
|
pict = [join, pict, join].join.strip
|
184
|
-
line = (pict % ([""] * size)).tr("
|
189
|
+
line = (pict % ([""] * size)).tr("│ ", "•─")
|
185
190
|
seen = -1
|
186
191
|
meth["", line]
|
187
192
|
full.each do |vals|
|
@@ -196,6 +201,10 @@ class TextTable
|
|
196
201
|
(@rows || []).map {|r| r.each_with_index.inject(obj) {|h, (v, c)| h[fields[c]] = v; h }}
|
197
202
|
end
|
198
203
|
|
204
|
+
def to_hash
|
205
|
+
Hash[@cols.keys.zip(@values)]
|
206
|
+
end
|
207
|
+
|
199
208
|
def csv(sep=',', encoding: nil, **kw)
|
200
209
|
require 'csv'
|
201
210
|
out = kw.key?(:out) ? (kw.delete(:out) || "").dup : nil
|
data/texttable.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "texttable"
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.13"
|
6
6
|
s.author = "Steve Shreeve"
|
7
7
|
s.email = "steve.shreeve@gmail.com"
|
8
8
|
s.summary = "An easy way to work with rows and columns as simple tables"
|
9
9
|
s.description = "This gem will auto-size based on column widths."
|
10
10
|
s.homepage = "https://github.com/shreeve/texttable"
|
11
11
|
s.license = "MIT"
|
12
|
-
s.files = `git ls-files`.split("\
|
12
|
+
s.files = `git ls-files -z`.split("\0") - %w[.gitignore]
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texttable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem will auto-size based on column widths.
|
14
14
|
email: steve.shreeve@gmail.com
|
@@ -16,7 +16,6 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
- ".ruby-version"
|
20
19
|
- Gemfile
|
21
20
|
- LICENSE
|
22
21
|
- README.md
|
@@ -41,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
40
|
- !ruby/object:Gem::Version
|
42
41
|
version: '0'
|
43
42
|
requirements: []
|
44
|
-
rubygems_version: 3.
|
43
|
+
rubygems_version: 3.4.7
|
45
44
|
signing_key:
|
46
45
|
specification_version: 4
|
47
46
|
summary: An easy way to work with rows and columns as simple tables
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.1.2
|