texttable 1.1.0 → 1.1.2
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 +4 -3
- data/texttable.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9952b36c316d6bfb8b99b98c83e6b443e8df7fab62098d48d2106bfaba910762
|
4
|
+
data.tar.gz: fac19dec457d9b53adbdb11a6f24b39496af73b882ab4abd856039f10c6b07e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ef3df123eaf0261b9c3962389b667828653ea50430ca31183c51418aedba3047f9522d5e2bb8b666a81263cd283d1bb63e0fbea75ece990b24cc654cc39562
|
7
|
+
data.tar.gz: 7198b28bdf371c91976476542a5b903f393009a5d2cbadb8ca1ba89911670453d536929588ced94f6d2f84c05335cf7f0a3568a8e008db079d3ae3ae75d13220
|
data/lib/texttable.rb
CHANGED
@@ -18,7 +18,7 @@ class TextTable
|
|
18
18
|
cols = cols[0] if cols[0].is_a?(Array) && cols[0][0].is_a?(Array)
|
19
19
|
cols, *rows = cols if cols[0].is_a?(Array)
|
20
20
|
rows = *rows[0] if rows && rows[0].is_a?(Array) && rows[0][0].is_a?(Array)
|
21
|
-
rows = [] if !rows || !rows[0].is_a?(Array)
|
21
|
+
rows = [] if !rows || !rows[0].is_a?(Array) || rows[0].empty?
|
22
22
|
@cols = Hash.new {|h,k| h[k] = h.size}
|
23
23
|
@rows = rows
|
24
24
|
@values = nil
|
@@ -157,7 +157,7 @@ class TextTable
|
|
157
157
|
def tsv; csv("\t"); end
|
158
158
|
def psv; csv("|" ); end
|
159
159
|
|
160
|
-
def sql(table='table', quote: false)
|
160
|
+
def sql(table='table', quote: false, timestamps: false, verb: 'insert')
|
161
161
|
q = quote ? '`' : ''
|
162
162
|
flip = @cols.invert
|
163
163
|
@rows.each do |vals|
|
@@ -166,7 +166,8 @@ class TextTable
|
|
166
166
|
list << "#{q}#{flip[i]}#{q}='#{item.gsub("'","''")}'" if item =~ /\S/
|
167
167
|
list
|
168
168
|
end
|
169
|
-
|
169
|
+
list.push('created_at=now(), updated_at=now()') if timestamps
|
170
|
+
puts "#{verb} into #{q}#{table}#{q} set #{list * ', '};" if !list.empty?
|
170
171
|
end
|
171
172
|
nil
|
172
173
|
end
|
data/texttable.gemspec
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02
|
11
|
+
date: 2020-03-02 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.
|
44
|
+
rubygems_version: 3.1.2
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: An easy way to work with rows and columns as simple tables
|