visionmedia-terminal-table 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +3 -0
- data/lib/terminal-table.rb +1 -0
- data/lib/terminal-table/core_ext.rb +5 -6
- data/lib/terminal-table/import.rb +3 -51
- data/lib/terminal-table/table.rb +11 -2
- data/lib/terminal-table/table_helper.rb +53 -0
- data/lib/terminal-table/version.rb +1 -1
- data/spec/cell_spec.rb +2 -1
- data/spec/core_ext_spec.rb +1 -0
- data/spec/import_spec.rb +4 -6
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/table_helper_spec.rb +18 -0
- data/spec/table_spec.rb +233 -183
- data/terminal-table.gemspec +6 -7
- metadata +8 -4
data/Manifest
CHANGED
@@ -5,6 +5,7 @@ lib/terminal-table/core_ext.rb
|
|
5
5
|
lib/terminal-table/heading.rb
|
6
6
|
lib/terminal-table/import.rb
|
7
7
|
lib/terminal-table/table.rb
|
8
|
+
lib/terminal-table/table_helper.rb
|
8
9
|
lib/terminal-table/version.rb
|
9
10
|
lib/terminal-table.rb
|
10
11
|
Manifest
|
@@ -13,7 +14,9 @@ README.rdoc
|
|
13
14
|
spec/cell_spec.rb
|
14
15
|
spec/core_ext_spec.rb
|
15
16
|
spec/import_spec.rb
|
17
|
+
spec/spec.opts
|
16
18
|
spec/spec_helper.rb
|
19
|
+
spec/table_helper_spec.rb
|
17
20
|
spec/table_spec.rb
|
18
21
|
tasks/docs.rake
|
19
22
|
tasks/gemspec.rake
|
data/lib/terminal-table.rb
CHANGED
@@ -28,12 +28,11 @@ class Object
|
|
28
28
|
# in order to support both types of block syntax for DSL's.
|
29
29
|
|
30
30
|
def yield_or_eval &block
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
31
|
+
return unless block
|
32
|
+
if block.arity > 0
|
33
|
+
yield self
|
34
|
+
else
|
35
|
+
self.instance_eval &block
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -1,53 +1,5 @@
|
|
1
|
-
|
2
1
|
require 'terminal-table'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# Generates a Terminal::Table object.
|
8
|
-
#
|
9
|
-
# === Examples:
|
10
|
-
#
|
11
|
-
# puts table(['a', 'b'], [1, 2], [3, 4])
|
12
|
-
#
|
13
|
-
# # OR
|
14
|
-
#
|
15
|
-
# t = table ['a', 'b']
|
16
|
-
# t << [1, 2]
|
17
|
-
# t << [3, 4]
|
18
|
-
# puts t
|
19
|
-
#
|
20
|
-
# # OR
|
21
|
-
#
|
22
|
-
# user_table = table do |t|
|
23
|
-
# t.headings = 'First Name', 'Last Name', 'Email'
|
24
|
-
# t << ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
|
25
|
-
# t << ['Bob', 'Someone', 'bob@vision-media.ca']
|
26
|
-
# t << ['Joe', 'Whatever', 'joe@vision-media.ca']
|
27
|
-
# end
|
28
|
-
# puts user_table
|
29
|
-
#
|
30
|
-
# # OR
|
31
|
-
#
|
32
|
-
# user_table = table do
|
33
|
-
# self.headings = 'First Name', 'Last Name', 'Email'
|
34
|
-
# add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
|
35
|
-
# add_row ['Bob', 'Someone', 'bob@vision-media.ca']
|
36
|
-
# add_row ['Joe', 'Whatever', 'joe@vision-media.ca']
|
37
|
-
# end
|
38
|
-
# puts user_table
|
39
|
-
#
|
40
|
-
# # OR
|
41
|
-
#
|
42
|
-
# rows = []
|
43
|
-
# rows << ['Lines', 100]
|
44
|
-
# rows << ['Comments', 20]
|
45
|
-
# rows << ['Ruby', 70]
|
46
|
-
# rows << ['JavaScript', 30]
|
47
|
-
# puts table(nil, *rows)
|
48
|
-
#
|
49
|
-
|
50
|
-
def table headings = [], *rows, &block
|
51
|
-
Terminal::Table.new :headings => headings.to_a, :rows => rows, &block
|
52
|
-
end
|
53
|
-
end
|
3
|
+
class Object
|
4
|
+
include Terminal::Table::TableHelper
|
5
|
+
end
|
data/lib/terminal-table/table.rb
CHANGED
@@ -6,7 +6,7 @@ module Terminal
|
|
6
6
|
#
|
7
7
|
# This class can be used in many ways, however ultimately you should
|
8
8
|
# require 'terminal-table/import' (which requires terminal-table itself) to use
|
9
|
-
# the Kernel helper method which is easier, and cleaner to use. View
|
9
|
+
# the Kernel helper method which is easier, and cleaner to use. View Object#table
|
10
10
|
# for examples.
|
11
11
|
#
|
12
12
|
# === Examples:
|
@@ -155,5 +155,14 @@ module Terminal
|
|
155
155
|
[headings] + rows
|
156
156
|
end
|
157
157
|
|
158
|
+
##
|
159
|
+
# Check if +other+ is equal to self. +other+ is considered equal
|
160
|
+
# if it contains the same headings and rows.
|
161
|
+
|
162
|
+
def == other
|
163
|
+
if other.respond_to?(:headings) && other.respond_to?(:rows)
|
164
|
+
headings == other.headings && rows == other.rows
|
165
|
+
end
|
166
|
+
end
|
158
167
|
end
|
159
|
-
end
|
168
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Terminal
|
2
|
+
class Table
|
3
|
+
module TableHelper
|
4
|
+
##
|
5
|
+
# Generates a Terminal::Table object.
|
6
|
+
#
|
7
|
+
# === Examples:
|
8
|
+
#
|
9
|
+
# puts table(['a', 'b'], [1, 2], [3, 4])
|
10
|
+
#
|
11
|
+
# # OR
|
12
|
+
#
|
13
|
+
# t = table ['a', 'b']
|
14
|
+
# t << [1, 2]
|
15
|
+
# t << [3, 4]
|
16
|
+
# puts t
|
17
|
+
#
|
18
|
+
# # OR
|
19
|
+
#
|
20
|
+
# user_table = table do |t|
|
21
|
+
# t.headings = 'First Name', 'Last Name', 'Email'
|
22
|
+
# t << ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
|
23
|
+
# t << ['Bob', 'Someone', 'bob@vision-media.ca']
|
24
|
+
# t << ['Joe', 'Whatever', 'joe@vision-media.ca']
|
25
|
+
# end
|
26
|
+
# puts user_table
|
27
|
+
#
|
28
|
+
# # OR
|
29
|
+
#
|
30
|
+
# user_table = table do
|
31
|
+
# self.headings = 'First Name', 'Last Name', 'Email'
|
32
|
+
# add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
|
33
|
+
# add_row ['Bob', 'Someone', 'bob@vision-media.ca']
|
34
|
+
# add_row ['Joe', 'Whatever', 'joe@vision-media.ca']
|
35
|
+
# end
|
36
|
+
# puts user_table
|
37
|
+
#
|
38
|
+
# # OR
|
39
|
+
#
|
40
|
+
# rows = []
|
41
|
+
# rows << ['Lines', 100]
|
42
|
+
# rows << ['Comments', 20]
|
43
|
+
# rows << ['Ruby', 70]
|
44
|
+
# rows << ['JavaScript', 30]
|
45
|
+
# puts table(nil, *rows)
|
46
|
+
#
|
47
|
+
|
48
|
+
def table headings = [], *rows, &block
|
49
|
+
Terminal::Table.new :headings => headings.to_a, :rows => rows, &block
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/cell_spec.rb
CHANGED
data/spec/core_ext_spec.rb
CHANGED
data/spec/import_spec.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
|
2
|
+
require "terminal-table/import"
|
1
3
|
|
2
|
-
|
3
|
-
|
4
|
-
describe Kernel do
|
5
|
-
|
4
|
+
describe Object do
|
6
5
|
describe "#table" do
|
7
6
|
it "should allow creation of a terminal table" do
|
8
7
|
table(['foo', 'bar'], ['a', 'b'], [1, 2]).
|
9
8
|
should be_instance_of(Terminal::Table)
|
10
9
|
end
|
11
10
|
end
|
12
|
-
|
13
|
-
end
|
11
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
|
2
|
+
|
3
|
+
module Terminal
|
4
|
+
describe Table::TableHelper do
|
5
|
+
before do
|
6
|
+
@obj = Class.new do
|
7
|
+
include Table::TableHelper
|
8
|
+
end.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#table" do
|
12
|
+
it "should allow creation of a terminal table" do
|
13
|
+
table = @obj.table(['foo', 'bar'], ['a', 'b'], [1, 2])
|
14
|
+
table.should be_instance_of(Terminal::Table)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/table_spec.rb
CHANGED
@@ -1,187 +1,237 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
|
1
2
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
3
|
+
module Terminal
|
4
|
+
describe Table do
|
5
|
+
before :each do
|
6
|
+
@table = Table.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should select columns" do
|
10
|
+
@table << ['foo', 'bar']
|
11
|
+
@table << ['big foo', 'big foo bar']
|
12
|
+
@table.column(1).should == ['bar', 'big foo bar']
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should count columns" do
|
16
|
+
@table << [1, 2, 3]
|
17
|
+
@table.number_of_columns.should == 3
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should iterate columns" do
|
21
|
+
@table << [1, 2, 3]
|
22
|
+
@table << [4, 5, 6]
|
23
|
+
@table.columns.should == [[1, 4], [2, 5], [3, 6]]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should select columns" do
|
27
|
+
@table.headings = ['one', 'two']
|
28
|
+
@table << ['foo', 'bar']
|
29
|
+
@table << ['big foo', 'big foo bar']
|
30
|
+
@table.column(1).should == ['bar', 'big foo bar']
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should select columns when using hashes" do
|
34
|
+
@table.headings = ['one', 'two']
|
35
|
+
@table.rows = [[{ :value => 'a', :align => :left }, 1], ['b', 2], ['c', 3]]
|
36
|
+
@table.column(0).should == [{ :value => 'a', :align => :left }, 'b', 'c']
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should select largest cell in a column" do
|
40
|
+
@table << ['foo', 'bar']
|
41
|
+
@table << ['big foo', 'big foo bar']
|
42
|
+
@table.largest_cell_in_column(1).should == 'big foo bar'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should find column length" do
|
46
|
+
@table << ['foo', 'bar', 'a']
|
47
|
+
@table << ['big foo', 'big foo bar']
|
48
|
+
@table.length_of_column(1).should == 11
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should find column length with headings" do
|
52
|
+
@table.headings = ['one', 'super long heading']
|
53
|
+
@table << ['foo', 'bar', 'a']
|
54
|
+
@table << ['big foo', 'big foo bar']
|
55
|
+
@table.length_of_column(1).should == 18
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should render seperators" do
|
59
|
+
@table.headings = ['Char', 'Num']
|
60
|
+
@table << ['a', 1]
|
61
|
+
@table.seperator.should == '+------+-----+'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should bitch and complain when you have no rows" do
|
65
|
+
lambda { @table.render }.should raise_error(Terminal::Table::Error)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should render properly" do
|
69
|
+
@table.headings = ['Char', 'Num']
|
70
|
+
@table << ['a', 1]
|
71
|
+
@table << ['b', 2]
|
72
|
+
@table << ['c', 3]
|
73
|
+
@table.render.should == <<-EOF.deindent
|
74
|
+
+------+-----+
|
75
|
+
| Char | Num |
|
76
|
+
+------+-----+
|
77
|
+
| a | 1 |
|
78
|
+
| b | 2 |
|
79
|
+
| c | 3 |
|
80
|
+
+------+-----+
|
81
|
+
EOF
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should render properly without headings" do
|
85
|
+
@table << ['a', 1]
|
86
|
+
@table << ['b', 2]
|
87
|
+
@table << ['c', 3]
|
88
|
+
@table.render.should == <<-EOF.deindent
|
89
|
+
+---+---+
|
90
|
+
| a | 1 |
|
91
|
+
| b | 2 |
|
92
|
+
| c | 3 |
|
93
|
+
+---+---+
|
94
|
+
EOF
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should render properly using block syntax" do
|
98
|
+
table = Terminal::Table.new do |t|
|
99
|
+
t << ['a', 1]
|
100
|
+
t << ['b', 2]
|
101
|
+
t << ['c', 3]
|
102
|
+
end
|
103
|
+
table.render.should == <<-EOF.deindent
|
104
|
+
+---+---+
|
105
|
+
| a | 1 |
|
106
|
+
| b | 2 |
|
107
|
+
| c | 3 |
|
108
|
+
+---+---+
|
109
|
+
EOF
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should render properly using instance_eval block syntax" do
|
113
|
+
table = Terminal::Table.new do
|
114
|
+
add_row ['a', 1]
|
115
|
+
add_row ['b', 2]
|
116
|
+
add_row ['c', 3]
|
117
|
+
end
|
118
|
+
table.render.should == <<-EOF.deindent
|
119
|
+
+---+---+
|
120
|
+
| a | 1 |
|
121
|
+
| b | 2 |
|
122
|
+
| c | 3 |
|
123
|
+
+---+---+
|
124
|
+
EOF
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should allows a hash of options for creation" do
|
128
|
+
headings = ['Char', 'Num']
|
129
|
+
rows = [['a', 1], ['b', 2], ['c', 3]]
|
130
|
+
Terminal::Table.new(:rows => rows, :headings => headings).render.should == <<-EOF.deindent
|
131
|
+
+------+-----+
|
132
|
+
| Char | Num |
|
133
|
+
+------+-----+
|
134
|
+
| a | 1 |
|
135
|
+
| b | 2 |
|
136
|
+
| c | 3 |
|
137
|
+
+------+-----+
|
138
|
+
EOF
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should flex for large cells" do
|
142
|
+
@table.headings = ['Just some characters', 'Num']
|
143
|
+
@table.rows = [['a', 1], ['b', 2], ['c', 3]]
|
144
|
+
@table.render.should == <<-EOF.deindent
|
145
|
+
+----------------------+-----+
|
146
|
+
| Just some characters | Num |
|
147
|
+
+----------------------+-----+
|
148
|
+
| a | 1 |
|
149
|
+
| b | 2 |
|
150
|
+
| c | 3 |
|
151
|
+
+----------------------+-----+
|
152
|
+
EOF
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should allow alignment of headings and cells" do
|
156
|
+
@table.headings = ['Characters', ['Nums', :right ]]
|
157
|
+
@table << [['a', :center ], 1]
|
158
|
+
@table << ['b', 222222222222222]
|
159
|
+
@table << ['c', 3]
|
160
|
+
@table.render.should == <<-EOF.deindent
|
161
|
+
+------------+-----------------+
|
162
|
+
| Characters | Nums |
|
163
|
+
+------------+-----------------+
|
164
|
+
| a | 1 |
|
165
|
+
| b | 222222222222222 |
|
166
|
+
| c | 3 |
|
167
|
+
+------------+-----------------+
|
168
|
+
EOF
|
66
169
|
|
67
|
-
|
68
|
-
@table.headings = ['Char', 'Num']
|
69
|
-
@table << ['a', 1]
|
70
|
-
@table << ['b', 2]
|
71
|
-
@table << ['c', 3]
|
72
|
-
@table.render.should == <<-EOF.deindent
|
73
|
-
+------+-----+
|
74
|
-
| Char | Num |
|
75
|
-
+------+-----+
|
76
|
-
| a | 1 |
|
77
|
-
| b | 2 |
|
78
|
-
| c | 3 |
|
79
|
-
+------+-----+
|
80
|
-
EOF
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should render properly without headings" do
|
84
|
-
@table << ['a', 1]
|
85
|
-
@table << ['b', 2]
|
86
|
-
@table << ['c', 3]
|
87
|
-
@table.render.should == <<-EOF.deindent
|
88
|
-
+---+---+
|
89
|
-
| a | 1 |
|
90
|
-
| b | 2 |
|
91
|
-
| c | 3 |
|
92
|
-
+---+---+
|
93
|
-
EOF
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should render properly using block syntax" do
|
97
|
-
table = Terminal::Table.new do |t|
|
98
|
-
t << ['a', 1]
|
99
|
-
t << ['b', 2]
|
100
|
-
t << ['c', 3]
|
101
|
-
end
|
102
|
-
table.render.should == <<-EOF.deindent
|
103
|
-
+---+---+
|
104
|
-
| a | 1 |
|
105
|
-
| b | 2 |
|
106
|
-
| c | 3 |
|
107
|
-
+---+---+
|
108
|
-
EOF
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should render properly using instance_eval block syntax" do
|
112
|
-
table = Terminal::Table.new do
|
113
|
-
add_row ['a', 1]
|
114
|
-
add_row ['b', 2]
|
115
|
-
add_row ['c', 3]
|
116
|
-
end
|
117
|
-
table.render.should == <<-EOF.deindent
|
118
|
-
+---+---+
|
119
|
-
| a | 1 |
|
120
|
-
| b | 2 |
|
121
|
-
| c | 3 |
|
122
|
-
+---+---+
|
123
|
-
EOF
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should allows a hash of options for creation" do
|
127
|
-
headings = ['Char', 'Num']
|
128
|
-
rows = [['a', 1], ['b', 2], ['c', 3]]
|
129
|
-
Terminal::Table.new(:rows => rows, :headings => headings).render.should == <<-EOF.deindent
|
130
|
-
+------+-----+
|
131
|
-
| Char | Num |
|
132
|
-
+------+-----+
|
133
|
-
| a | 1 |
|
134
|
-
| b | 2 |
|
135
|
-
| c | 3 |
|
136
|
-
+------+-----+
|
137
|
-
EOF
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should flex for large cells" do
|
141
|
-
@table.headings = ['Just some characters', 'Num']
|
142
|
-
@table.rows = [['a', 1], ['b', 2], ['c', 3]]
|
143
|
-
@table.render.should == <<-EOF.deindent
|
144
|
-
+----------------------+-----+
|
145
|
-
| Just some characters | Num |
|
146
|
-
+----------------------+-----+
|
147
|
-
| a | 1 |
|
148
|
-
| b | 2 |
|
149
|
-
| c | 3 |
|
150
|
-
+----------------------+-----+
|
151
|
-
EOF
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should allow alignment of headings and cells" do
|
155
|
-
@table.headings = ['Characters', ['Nums', :right ]]
|
156
|
-
@table << [['a', :center ], 1]
|
157
|
-
@table << ['b', 222222222222222]
|
158
|
-
@table << ['c', 3]
|
159
|
-
@table.render.should == <<-EOF.deindent
|
160
|
-
+------------+-----------------+
|
161
|
-
| Characters | Nums |
|
162
|
-
+------------+-----------------+
|
163
|
-
| a | 1 |
|
164
|
-
| b | 222222222222222 |
|
165
|
-
| c | 3 |
|
166
|
-
+------------+-----------------+
|
167
|
-
EOF
|
170
|
+
end
|
168
171
|
|
172
|
+
it "should align columns, but allow specifics to remain" do
|
173
|
+
@table.headings = ['Just some characters', 'Num']
|
174
|
+
@table.rows = [[['a', :left], 1], ['b', 2], ['c', 3]]
|
175
|
+
@table.align_column 0, :center
|
176
|
+
@table.align_column 1, :right
|
177
|
+
@table.render.should == <<-EOF.deindent
|
178
|
+
+----------------------+-----+
|
179
|
+
| Just some characters | Num |
|
180
|
+
+----------------------+-----+
|
181
|
+
| a | 1 |
|
182
|
+
| b | 2 |
|
183
|
+
| c | 3 |
|
184
|
+
+----------------------+-----+
|
185
|
+
EOF
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "#==" do
|
189
|
+
it "should be equal to itself" do
|
190
|
+
t = Table.new
|
191
|
+
t.should == t
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should be equal with two empty tables" do
|
195
|
+
table_one = Table.new
|
196
|
+
table_two = Table.new
|
197
|
+
|
198
|
+
table_one.should == table_two
|
199
|
+
table_two.should == table_one
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should not be equal with different headings" do
|
203
|
+
table_one = Table.new
|
204
|
+
table_two = Table.new
|
205
|
+
|
206
|
+
table_one.headings << "a"
|
207
|
+
|
208
|
+
table_one.should_not == table_two
|
209
|
+
table_two.should_not == table_one
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should not be equal with different rows" do
|
213
|
+
table_one = Table.new
|
214
|
+
table_two = Table.new
|
215
|
+
|
216
|
+
table_one.rows << "a"
|
217
|
+
|
218
|
+
table_one.should_not == table_two
|
219
|
+
table_two.should_not == table_one
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should not be equal if the other object does not respond_to? :headings" do
|
223
|
+
table_one = Table.new
|
224
|
+
table_two = Object.new
|
225
|
+
table_two.stub!(:rows).and_return([])
|
226
|
+
table_one.should_not == table_two
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should not be equal if the other object does not respond_to? :rows" do
|
230
|
+
table_one = Table.new
|
231
|
+
table_two = Object.new
|
232
|
+
table_two.stub!(:rows).and_return([])
|
233
|
+
table_one.should_not == table_two
|
234
|
+
end
|
235
|
+
end
|
169
236
|
end
|
170
|
-
|
171
|
-
it "should align columns, but allow specifics to remain" do
|
172
|
-
@table.headings = ['Just some characters', 'Num']
|
173
|
-
@table.rows = [[['a', :left], 1], ['b', 2], ['c', 3]]
|
174
|
-
@table.align_column 0, :center
|
175
|
-
@table.align_column 1, :right
|
176
|
-
@table.render.should == <<-EOF.deindent
|
177
|
-
+----------------------+-----+
|
178
|
-
| Just some characters | Num |
|
179
|
-
+----------------------+-----+
|
180
|
-
| a | 1 |
|
181
|
-
| b | 2 |
|
182
|
-
| c | 3 |
|
183
|
-
+----------------------+-----+
|
184
|
-
EOF
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
237
|
+
end
|
data/terminal-table.gemspec
CHANGED
@@ -2,26 +2,25 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{terminal-table}
|
5
|
-
s.version = "1.0
|
5
|
+
s.version = "1.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["TJ Holowaychuk"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-13}
|
10
10
|
s.description = %q{Simple,}
|
11
11
|
s.email = %q{tj@vision-media.ca}
|
12
|
-
s.extra_rdoc_files = ["lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/version.rb", "lib/terminal-table.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
13
|
-
s.files = ["examples/examples.rb", "History.rdoc", "lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/version.rb", "lib/terminal-table.rb", "Manifest", "Rakefile", "README.rdoc", "spec/cell_spec.rb", "spec/core_ext_spec.rb", "spec/import_spec.rb", "spec/spec_helper.rb", "spec/table_spec.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "terminal-table.gemspec", "Todo.rdoc"]
|
14
|
-
s.has_rdoc = true
|
12
|
+
s.extra_rdoc_files = ["lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "lib/terminal-table.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
13
|
+
s.files = ["examples/examples.rb", "History.rdoc", "lib/terminal-table/cell.rb", "lib/terminal-table/core_ext.rb", "lib/terminal-table/heading.rb", "lib/terminal-table/import.rb", "lib/terminal-table/table.rb", "lib/terminal-table/table_helper.rb", "lib/terminal-table/version.rb", "lib/terminal-table.rb", "Manifest", "Rakefile", "README.rdoc", "spec/cell_spec.rb", "spec/core_ext_spec.rb", "spec/import_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/table_helper_spec.rb", "spec/table_spec.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "terminal-table.gemspec", "Todo.rdoc"]
|
15
14
|
s.homepage = %q{http://github.com/visionmedia/terminal-table}
|
16
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Terminal-table", "--main", "README.rdoc"]
|
17
16
|
s.require_paths = ["lib"]
|
18
17
|
s.rubyforge_project = %q{terminal-table}
|
19
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.4}
|
20
19
|
s.summary = %q{Simple,}
|
21
20
|
|
22
21
|
if s.respond_to? :specification_version then
|
23
22
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
-
s.specification_version =
|
23
|
+
s.specification_version = 3
|
25
24
|
|
26
25
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
26
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-terminal-table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,6 +25,7 @@ extra_rdoc_files:
|
|
25
25
|
- lib/terminal-table/heading.rb
|
26
26
|
- lib/terminal-table/import.rb
|
27
27
|
- lib/terminal-table/table.rb
|
28
|
+
- lib/terminal-table/table_helper.rb
|
28
29
|
- lib/terminal-table/version.rb
|
29
30
|
- lib/terminal-table.rb
|
30
31
|
- README.rdoc
|
@@ -39,6 +40,7 @@ files:
|
|
39
40
|
- lib/terminal-table/heading.rb
|
40
41
|
- lib/terminal-table/import.rb
|
41
42
|
- lib/terminal-table/table.rb
|
43
|
+
- lib/terminal-table/table_helper.rb
|
42
44
|
- lib/terminal-table/version.rb
|
43
45
|
- lib/terminal-table.rb
|
44
46
|
- Manifest
|
@@ -47,14 +49,16 @@ files:
|
|
47
49
|
- spec/cell_spec.rb
|
48
50
|
- spec/core_ext_spec.rb
|
49
51
|
- spec/import_spec.rb
|
52
|
+
- spec/spec.opts
|
50
53
|
- spec/spec_helper.rb
|
54
|
+
- spec/table_helper_spec.rb
|
51
55
|
- spec/table_spec.rb
|
52
56
|
- tasks/docs.rake
|
53
57
|
- tasks/gemspec.rake
|
54
58
|
- tasks/spec.rake
|
55
59
|
- terminal-table.gemspec
|
56
60
|
- Todo.rdoc
|
57
|
-
has_rdoc:
|
61
|
+
has_rdoc: false
|
58
62
|
homepage: http://github.com/visionmedia/terminal-table
|
59
63
|
post_install_message:
|
60
64
|
rdoc_options:
|
@@ -83,7 +87,7 @@ requirements: []
|
|
83
87
|
rubyforge_project: terminal-table
|
84
88
|
rubygems_version: 1.2.0
|
85
89
|
signing_key:
|
86
|
-
specification_version:
|
90
|
+
specification_version: 3
|
87
91
|
summary: Simple,
|
88
92
|
test_files: []
|
89
93
|
|