timetrap 1.7.8 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
 - data/lib/timetrap/timer.rb +8 -1
 - data/spec/timetrap_spec.rb +10 -1
 - data/timetrap.gemspec +1 -1
 - metadata +3 -3
 
    
        data/VERSION.yml
    CHANGED
    
    
    
        data/lib/timetrap/timer.rb
    CHANGED
    
    | 
         @@ -14,7 +14,7 @@ module Timetrap 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    time
         
     | 
| 
       15 
15 
     | 
    
         
             
                  when String
         
     | 
| 
       16 
16 
     | 
    
         
             
                    chronic = begin
         
     | 
| 
       17 
     | 
    
         
            -
                       
     | 
| 
      
 17 
     | 
    
         
            +
                      time_closest_to_now_with_chronic(time, now)
         
     | 
| 
       18 
18 
     | 
    
         
             
                    rescue => e
         
     | 
| 
       19 
19 
     | 
    
         
             
                      warn "#{e.class} in Chronic gem parsing time.  Falling back to Time.parse"
         
     | 
| 
       20 
20 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -29,6 +29,13 @@ module Timetrap 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  end
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
                def time_closest_to_now_with_chronic(time, now)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  [
         
     | 
| 
      
 34 
     | 
    
         
            +
                    Chronic.parse(time, :context => :past, :now => now),
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Chronic.parse(time, :context => :future, :now => now)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  ].sort_by{|a| (a.to_i - now.to_i).abs }.first
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       32 
39 
     | 
    
         
             
                # Time.parse is optimistic and will parse things like '=18' into midnight
         
     | 
| 
       33 
40 
     | 
    
         
             
                # on 18th of this month.
         
     | 
| 
       34 
41 
     | 
    
         
             
                # It will also turn 'total garbage' into Time.now
         
     | 
    
        data/spec/timetrap_spec.rb
    CHANGED
    
    | 
         @@ -1014,7 +1014,7 @@ END:VCALENDAR 
     | 
|
| 
       1014 
1014 
     | 
    
         
             
                    end
         
     | 
| 
       1015 
1015 
     | 
    
         
             
                  end
         
     | 
| 
       1016 
1016 
     | 
    
         | 
| 
       1017 
     | 
    
         
            -
                  describe " 
     | 
| 
      
 1017 
     | 
    
         
            +
                  describe "with times specfied like 12:12:12" do
         
     | 
| 
       1018 
1018 
     | 
    
         
             
                    it "should assume a <24 hour duration" do
         
     | 
| 
       1019 
1019 
     | 
    
         
             
                      @entry.start= Time.at(Time.now - 3600) # 1.hour.ago
         
     | 
| 
       1020 
1020 
     | 
    
         
             
                      @entry.end = Time.at(Time.now - 300).strftime("%H:%M:%S") # ambiguous 5.minutes.ago
         
     | 
| 
         @@ -1023,6 +1023,15 @@ END:VCALENDAR 
     | 
|
| 
       1023 
1023 
     | 
    
         
             
                      # within this test.
         
     | 
| 
       1024 
1024 
     | 
    
         
             
                      (3299..3301).should === @entry.duration
         
     | 
| 
       1025 
1025 
     | 
    
         
             
                    end
         
     | 
| 
      
 1026 
     | 
    
         
            +
             
     | 
| 
      
 1027 
     | 
    
         
            +
                    it "should assume a start time near the current time" do
         
     | 
| 
      
 1028 
     | 
    
         
            +
                      time = Time.at(Time.now - 300)
         
     | 
| 
      
 1029 
     | 
    
         
            +
                      @entry.start= time.strftime("%H:%M:%S") # ambiguous 5.minutes.ago
         
     | 
| 
      
 1030 
     | 
    
         
            +
             
     | 
| 
      
 1031 
     | 
    
         
            +
                      # should be about 55 minutes duration.  Allow for second rollover
         
     | 
| 
      
 1032 
     | 
    
         
            +
                      # within this test.
         
     | 
| 
      
 1033 
     | 
    
         
            +
                      @entry.start.to_i.should == time.to_i
         
     | 
| 
      
 1034 
     | 
    
         
            +
                    end
         
     | 
| 
       1026 
1035 
     | 
    
         
             
                  end
         
     | 
| 
       1027 
1036 
     | 
    
         
             
                end
         
     | 
| 
       1028 
1037 
     | 
    
         | 
    
        data/timetrap.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: timetrap
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 25
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 7
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1.7. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 9
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.7.9
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Sam Goldstein
         
     |