lib/gitwakatime/actions.rb in gitwakatime-0.0.1 vs lib/gitwakatime/actions.rb in gitwakatime-0.0.2
- old
+ new
@@ -1,9 +1,11 @@
module GitWakaTime
# Extract Duration Data from Actions for the WAKATIME API
class Actions
+ attr_accessor :actions
def initialize(args)
+ return @actions = args[:actions] if args[:actions]
fail if args[:project].nil?
@project = args[:project]
@args = args
@session = Wakatime::Session.new(api_key: GitWakaTime.config.api_key)
@client = Wakatime::Client.new(@session)
@@ -13,15 +15,19 @@
def load_actions
Log.new "querying WakaTime actions for #{@project}"
time = Benchmark.realtime do
@actions = @client.actions(@args)
# remove returned actions that do not have the project we want
- @actions.keep_if { |a| a['project'] == @project }
+ @actions = @actions.keep_if do |a|
+ a['project'] == @project
+ end
+
end
Log.new "API took #{time}s"
+ @actions
end
- def actions_to_durations(project = nil, timeout = 15)
+ def actions_to_durations(_project = nil, timeout = 15)
durations = []
current = []
@actions.each do | action |
# the first action just sets state and does nothing
unless current.empty?