rtables 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 476b203d969073a14520ac1ea98765e688b211f5
4
- data.tar.gz: 0b6436a04b12f9ca02d6f36653fec415cf19a917
3
+ metadata.gz: f6ca63c3fa094725afe6a512242c42625b804c69
4
+ data.tar.gz: a4007c9aa87978745c6bcb2c1cfc4a8d27cc6be7
5
5
  SHA512:
6
- metadata.gz: fc21c375f9d192b9e50bc8dd2703298b65ba5e431df8544b6816911cf7d8a0bc520da5e0518422bf5c3a46bb2a8c5af5a17f04ab6add3ad04ca2fc0cb920e38e
7
- data.tar.gz: 3ff2f50aed25777364d30e22238428ead2e851f117206fd52b2d9af29a4ea46469088a149d443f8c3c30aaed8c71a6be98330458cda431196233dbdc85feb39b
6
+ metadata.gz: a8ab35eeb7fd374545eb59e5ed27b50023dc8c25d1f5a7ddda5e41b1e7f36344a70dac8c2dd5f5cbf337fcfb177b20b5529d1f242f16774eef7aebdf780cc765
7
+ data.tar.gz: de32615674f18a08e305e811a32a4fb353dfe27e1d0ce239d07126497fa3f126be7265f1feb2005720ae8ab89e9f2ee609294162eadc7ca0a316efded96e753f
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Ruby Tables
2
+ [![Build Status](https://travis-ci.org/Zarthus/rtables.svg?branch=master)](https://travis-ci.org/Zarthus/rtables)
3
+ [![Code Climate](https://codeclimate.com/github/Zarthus/rtables/badges/gpa.svg)](https://codeclimate.com/github/Zarthus/rtables)
4
+ [![Test Coverage](https://codeclimate.com/github/Zarthus/rtables/badges/coverage.svg)](https://codeclimate.com/github/Zarthus/rtables/coverage)
2
5
 
3
6
  RTables (Ruby Tables) is a small library that helps you generate table output in various predefined formats.
4
7
 
@@ -1,9 +1,9 @@
1
- # Small Monospace Table
1
+ # Monospace Table
2
2
 
3
3
  Code:
4
4
 
5
5
  ```ruby
6
- require 'rtables/table/monotable'
6
+ require 'rtables'
7
7
  table = RTables::Table::MonoTable.new
8
8
 
9
9
  table.add_column('Example')
@@ -15,19 +15,21 @@ table.add_row('Very Large Field', 'With a large amount of text on it.')
15
15
  table.render
16
16
  ```
17
17
 
18
- Looks like:
19
-
18
+ Looks like (output from .ci/show_table_formats.rb):
20
19
  ```
21
- +---------+------------------------------------+
22
- | Example | First |
23
- | Field | This is an example text |
24
- +---------+------------------------------------+
25
- | Example | Small |
26
- | Field | Field |
27
- +---------+------------------------------------+
28
- | Example | Very Large Field |
29
- | Field | With a large amount of text on it. |
30
- +---------+------------------------------------+
20
+ +-------------+---------------------------------------------------------+
21
+ | Name | Maxine Caulfield |
22
+ | Occupation | Time Wizard |
23
+ | Voice Actor | Serena de Mouroux |
24
+ +-------------+---------------------------------------------------------+
25
+ | Name | David N. Madsen |
26
+ | Occupation | Head of Security at Blackwell Academy |
27
+ | Voice Actor | Don McManus |
28
+ +-------------+---------------------------------------------------------+
29
+ | Name | Mark Jefferson |
30
+ | Occupation | Professional Photographer, Teacher at Blackwell Academy |
31
+ | Voice Actor | Derek Phillips |
32
+ +-------------+---------------------------------------------------------+
31
33
  ```
32
34
 
33
35
  ## Positives
@@ -38,5 +40,3 @@ Looks like:
38
40
  ## Negatives
39
41
 
40
42
  - Requires a Monospace font to render properly.
41
- - If field names are too long the table will look strange.
42
- - Table::MonoTable solves this by making use of [`BigMonoTable`](BigMonoTable.md) dynamically when the content is too big.
@@ -0,0 +1,36 @@
1
+ # Plain Table
2
+
3
+ Code:
4
+
5
+ ```ruby
6
+ require 'rtables'
7
+ table = RTables::Table::PlainTable.new
8
+
9
+ table.add_column('Example')
10
+ table.add_column('Field')
11
+ table.add_row('First', 'This is an example text')
12
+ table.add_row('Small', 'Field')
13
+ table.add_row('Very Large Field', 'With a large amount of text on it.')
14
+
15
+ table.render
16
+ ```
17
+
18
+ Looks like (output from .ci/show_table_formats.rb):
19
+ ```
20
+ Name: Maxine Caulfield
21
+ Occupation: Time Wizard
22
+ Voice Actor: Serena de Mouroux
23
+ ----
24
+ Name: David N. Madsen
25
+ Occupation: Head of Security at Blackwell Academy
26
+ Voice Actor: Don McManus
27
+ ----
28
+ Name: Mark Jefferson
29
+ Occupation: Professional Photographer, Teacher at Blackwell Academy
30
+ Voice Actor: Derek Phillips
31
+ ----
32
+ ```
33
+
34
+ ## Positives
35
+
36
+ - Displays the same everywhere
@@ -0,0 +1,33 @@
1
+ # Simple Table
2
+
3
+ Code:
4
+
5
+ ```ruby
6
+ require 'rtables'
7
+ table = RTables::Table::SimpleTable.new
8
+
9
+ table.add_column('Example')
10
+ table.add_column('Field')
11
+ table.add_row('First', 'This is an example text')
12
+ table.add_row('Small', 'Field')
13
+ table.add_row('Very Large Field', 'With a large amount of text on it.')
14
+
15
+ table.render
16
+ ```
17
+
18
+ Looks like (output from .ci/show_table_formats.rb):
19
+ ```
20
+ Name: Maxine Caulfield, Occupation: Time Wizard, Voice Actor: Serena de Mouroux
21
+ Name: David N. Madsen, Occupation: Head of Security at Blackwell Academy, Voice Actor: Don McManus
22
+ Name: Mark Jefferson, Occupation: Professional Photographer, Teacher at Blackwell Academy, Voice Actor: Derek Phillips
23
+ ```
24
+
25
+
26
+ ## Positives
27
+
28
+ - Displays the same everywhere
29
+ - Takes up very little space
30
+
31
+ ## Negatives
32
+
33
+ - Difficult to read
@@ -0,0 +1,43 @@
1
+ # Unicode Monospace Table
2
+
3
+ Code:
4
+
5
+ ```ruby
6
+ require 'rtables'
7
+ table = RTables::Table::UnicodeMonoTable.new
8
+
9
+ table.add_column('Example')
10
+ table.add_column('Field')
11
+ table.add_row('First', 'This is an example text')
12
+ table.add_row('Small', 'Field')
13
+ table.add_row('Very Large Field', 'With a large amount of text on it.')
14
+
15
+ table.render
16
+ ```
17
+
18
+ Looks like (output from .ci/show_table_formats.rb):
19
+ ```
20
+ ┌─────────────┬─────────────────────────────────────────────────────────┐
21
+ │ Name │ Maxine Caulfield │
22
+ │ Occupation │ Time Wizard │
23
+ │ Voice Actor │ Serena de Mouroux │
24
+ ├─────────────┼─────────────────────────────────────────────────────────┤
25
+ │ Name │ David N. Madsen │
26
+ │ Occupation │ Head of Security at Blackwell Academy │
27
+ │ Voice Actor │ Don McManus │
28
+ ├─────────────┼─────────────────────────────────────────────────────────┤
29
+ │ Name │ Mark Jefferson │
30
+ │ Occupation │ Professional Photographer, Teacher at Blackwell Academy │
31
+ │ Voice Actor │ Derek Phillips │
32
+ └─────────────┴─────────────────────────────────────────────────────────┘
33
+ ```
34
+
35
+ ## Positives
36
+
37
+ - Easy to read
38
+ - Perfect for key => value display
39
+
40
+ ## Negatives
41
+
42
+ - Requires a Monospace font to render properly.
43
+ - Will not function when charset is misconfigured, does not use basic ASCII characters.
@@ -27,40 +27,7 @@ table.add_row('It\'s a beautiful day to be a table', 'Indeed.')
27
27
  puts table.to_s
28
28
  ```
29
29
 
30
- The following output may be generated:
31
-
32
- ```
33
- # PlainTable - the most boring table, but also the one that is the most consistent
34
-
35
- Column: Row1 Value1, Column2: Row1 Value2, ...
36
- Column: Row2 Value1, Column2: Row2 Value2, ...
37
- Column: Row3 Value1, Column2: Row3 Value2, ...
38
- ```
39
-
40
- ```
41
- # SimpleTable - slightly less boring table, keeping the same level of consistency
42
-
43
- Column: Row1 Value1
44
- Column2: Row1 Value2
45
- ----
46
- Column: Row2 Value1
47
- Column2: Row2 Value2
48
- ----
49
- Column: Row3 Value1
50
- Column2: Row3 Value2
51
-
52
- ```
53
-
54
- ```
55
- # MonoTable - prettier, but requires a monospace font to function.
56
-
57
- ```
58
-
59
- ```
60
- # UnicodeMonoTable - the prettiest, but requires a monospace font to function.
61
- # Makes use of non-ascii characters, so may cause rendering issues on some clients.
62
-
63
- ```
30
+ You can run `ruby .ci/show_table_formats.rb` to generate a current list of table formats.
64
31
 
65
32
  ## Making your own table
66
33
  Your table needs to meet the following two conditions:
@@ -34,7 +34,7 @@ module RTables
34
34
  end
35
35
 
36
36
  def raise_if_empty
37
- fail TableFormatError, 'Table has no content to display.' if empty?
37
+ fail TableFormatError, 'Table has no content to display.' if empty? || @columns == 0 || @rows == 0
38
38
  end
39
39
 
40
40
  def empty?
@@ -1,3 +1,3 @@
1
1
  module RTables
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtables
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jos Ahrens