Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove to_csv functions #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lib/saxlsx/sheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,5 @@ def rows
@rows ||= RowsCollection.new(@index, @file_system, @workbook)
end

def to_csv(path)
FileUtils.mkpath path unless Dir.exists? path
File.open("#{path}/#{name}.csv", 'w') do |f|
rows.each do |row|
f.puts row.map{|c| "\"#{c}\""}.join(',')
end
end
end

end
end
4 changes: 0 additions & 4 deletions lib/saxlsx/workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ def base_date
@base_date ||= date1904 ? DATE_SYSTEM_1904 : DATE_SYSTEM_1900
end

def to_csv(path)
sheets.each { |s| s.to_csv path }
end

end
end
20 changes: 0 additions & 20 deletions spec/sheet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,6 @@
end
end

it 'Export to CSV' do
Workbook.open filename do |w|
csv_file = "#{tmp_path}/#{w.sheets[0].name}.csv"

File.should_not be_exists csv_file

w.sheets[0].to_csv tmp_path

csv = File.open(csv_file, 'r') { |f| f.readlines }
# TODO: newer rubies use lowercase "e" in scientific numbers
# csv[0].should eq %{"LevenshteinDistance","3.14","3","2013-12-13T08:00:58+00:00","1970-01-01T00:00:00+00:00","0.34028236692093801E39","2015-02-13T12:40:05+00:00"\n}
csv[1].should eq %{"Case sensitive","false","3.0","1970-01-01T01:00:00+00:00"\n}
csv[2].should eq "\"Fields\",\"Type\",\"URL Mining\"\n"
csv[3].should eq "\"autor\",\"text\",\"false\"\n"
csv[4].should eq "\"texto\",\"text\",\"false\"\n"
csv[5].should eq "\"url\",\"text\",\"false\"\n"
csv[6].should eq "\"comentario\",\"text\",\"false\"\n"
end
end

it 'Handle missing fonts and dimension tags' do
filename = "#{File.dirname(__FILE__)}/data/SpecSloppy.xlsx"

Expand Down
7 changes: 0 additions & 7 deletions spec/workbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,4 @@
w.shared_strings.should include 'TST_ModMan_Insulto_SU_Normal'
end
end

it 'Export to CSV' do
Workbook.open filename do |w|
w.sheets.each { |s| s.should_receive(:to_csv).with(Dir.pwd) }
w.to_csv Dir.pwd
end
end
end