class Focus::LogFocusTime

Public Instance Methods

perform() click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 4
def perform
  update_log
end

Private Instance Methods

entry(epoch, min, target) click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 20
def entry(epoch, min, target)
  line % [epoch, min, target]
end
focus_target() click to toggle source
Calls superclass method Focus::Action#focus_target
# File lib/focus/actions/log_focus_time.rb, line 32
def focus_target
  jira_ticket || super
end
jira_ticket() click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 36
def jira_ticket
  @ticket ||= Utils::ParseJiraTicketFromGitBranch.call.jira_ticket
end
line() click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 24
def line
  "%-20s %-20s %s"
end
title() click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 28
def title
  entry "EPOCH", "FOCUS_MINUTES", "TARGET"
end
update_log() click to toggle source
# File lib/focus/actions/log_focus_time.rb, line 10
def update_log
  file = File.expand_path config.focus_history_file
  new_file = File.exist?(file)

  File.open(file, "a") do |fo|
    fo.puts title unless new_file
    fo.puts entry(Time.now.to_i, focus_minutes, focus_target)
  end
end