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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tempo/exceptions.rb +37 -3
- data/lib/tempo/models/time_record.rb +3 -2
- data/lib/tempo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6cc8f7f2251d38ac0f1302e37a0f2cf93fa3d4
|
4
|
+
data.tar.gz: 2e8cce29f69bbc7468034c872084ff4e0952e5e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516fe4c8216081c83a2ce43436cce83827aecccba3823956e236ed7f1bc0e86f67cde7c63537dab655ae60e4dc7610a1e5649858474bb118926ded4aed3ee5e6
|
7
|
+
data.tar.gz: 8c0b3784dfd824eb13343662c061eaf6f4f7ec308458a2f706127ee5388d00d1b20983e5cc0df0e13ce0c170204b70720cefc8164135d948caf8bd85ffedfffe
|
data/Gemfile.lock
CHANGED
data/lib/tempo/exceptions.rb
CHANGED
@@ -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
|
-
@
|
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
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|