5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/cranium/extract/strategy/base.rb', line 5
def execute()
target_file_name = "#{extract_definition.name}.csv"
target_file_path = File.join Cranium.configuration.upload_path, target_file_name
raise StandardError, %Q(Extract halted: a file named "#{target_file_name}" already exists) if File.exists? target_file_path
CSV.open target_file_path, "w:UTF-8" do |target_file|
dataset = Cranium::Database[.from].fetch .query
target_file << (.columns || dataset.columns)
write_dataset_into_file target_file, dataset,
end
end
|