Sha256: 8d84bc41a2c9664143d1628f4d267fcaac4750a8d96e9506c00fd13b5fc446c1
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
module Luxafor module Toggl class Client def initialize(toggl: Luxafor::Toggl.toggl_client, luxafor: Luxafor::Toggl.luxafor_client, state: Luxafor::Toggl::state_file) @toggl = toggl @luxafor = luxafor @state_file = state end def execute! return false unless current_state.sufficiently_different_from?(stored_state) luxafor.on(current_state.colour) current_state.store!(state_file) true end private attr_reader :toggl, :luxafor, :state_file def latest_task start = DateTime.now - 1 @_latest_task = toggl.get_time_entries(start_date: start).last end def current_state @_current_state ||= State.new_from_task(latest_task) end def stored_state return State.new unless File.exist?(state_file) file_contents = File.new(state_file).read.to_s state_json = Oj.load(file_contents) State.new(state: state_json['state'], as_of: state_json['as_of']) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
luxafor-toggl-1.0.2 | lib/luxafor/toggl/client.rb |
luxafor-toggl-1.0.1 | lib/luxafor/toggl/client.rb |
luxafor-toggl-1.0.0 | lib/luxafor/toggl/client.rb |