Class: StarTrack::TimeTracker::Freckle
- Inherits:
-
Object
- Object
- StarTrack::TimeTracker::Freckle
- Defined in:
- lib/star_track/time_tracker/freckle.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize ⇒ Freckle
constructor
A new instance of Freckle.
- #track(tasks) ⇒ Object
Constructor Details
#initialize ⇒ Freckle
Returns a new instance of Freckle.
8 9 10 11 12 13 14 15 |
# File 'lib/star_track/time_tracker/freckle.rb', line 8 def initialize config = YAML.load_file("#{ENV['HOME']}/.star_track.yaml")["freckle"] @token = config["token"] @project_id = config["project_id"].to_i @client = ::Freckle::Client.new(token: @token) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/star_track/time_tracker/freckle.rb', line 6 def client @client end |
Instance Method Details
#track(tasks) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/star_track/time_tracker/freckle.rb', line 17 def track(tasks) params = { description: tasks.join(" - ").gsub("#", " "), project_id: @project_id, minutes: billable_time, date: Date.today.to_s, } begin client.create_entry(params) rescue => error ErrorHandler.raise(error.) end end |