diff --git a/lib/squib/import/data_frame.rb b/lib/squib/import/data_frame.rb index cb34048..30ec576 100644 --- a/lib/squib/import/data_frame.rb +++ b/lib/squib/import/data_frame.rb @@ -86,13 +86,13 @@ module Squib end def wrap_n_pad(str, max_col) - str.to_s. - concat(' '). # handle nil & empty strings - scan(/.{1,34}/). - map { |s| (' ' * max_col) + " | " + s.ljust(34) }. - join(" |\n"). - lstrip. # initially no whitespace next to key - concat(" |\n") + new_str = str.to_s + ' ' # handle nil & empty strings + new_str = new_str. + scan(/.{1,34}/). # break down + map { |s| (' ' * max_col) + " | " + s.ljust(34) }. + join(" |\n"). + lstrip # initially no whitespace next to key + return new_str + " |\n" end def def_column(col) diff --git a/spec/import/data_frame_spec.rb b/spec/import/data_frame_spec.rb index 6f7bec5..22d72d8 100644 --- a/spec/import/data_frame_spec.rb +++ b/spec/import/data_frame_spec.rb @@ -246,6 +246,14 @@ Fun with UTF8! | 👊 | ╰------------------------------------╯ EOS 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