terminal-table 1.4.0 → 1.4.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/History.rdoc +4 -0
- data/lib/terminal-table/table.rb +2 -1
- data/lib/terminal-table/version.rb +1 -1
- data/spec/table_spec.rb +20 -0
- data/terminal-table.gemspec +1 -1
- metadata +1 -1
data/History.rdoc
CHANGED
data/lib/terminal-table/table.rb
CHANGED
@@ -179,8 +179,9 @@ module Terminal
|
|
179
179
|
# Align column _n_ to the given _alignment_ of :center, :left, or :right.
|
180
180
|
|
181
181
|
def align_column n, alignment
|
182
|
+
r = rows
|
182
183
|
column(n).each_with_index do |col, i|
|
183
|
-
|
184
|
+
r[i][n] = { :value => col, :alignment => alignment } unless Hash === col
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
data/spec/table_spec.rb
CHANGED
@@ -121,6 +121,26 @@ module Terminal
|
|
121
121
|
EOF
|
122
122
|
end
|
123
123
|
|
124
|
+
it "should align columns with separators" do
|
125
|
+
@table.headings = ['Char', 'Num']
|
126
|
+
@table << ['a', 1]
|
127
|
+
@table << ['b', 2]
|
128
|
+
@table.add_separator
|
129
|
+
@table << ['c', 3]
|
130
|
+
@table.align_column 1, :right
|
131
|
+
@table.render.should == <<-EOF.deindent
|
132
|
+
+------+-----+
|
133
|
+
| Char | Num |
|
134
|
+
+------+-----+
|
135
|
+
| a | 1 |
|
136
|
+
| b | 2 |
|
137
|
+
+------+-----+
|
138
|
+
| c | 3 |
|
139
|
+
+------+-----+
|
140
|
+
EOF
|
141
|
+
end
|
142
|
+
|
143
|
+
|
124
144
|
it "should render properly using block syntax" do
|
125
145
|
table = Terminal::Table.new do |t|
|
126
146
|
t << ['a', 1]
|
data/terminal-table.gemspec
CHANGED