Class: CSVTasks

Inherits:
Thor
  • Object
show all
Defined in:
lib/tasks/thorfile.rb

Instance Method Summary collapse

Instance Method Details

#exportObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tasks/thorfile.rb', line 7

def export
  require 'config/environment'

  detect_and_set_project_scope

  exporter = Dradis::Plugins::CSVExport::Exporter.new(task_options)
  csv = exporter.export()

  date = DateTime.now.strftime("%Y-%m-%d")
  base_filename = "dradis-report_#{date}.csv"

  filename = NamingService.name_file(
    original_filename: base_filename,
    pathname: Rails.root
  )

  File.open(filename, 'w') { |f| f.write csv }

  logger.info "File written to ./#{ filename }"
end