text-table 1.2.0 → 1.2.1
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.
- data/CHANGELOG.rdoc +9 -5
- data/README.rdoc +6 -7
- data/VERSION +1 -1
- data/lib/text-table/table.rb +1 -2
- data/spec/table_spec.rb +5 -0
- data/text-table.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
=== 1.
|
1
|
+
=== 1.2.1 (2010-01-05)
|
2
|
+
|
3
|
+
* Initialize a Text::Table with an empty array for its rows as default.
|
4
|
+
|
5
|
+
=== 1.2.0 (2010-01-05)
|
2
6
|
|
3
|
-
*
|
7
|
+
* Added an easy way to align columns.
|
8
|
+
* Fixed compatibility with Ruby 1.8.6
|
4
9
|
|
5
10
|
=== 1.1.0 (2009-12-28)
|
6
11
|
|
7
12
|
* Centered headers by default.
|
8
13
|
* Revamped specs and made them more extensive.
|
9
14
|
|
10
|
-
=== 1.
|
15
|
+
=== 1.0.1 (2009-12-21)
|
11
16
|
|
12
|
-
*
|
13
|
-
* Fixed compatibility with Ruby 1.8.6
|
17
|
+
* Initial stable release.
|
data/README.rdoc
CHANGED
@@ -23,16 +23,16 @@ and to be able to model-out the classes differently.
|
|
23
23
|
If you haven't yet,
|
24
24
|
|
25
25
|
gem install gemcutter
|
26
|
-
gem
|
26
|
+
gem tumble
|
27
27
|
|
28
28
|
Then,
|
29
29
|
|
30
30
|
gem install text-table
|
31
31
|
|
32
32
|
|
33
|
-
== Calling the <tt>
|
33
|
+
== Calling the <tt>to_table</tt> Method
|
34
34
|
|
35
|
-
Just call the <tt>
|
35
|
+
Just call the <tt>to_table</tt> method (or <tt>to_text_table</tt> if the former is already defined) on Arrays (and other Enumerables).
|
36
36
|
|
37
37
|
require 'rubygems'
|
38
38
|
require 'text-table'
|
@@ -44,7 +44,7 @@ Just call the <tt>to_text_table</tt> method on Arrays (and other Enumerables).
|
|
44
44
|
['Average', 93, 96]
|
45
45
|
]
|
46
46
|
|
47
|
-
puts array.
|
47
|
+
puts array.to_table
|
48
48
|
|
49
49
|
# +---------+-----------+--------+
|
50
50
|
# | Student | Mid-Terms | Finals |
|
@@ -55,7 +55,7 @@ Just call the <tt>to_text_table</tt> method on Arrays (and other Enumerables).
|
|
55
55
|
|
56
56
|
You could specify that the first row is the table heading.
|
57
57
|
|
58
|
-
puts array.
|
58
|
+
puts array.to_table(:first_row_is_head => true)
|
59
59
|
|
60
60
|
# +---------+-----------+--------+
|
61
61
|
# | Student | Mid-Terms | Finals |
|
@@ -67,7 +67,7 @@ You could specify that the first row is the table heading.
|
|
67
67
|
|
68
68
|
You could also specify that the last row is the table footer.
|
69
69
|
|
70
|
-
puts array.
|
70
|
+
puts array.to_table(:first_row_is_head => true, :last_row_is_foot => true)
|
71
71
|
|
72
72
|
# +---------+-----------+--------+
|
73
73
|
# | Student | Mid-Terms | Finals |
|
@@ -113,7 +113,6 @@ Cells and footers are aligned to the left by default, while headers are centered
|
|
113
113
|
|
114
114
|
table = Text::Table.new do |t|
|
115
115
|
t.head = ['Heading A', 'Heading B']
|
116
|
-
t.rows = []
|
117
116
|
t.rows << ['a1', 'b1']
|
118
117
|
t.rows << ['a2', {:value => 'b2', :align => :right}]
|
119
118
|
t.rows << ['a3', 'b3']
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/lib/text-table/table.rb
CHANGED
@@ -61,7 +61,6 @@ module Text #:nodoc:
|
|
61
61
|
#
|
62
62
|
# table = Text::Table.new do |t|
|
63
63
|
# t.head = ['Heading A', 'Heading B']
|
64
|
-
# t.rows = []
|
65
64
|
# t.rows << ['a1', 'b1']
|
66
65
|
# t.rows << ['a2', {:value => 'b2', :align => :right}]
|
67
66
|
# t.rows << ['a3', 'b3']
|
@@ -124,7 +123,7 @@ module Text #:nodoc:
|
|
124
123
|
@boundary_intersection = options[:boundary_intersection] || '+'
|
125
124
|
@horizontal_padding = options[:horizontal_padding ] || 1
|
126
125
|
@head = options[:head]
|
127
|
-
@rows = options[:rows]
|
126
|
+
@rows = options[:rows] || []
|
128
127
|
@foot = options[:foot]
|
129
128
|
yield self if block_given?
|
130
129
|
end
|
data/spec/table_spec.rb
CHANGED
@@ -12,6 +12,11 @@ describe Text::Table do
|
|
12
12
|
@table = Text::Table.new :rows => @rows, :head => @head, :foot => @foot
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'should initialize with an empty array for its rows as default' do
|
16
|
+
@table = Text::Table.new
|
17
|
+
@table.rows.should == []
|
18
|
+
end
|
19
|
+
|
15
20
|
describe 'should allow setting of attributes' do
|
16
21
|
|
17
22
|
it 'passed as an options hash' do
|
data/text-table.gemspec
CHANGED