class Herodot::Parser
Constants
- NO_SUCH_FILE
Public Class Methods
from_to_from_range(range)
click to toggle source
# File lib/herodot/parser.rb, line 18 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
parse(range, config)
click to toggle source
# File lib/herodot/parser.rb, line 9 def parse(range, config) worklog = Worklog.new(config) from, to = from_to_from_range(range) parse_into_worklog(worklog, config.worklog_file, from, to) worklog rescue Errno::ENOENT abort NO_SUCH_FILE end
Private Class Methods
parse_into_worklog(worklog, file, from, to)
click to toggle source
# File lib/herodot/parser.rb, line 25 def parse_into_worklog(worklog, file, from, to) CSV.foreach(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 end