Sha256: cb4b47d4646c942cb34997a7ae1f76e6be177f5c3c68e9996936830e456e1ad3

Contents?: true

Size: 605 Bytes

Versions: 5

Compression:

Stored size: 605 Bytes

Contents

require 'csv'
require 'pry'

class Herodot::Parser
  class << self
    def parse(range, config)
      worklog = Herodot::Worklog.new(config)
      from, to = from_to_from_range(range)
      CSV.foreach(config.worklog_file, col_sep: ';') do |row|
        next if row[2] == 'HEAD'
        time = Time.parse(row[0])
        worklog.add_entry(time, row[1], row[2]) if time >= from && time <= to
      end
      worklog
    end

    def from_to_from_range(range)
      return [range, Time.now] unless range.respond_to?(:begin) && range.respond_to?(:end)
      [range.begin, range.end + 3600]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
herodot-0.1.5 lib/herodot/parser.rb
herodot-0.1.4 lib/herodot/parser.rb
herodot-0.1.3 lib/herodot/parser.rb
herodot-0.1.2 lib/herodot/parser.rb
herodot-0.1.0 lib/herodot/parser.rb