texttable 1.1.12 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/texttable.rb +9 -0
  3. data/texttable.gemspec +2 -2
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87e25e891adb38fb970af89bcde4da535c6358a56e5174ecf7672e0b4b08bf38
4
- data.tar.gz: 371c68f35b9dd4a489db7f60401a1613b8a1a49a1ba8bf61ea4e7ae318bac74c
3
+ metadata.gz: d6d22a3cfda2785ea934f180cb298d54b83baa252bcc9196e3747e539d1a46e0
4
+ data.tar.gz: 746d582a99f08acf7b968af2d86a480e6795eca0164400ce3196e7794dd6536d
5
5
  SHA512:
6
- metadata.gz: 3f21e246ab40d03a44b8c57c53e5f98383fc716b8dca109015fd3f9153ad69810d368d8c63b4da05115fe1e150b6ec152b002772562567cff46ba2a82f603230
7
- data.tar.gz: b1e542914ee61d821dfcfacb9fe83aa734fc919b1bbe76a37f8581d61d47973fd6596d80e64b887949a05799efa8e73a047601ba9b3e47b7748b1b229dfe27ba
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
@@ -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.12"
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("\n") - %w[.gitignore]
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.12
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: 2023-02-22 00:00:00.000000000 Z
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
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
- rubygems_version: 3.4.6
43
+ rubygems_version: 3.4.7
44
44
  signing_key:
45
45
  specification_version: 4
46
46
  summary: An easy way to work with rows and columns as simple tables