texttable 1.1.7 → 1.1.9

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: 7e00f8d89b3eda372e1d263c439bde89c2a49fc514733c03d9d173c27d88a21b
4
- data.tar.gz: bd3e7c03b5baa30ad80517ed68ed2cf14937ac037119a49af90e97bc99fe9cf0
3
+ metadata.gz: 79e3c725b088a02d42d7096862e6087d090ba057b66e28297bf796597da59f16
4
+ data.tar.gz: 7a07a8a529036fe884d27290576c530b29c990a606866f09d8aa24526a7e1661
5
5
  SHA512:
6
- metadata.gz: 8983dbf73e36741f53acb51f953e88bfc2a77068ddd79aef042ed74e608e17d186d6c3f245bc6d8bcf548cfdb34bb3c40774af6df9e7375d8b6255a744affa10
7
- data.tar.gz: c85f63f6c92c17475860fac370fb64c5990e7de39ebf471fcc722e099f6c3b36329d2309f3ea919851c48f99a2515f54b4ed3319f05c63e287fb5e30b04e8a8a
6
+ metadata.gz: 5ac2b2ece811fc38432cec0ad1315c211030b9effef406d7e715eff94243c5a4535ab6935dab23e0b926f23d70082daa55000253ad6d3a7597050498c6800cf8
7
+ data.tar.gz: 30345f8c02e6ec6169bb82e06ba19be129e6d74c4edb254ff308a989e2fe70cb6a6a0c422e8b87e16e6a5d8f991aad25950a4475a4a4f5cb36c6be4b3f415c48
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5
1
+ 2.6.5
data/lib/texttable.rb CHANGED
@@ -67,6 +67,14 @@ class TextTable
67
67
  index(field, true)
68
68
  end
69
69
 
70
+ def lookup!(field)
71
+ @rows or raise "no rows defined"
72
+ index = index(field)
73
+ lookup = {}
74
+ @rows.each_with_index {|cols, i| lookup[cols[index]] = i}
75
+ lookup
76
+ end
77
+
70
78
  def convert_key(key)
71
79
  key.
72
80
  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
@@ -180,12 +188,8 @@ class TextTable
180
188
  self
181
189
  end
182
190
 
183
- def lookup!(field)
184
- @rows or raise "no rows defined"
185
- index = index(field)
186
- lookup = {}
187
- @rows.each_with_index {|cols, i| lookup[cols[index]] = i}
188
- lookup
191
+ def as_json(obj = defined?(ConfigHash) ? +{} : {})
192
+ (@rows || []).map {|r| r.each_with_index.inject(obj) {|h, (v, c)| h[fields[c]] = v; h }}
189
193
  end
190
194
 
191
195
  def csv(sep=',', encoding: nil, **kw)
data/texttable.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "texttable"
5
- s.version = "1.1.7"
5
+ s.version = "1.1.9"
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"
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.7
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-04-26 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
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubygems_version: 3.1.4
44
+ rubygems_version: 3.2.16
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: An easy way to work with rows and columns as simple tables