tablesmith 0.2.2 → 0.3.0

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
  SHA1:
3
- metadata.gz: a2debe86ed561ee342350d05b984e6519aafff2a
4
- data.tar.gz: 64ab1246d907cb92b33e18bdf0a66ccea31047a0
3
+ metadata.gz: 8f3522932a6fc5ebef456813b2e66ae176bd713f
4
+ data.tar.gz: 7bc184ba5791b77adceaa0747c3bb2196069817d
5
5
  SHA512:
6
- metadata.gz: 5b4d1e2f5b10d150d9bb6d28c800030703a35a0a3196c4d941f7ed1e62618dfcadf89f1eaab183049b1f75284e63680ae2517489e26db578c5bc8fe0ffbd0073
7
- data.tar.gz: ea5238cdeff276b012e3d7cecfbd061b486e5e3eda77e0d0c1adaaff07b7449db17289289ac7301fff132f5d4fe48178201edd2d781d49055889d005c2bafa7c
6
+ metadata.gz: 6c3a88d707ebc54fa249443d9406ed53b07af4c01701f2e57c210a5bbb42324f1e86ea43584e5c4c5f8c66735c3819c197ac4e42eb5bb8dc0ecd4fe19a3df336
7
+ data.tar.gz: 47318db55b7575fac854a8e2183aa88f95b1e8e4608a25a4ca62df54acd65c10e28e665a121b2b6d543da19369d992384154038ebf09169f4cd931cfa9f08696
@@ -1 +1 @@
1
- 2.3.4
1
+ 2.4.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tablesmith (0.2.2)
4
+ tablesmith (0.3.0)
5
5
  text-table
6
6
 
7
7
  GEM
@@ -20,13 +20,13 @@ GEM
20
20
  multi_json (~> 1.0)
21
21
  arel (3.0.3)
22
22
  builder (3.0.4)
23
- coderay (1.1.1)
23
+ coderay (1.1.2)
24
24
  diff-lcs (1.3)
25
25
  docile (1.1.5)
26
26
  i18n (0.8.6)
27
27
  json (2.1.0)
28
28
  method_source (0.8.2)
29
- multi_json (1.12.1)
29
+ multi_json (1.12.2)
30
30
  pry (0.10.4)
31
31
  coderay (~> 1.1.0)
32
32
  method_source (~> 0.8.1)
@@ -44,7 +44,7 @@ GEM
44
44
  docile (~> 1.1.0)
45
45
  json (>= 1.8, < 3)
46
46
  simplecov-html (~> 0.10.0)
47
- simplecov-html (0.10.1)
47
+ simplecov-html (0.10.2)
48
48
  slop (3.6.0)
49
49
  sqlite3 (1.3.13)
50
50
  text-table (1.2.4)
@@ -63,4 +63,4 @@ DEPENDENCIES
63
63
  tablesmith!
64
64
 
65
65
  BUNDLED WITH
66
- 1.16.0.pre.2
66
+ 1.16.1
@@ -1,4 +1,5 @@
1
1
  require 'text-table'
2
+ require 'csv'
2
3
 
3
4
  module Tablesmith
4
5
  class Table < Array
@@ -39,6 +40,22 @@ module Tablesmith
39
40
  rows.to_text_table
40
41
  end
41
42
 
43
+ def to_csv
44
+ CSV.generate do |csv|
45
+ text_table.rows.each do |row|
46
+ next if row == :separator
47
+ csv << row.map do |cell|
48
+ case cell
49
+ when Hash
50
+ cell[:value]
51
+ else
52
+ cell
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
42
59
  # override in subclass or mixin
43
60
  def row_values(row)
44
61
  row
@@ -1,3 +1,3 @@
1
1
  module Tablesmith
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -42,4 +42,14 @@ describe Table do
42
42
  TABLE
43
43
  actual.to_table.text_table.to_s.should == expected
44
44
  end
45
+
46
+ it 'should output csv' do
47
+ a = [['a', 'b,s', 'c'], %w(d e f)]
48
+ actual = a
49
+ expected = <<~TABLE
50
+ a,"b,s",c
51
+ d,e,f
52
+ TABLE
53
+ actual.to_table.to_csv.should == expected
54
+ end
45
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablesmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-22 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-table