class Doing::CSVExport

CSV Export

Public Class Methods

format_note(note) click to toggle source
# File lib/doing/plugins/export/csv_export.rb, line 36
def self.format_note(note)
  out = ''
  if note
    arr = note.map(&:strip).delete_if { |e| e =~ /^\s*$/ }
    out = arr.join("\n") unless arr.empty?
  end

  out
end
render(wwid, items, variables: {}) click to toggle source
# File lib/doing/plugins/export/csv_export.rb, line 20
def self.render(wwid, items, variables: {})
  return if items.nil?

  opt = variables[:options]

  output = [CSV.generate_line(%w[start end title note timer section])]
  items.each do |i|
    note = format_note(i.note)
    end_date = i.end_date
    interval = end_date && opt[:times] ? wwid.get_interval(i, formatted: false) : 0
    output.push(CSV.generate_line([i.date, end_date, i.title, note, interval, i.section]))
  end
  Doing.logger.debug('CSV Export:', "#{items.count} items output to CSV")
  output.join('')
end
settings() click to toggle source
# File lib/doing/plugins/export/csv_export.rb, line 14
def self.settings
  {
    trigger: 'csv'
  }
end