tempo-cli 0.2.2 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0e749497d74a2c5e925fd047c19040e672ec24
4
- data.tar.gz: a4923005458055bcf4439e939a8f278d65459296
3
+ metadata.gz: ea6cc8f7f2251d38ac0f1302e37a0f2cf93fa3d4
4
+ data.tar.gz: 2e8cce29f69bbc7468034c872084ff4e0952e5e2
5
5
  SHA512:
6
- metadata.gz: 2524f53d37306e60ced9e55015ac57c1e962540113170b190abb7937a7a2eb16dd0ef7d5825d9ac574895649df0b0f49d3fe146e64a75c9800c51dc42a30aaa3
7
- data.tar.gz: 66e4108bba0f37681e7a1f4e701f5e3a7de62705770351f9e5954e998351a73f85328e4e20bdf06ba392905b45c60f4b638051a9fe5aa0c417629f1509016b78
6
+ metadata.gz: 516fe4c8216081c83a2ce43436cce83827aecccba3823956e236ed7f1bc0e86f67cde7c63537dab655ae60e4dc7610a1e5649858474bb118926ded4aed3ee5e6
7
+ data.tar.gz: 8c0b3784dfd824eb13343662c061eaf6f4f7ec308458a2f706127ee5388d00d1b20983e5cc0df0e13ce0c170204b70720cefc8164135d948caf8bd85ffedfffe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tempo-cli (0.2.1)
4
+ tempo-cli (0.2.2)
5
5
  chronic (~> 0.10)
6
6
  gli (~> 2.10)
7
7
 
@@ -7,7 +7,9 @@ module Tempo
7
7
  # This error is raised when an existing time period conflicts with a time or time period
8
8
  # All parameters are optional, and will be build into the error string if supplied
9
9
  #
10
- # Expected parameters are Time objects, but nil or strings will be handled as well
10
+ # Expected parameters are Time objects, but nil or strings will be handled as well.
11
+ #
12
+ # If start time is a Time object, the date will be added to the message.
11
13
  #
12
14
  # examples:
13
15
  #
@@ -17,10 +19,11 @@ module Tempo
17
19
  # (<8:00>, <10:00>, <9:00>, <9:30>) => "time <9:00 - 9:30> conflicts with existing record: 8:00 - 10:00"
18
20
  # (<8:00>, :running) => "time conflicts with existing record: 8:00 - running"
19
21
  #
22
+ # (<2015-09-23 11:50:00 -0400>,...) "... on Sept 23, 2015"
23
+
20
24
  class TimeConflictError < ArgumentError
21
25
 
22
26
  def initialize(start_time=nil, end_time=nil, target_start_time=nil, target_end_time=nil)
23
-
24
27
  @end_time = (end_time.kind_of? Time) ? end_time.strftime('%H:%M') : end_time.to_s
25
28
  @end_time = " - #{@end_time}" if !@end_time.empty?
26
29
  @existing = (start_time.kind_of? Time) ? ": #{start_time.strftime('%H:%M')}#{@end_time}" : start_time.to_s
@@ -29,7 +32,38 @@ module Tempo
29
32
  @target_end_time = " - #{@target_end_time}" if !@target_end_time.empty?
30
33
  @target = (target_start_time.kind_of? Time) ? "<#{target_start_time.strftime('%H:%M')}#{@target_end_time}> " : ""
31
34
 
32
- @message = "time #{@target}conflicts with existing record#{@existing}"
35
+ @on_day = (start_time.kind_of? Time) ? " on #{start_time.strftime('%b %d, %Y')}" : ""
36
+ @message = "time #{@target}conflicts with existing record#{@existing}#{@on_day}"
37
+ end
38
+
39
+ def to_s
40
+ @message
41
+ end
42
+ end
43
+
44
+ # Raise when the end time is less than the start time
45
+ # start_time and end_time should be Time objects
46
+ class EndTimeError < ArgumentError
47
+
48
+ def initialize(start_time, end_time)
49
+ @start_time = (start_time.kind_of? Time) ? start_time.strftime('%H:%M') : start_time.to_s
50
+ @end_time = (end_time.kind_of? Time) ? end_time.strftime('%H:%M') : end_time.to_s
51
+ @on_day = (start_time.kind_of? Time) ? "on #{start_time.strftime('%b %d, %Y')}" : ""
52
+
53
+ @message = "End time #{@end_time} must be greater than start time #{@start_time} #{@on_day}"
54
+ end
55
+
56
+ def to_s
57
+ @message
58
+ end
59
+ end
60
+
61
+ class DifferentDaysError < ArgumentError
62
+
63
+ def initialize(start_time, end_time)
64
+ @start_time = (start_time.kind_of? Time) ? start_time.strftime('%H:%M on %b %d, %Y') : start_time.to_s
65
+ @end_time = (end_time.kind_of? Time) ? end_time.strftime('%H:%M on %b %d, %Y') : end_time.to_s
66
+ @message = "End time must be on the same day as start time: #{start_time} : #{end_time}"
33
67
  end
34
68
 
35
69
  def to_s
@@ -285,11 +285,12 @@ module Tempo
285
285
  # TODO: a better check for :running conditions
286
286
  return true if end_time == :running
287
287
 
288
- raise ArgumentError, "End time must be greater than start time" if end_time < start_time
288
+ raise Tempo::EndTimeError.new(start_time, end_time) if end_time < start_time
289
289
 
290
290
  dsym = self.class.date_symbol end_time
291
291
  start_dsym = self.class.date_symbol start_time
292
- raise ArgumentError, "End time must be on the same day as start time: #{start_time} : #{end_time}" if dsym != start_dsym
292
+
293
+ raise Tempo::DifferentDaysError.new(start_time, end_time) if dsym != start_dsym
293
294
 
294
295
  # this is necessary if this is the first record
295
296
  # for the day and self is not yet added to index
data/lib/tempo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tempo
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tempo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gabel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake