diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | lib/hcl/app.rb | 2 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 10 | ||||
| -rw-r--r-- | lib/hcl/day_entry.rb | 4 | 
4 files changed, 18 insertions, 0 deletions
| @@ -3,3 +3,5 @@ pkg  tags  doc  .yardoc +.rvmrc +.rvmrc.* diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index b208d11..b49c6c5 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -5,6 +5,7 @@ require 'net/http'  require 'net/https'  ## gem dependencies +require 'rubygems'  require 'chronic'  require 'trollop'  require 'highline/import' @@ -99,6 +100,7 @@ Commands:      hcl unset <key>      hcl start <task> [msg]      hcl stop [msg] +    hcl resume      hcl note <msg>  Examples: diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index 9e59a90..6d2619b 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -87,6 +87,16 @@ module HCl        puts "\t#{as_hours total_hours}\ttotal (as of #{current_time})"      end +    def resume +      entry = DayEntry.last +      if entry +        puts "Resumed #{entry} (at #{current_time})" +        entry.toggle +      else +        puts "No timers found" +      end +    end +        private      def current_time        Time.now.strftime('%I:%M %p').downcase diff --git a/lib/hcl/day_entry.rb b/lib/hcl/day_entry.rb index b77d597..d4fe69d 100644 --- a/lib/hcl/day_entry.rb +++ b/lib/hcl/day_entry.rb @@ -42,6 +42,10 @@ module HCl      def self.with_timer        all.detect {|t| t.running? }      end +     +    def self.last +      all.sort {|a,b| a.updated_at<=>b.updated_at}[-1] +    end      def running?        !@data[:timer_started_at].nil? && !@data[:timer_started_at].empty? | 
