Commit d50c4078 authored by Micaël Bergeron's avatar Micaël Bergeron

apply feedback from review

parent f71fbe7a
...@@ -64,8 +64,7 @@ module Pseudonymizer ...@@ -64,8 +64,7 @@ module Pseudonymizer
private private
def output_filename(basename = nil, ext = "csv.gz") def output_filename(basename = nil, ext = "csv.gz")
file_timestamp = "#{basename}.#{ext}" File.join(output_dir, "#{basename}.#{ext}")
File.join(output_dir, file_timestamp)
end end
def schema_to_yml def schema_to_yml
...@@ -147,7 +146,7 @@ module Pseudonymizer ...@@ -147,7 +146,7 @@ module Pseudonymizer
end end
def write_to_csv_file(table, contents) def write_to_csv_file(table, contents)
file_path = output_filename(table, "csv.gz") file_path = output_filename(table)
Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}." Rails.logger.info "#{self.class.name} writing #{table} to #{file_path}."
Zlib::GzipWriter.open(file_path) do |io| Zlib::GzipWriter.open(file_path) do |io|
......
...@@ -13,7 +13,7 @@ module Pseudonymizer ...@@ -13,7 +13,7 @@ module Pseudonymizer
end end
def upload_dir def upload_dir
File.join(start_at.iso8601) start_at.iso8601
end end
end end
end end
...@@ -34,7 +34,10 @@ module Pseudonymizer ...@@ -34,7 +34,10 @@ module Pseudonymizer
return unless File.exist?(@output_dir) return unless File.exist?(@output_dir)
progress_output.print "Deleting tmp directory #{@output_dir} ... " progress_output.print "Deleting tmp directory #{@output_dir} ... "
progress_output.puts FileUtils.rm_rf(@output_dir) ? "done".color(:green) : "failed".color(:red) FileUtils.rm_rf(@output_dir)
progress_output.puts "done".color(:green)
rescue
progress_output.puts "failed".color(:red)
end end
private private
......
...@@ -23,6 +23,10 @@ describe Pseudonymizer::Uploader do ...@@ -23,6 +23,10 @@ describe Pseudonymizer::Uploader do
mock_file("file_list.json") mock_file("file_list.json")
end end
after do
FileUtils.rm_rf(base_dir)
end
describe "#upload" do describe "#upload" do
it "upload all file in the directory" do it "upload all file in the directory" do
subject.upload subject.upload
...@@ -38,8 +42,4 @@ describe Pseudonymizer::Uploader do ...@@ -38,8 +42,4 @@ describe Pseudonymizer::Uploader do
expect(Dir[File.join(base_dir, "*")].length).to eq(0) expect(Dir[File.join(base_dir, "*")].length).to eq(0)
end end
end end
after do
FileUtils.rm_rf(base_dir)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment