data: fix wrap_n_pad bug
This doesn't make modifications to the original string. If only Ruby used their own convention and did str#concat! instead of str#concat Fixes #191 [skip ci]dev
parent
db0bf38ec0
commit
3ce5d8b4eb
|
|
@ -86,13 +86,13 @@ module Squib
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrap_n_pad(str, max_col)
|
def wrap_n_pad(str, max_col)
|
||||||
str.to_s.
|
new_str = str.to_s + ' ' # handle nil & empty strings
|
||||||
concat(' '). # handle nil & empty strings
|
new_str = new_str.
|
||||||
scan(/.{1,34}/).
|
scan(/.{1,34}/). # break down
|
||||||
map { |s| (' ' * max_col) + " | " + s.ljust(34) }.
|
map { |s| (' ' * max_col) + " | " + s.ljust(34) }.
|
||||||
join(" |\n").
|
join(" |\n").
|
||||||
lstrip. # initially no whitespace next to key
|
lstrip # initially no whitespace next to key
|
||||||
concat(" |\n")
|
return new_str + " |\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def def_column(col)
|
def def_column(col)
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,14 @@ Fun with UTF8! | 👊 |
|
||||||
╰------------------------------------╯
|
╰------------------------------------╯
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not pad the data' do
|
||||||
|
data = Squib::DataFrame.new
|
||||||
|
data['a'] = ['b', 'c']
|
||||||
|
expect(data.to_pretty_text.size).to be > 0
|
||||||
|
expect(data.columns).to eq ['a']
|
||||||
|
expect(data['a']).to eq ['b', 'c']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue