Sha256: 0cf690995a9127a6ee5c18ae10bc9984b6e7ba36d9ba90b8099aa69ddecee1c6

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

require 'wlog/commands/commandable'
require 'wlog/domain/log_entry'
require 'wlog/domain/helpers'

module Wlog
# Create a Csv report with this command
# @author Simon Symeonidis
class MakeCsv < Commandable

  # TODO refactor me. Because I feel like a horrible piece of code.
  def execute
    str = ""
    LogEntry.all.group_by{|el| el.created_at.strftime("%Y-%m-%d")}.each_pair do |key,value|
      str.concat("#{value.first.created_at.strftime("%A")} #{key}\n")
      value.each do |entry|
        str.concat(",\"#{Helpers.break_string(entry.description,80)}\"#{$/}")
      end
      str.concat($/)
    end
    @ret = str
  end

  attr_accessor :ret
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlog-1.2.2 lib/wlog/commands/make_csv.rb