texttable 1.1.0 → 1.1.2

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 +4 -3
  3. data/texttable.gemspec +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dc849d43312afb4106b6db6908f154f937409c3ac780a6d2ee36645f7155e7d
4
- data.tar.gz: d947accbe4d63f66d6c9d321aa96f8936a594d4c5a3e34dd05259b61645bb3c7
3
+ metadata.gz: 9952b36c316d6bfb8b99b98c83e6b443e8df7fab62098d48d2106bfaba910762
4
+ data.tar.gz: fac19dec457d9b53adbdb11a6f24b39496af73b882ab4abd856039f10c6b07e4
5
5
  SHA512:
6
- metadata.gz: b40935ce7e9ea135221c2505cb6ea7c597d67f5d9e991b834c801ef7eb3fd162e1d320b2eec1c3b835bc343d4f8d5c5f5afebf7ba2b7e28164c69d16166b97d3
7
- data.tar.gz: 1e21bbc4c2ebf4439910113ee6d0136c36894f2c7d2e357a82163e3e69842f051ea9903be5bed95cafc15a0a226a0f379655ba0df631b4301cdd5ddbaf3f3cf4
6
+ metadata.gz: 55ef3df123eaf0261b9c3962389b667828653ea50430ca31183c51418aedba3047f9522d5e2bb8b666a81263cd283d1bb63e0fbea75ece990b24cc654cc39562
7
+ data.tar.gz: 7198b28bdf371c91976476542a5b903f393009a5d2cbadb8ca1ba89911670453d536929588ced94f6d2f84c05335cf7f0a3568a8e008db079d3ae3ae75d13220
@@ -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
- puts "insert into #{q}#{table}#{q} set #{list * ', '};" if !list.empty?
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "texttable"
5
- s.version = "1.1.0"
5
+ s.version = "1.1.2"
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.0
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-27 00:00:00.000000000 Z
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.0.6
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