gauge-ruby 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/table.rb +12 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d02594acc904fc72ca2ee33b36d035f16a2f7d6
4
- data.tar.gz: 101648409eacd64b386ee67a779676fb4c7e3d34
3
+ metadata.gz: a827a1d745e1a0a7156b9f3ad37b08be91cce127
4
+ data.tar.gz: c5103ef16af489c0426ce789bd7a91836cd45fe0
5
5
  SHA512:
6
- metadata.gz: 4447626f14695ddf0f3ce41562007a4544e4f55451ef0a9d613c83e552f8d1c2c77a04c41021826ae58f31edfb4bbaf18753a4048064d4cb33ed74aabee3012b
7
- data.tar.gz: 99a5cf6190e7e4ab33736ee3dfd15c7b568a30d6fee44681341c4123664f0ddc91b0fca511f47fd489ba23d9e9a9d3a5074ee452ee9bee82dd42c5c995e54713
6
+ metadata.gz: 548a966e03e16389ee57f8708136da420d2fcaa2d39db5d13d89666fc45d186d79fd2690d02e9e1528a43c8e3bec2d423e8790a5ce1f641c524692d7815de21c
7
+ data.tar.gz: 5f22447adbcf0c92f98202c866c873d05e1676465058794d9a837db78baa317db2229368172bc5fbab112d0441c1bcca02c5222e0b52c822122ba0f6381a0643
data/lib/table.rb CHANGED
@@ -55,6 +55,18 @@ module Gauge
55
55
  column_values_as_array(index)
56
56
  end
57
57
 
58
+ # Converts the table to the markdown equivalent string
59
+ def to_s
60
+ col_str = Array.new(@rows.length+2, '')
61
+ @columns.each{|c|
62
+ col_vals = column_values_as_array(c).unshift c
63
+ col_width = col_vals.map(&:length).max
64
+ col_vals.insert(1, '-' * col_width)
65
+ col_str = col_str.zip(col_vals.map{|x| '|' + x.ljust(col_width)}).map { |x| x[0] + x[1]}
66
+ }
67
+ col_str.join('|\n') + '|'
68
+ end
69
+
58
70
  private
59
71
 
60
72
  def column_values_as_array(col_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gauge-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gauge Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-protocol-buffers