Sha256: 37035121188ab5b74d98efeedbbeeb9288211ecbae5813d044254d376699ca02

Contents?: true

Size: 661 Bytes

Versions: 5

Compression:

Stored size: 661 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

5 entries across 5 versions & 1 rubygems

Version Path
wlog-1.2.1 lib/wlog/commands/make_csv.rb
wlog-1.2.0 lib/wlog/commands/make_csv.rb
wlog-1.1.7 lib/wlog/commands/make_csv.rb
wlog-1.1.6 lib/wlog/commands/make_csv.rb
wlog-1.1.5 lib/wlog/commands/make_csv.rb