timesheet 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/timesheet.rb +1 -1
- data/lib/timesheet/report_item.rb +30 -5
- data/spec/time_report_spec.rb +36 -18
- metadata +2 -2
data/lib/timesheet.rb
CHANGED
@@ -10,16 +10,39 @@ class ReportItem < DelegateClass(TimeEntry)
|
|
10
10
|
@report = report
|
11
11
|
end
|
12
12
|
|
13
|
+
def start_time_sliced?
|
14
|
+
@time_entry.to_range.include?(@report.report_start)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
13
18
|
def start_time
|
14
|
-
if
|
19
|
+
if start_time_sliced?
|
15
20
|
@report.report_start
|
16
21
|
else
|
17
22
|
@time_entry.start_time
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
26
|
+
def duration
|
27
|
+
return 0 if start_time == nil || end_time == nil
|
28
|
+
RichUnits::Duration.new(end_time - start_time)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def end_time_sliced?
|
33
|
+
@time_entry.to_range.include?(@report.report_end)
|
34
|
+
end
|
35
|
+
|
36
|
+
def start_slice_indication
|
37
|
+
(start_time_sliced?) ? '<' : ' '
|
38
|
+
end
|
39
|
+
|
40
|
+
def end_slice_indication
|
41
|
+
(end_time_sliced?) ? '>' : ' '
|
42
|
+
end
|
43
|
+
|
21
44
|
def end_time
|
22
|
-
if
|
45
|
+
if end_time_sliced?
|
23
46
|
@report.report_end
|
24
47
|
else
|
25
48
|
@time_entry.end_time
|
@@ -32,10 +55,12 @@ class ReportItem < DelegateClass(TimeEntry)
|
|
32
55
|
|
33
56
|
def formatted_times
|
34
57
|
str = ""
|
58
|
+
str << start_slice_indication
|
35
59
|
str << start_time.strftime("%m/%d/%Y at %I:%M %p")
|
36
60
|
str << " to "
|
37
61
|
str << end_time.strftime("%m/%d/%Y at ") if ((start_time.year != end_time.year) || (start_time.yday != end_time.yday))
|
38
|
-
str << end_time.strftime("%I:%M %p")
|
62
|
+
str << end_time.strftime("%I:%M %p")
|
63
|
+
str << end_slice_indication
|
39
64
|
end
|
40
65
|
|
41
66
|
def comment
|
@@ -44,8 +69,8 @@ class ReportItem < DelegateClass(TimeEntry)
|
|
44
69
|
|
45
70
|
def formatted_duration
|
46
71
|
str = ""
|
47
|
-
str <<
|
48
|
-
str <<
|
72
|
+
str << duration.strftime("%d Days ") if duration.days > 0
|
73
|
+
str << duration.strftime("%hh %mm")
|
49
74
|
end
|
50
75
|
|
51
76
|
def <=>(other_time_entry)
|
data/spec/time_report_spec.rb
CHANGED
@@ -45,15 +45,33 @@ describe TimeReport do
|
|
45
45
|
stream = StringIO.new
|
46
46
|
@time_report.report(command_options, stream)
|
47
47
|
stream.string.should eql( <<EOS
|
48
|
-
|
49
|
-
| Id | Project |
|
50
|
-
|
51
|
-
| 0 | ProjectB |
|
52
|
-
| 0 | ProjectA |
|
53
|
-
| 0 | ProjectA |
|
54
|
-
| 0 | ProjectB |
|
55
|
-
| 0 | ProjectC |
|
56
|
-
|
48
|
+
+------------------------------------------------------------------------------+
|
49
|
+
| Id | Project | Start - Stop | Hours | Comment |
|
50
|
+
+------------------------------------------------------------------------------+
|
51
|
+
| 0 | ProjectB | 12/01/2009 at 01:00 AM to 05:00 PM | 16h 0m | comment 2 |
|
52
|
+
| 0 | ProjectA | 12/01/2009 at 09:00 AM to 12:00 PM | 3h 0m | comment 1 |
|
53
|
+
| 0 | ProjectA | 12/03/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 3 |
|
54
|
+
| 0 | ProjectB | 12/04/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 4 |
|
55
|
+
| 0 | ProjectC | 12/05/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 5 |
|
56
|
+
+------------------------------------------------------------------------------+
|
57
|
+
EOS
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should be able to produce a detail report with slice indicators" do
|
62
|
+
command_options = {:detail => true, :start => Time.local(2009, 12, 1, 11, 0, 0), :end => Time.local(2009, 12, 5, 12, 0, 0)}
|
63
|
+
stream = StringIO.new
|
64
|
+
@time_report.report(command_options, stream)
|
65
|
+
stream.string.should eql( <<EOS
|
66
|
+
+-----------------------------------------------------------------------------+
|
67
|
+
| Id | Project | Start - Stop | Hours | Comment |
|
68
|
+
+-----------------------------------------------------------------------------+
|
69
|
+
| 0 | ProjectA | <12/01/2009 at 11:00 AM to 12:00 PM | 1h 0m | comment 1 |
|
70
|
+
| 0 | ProjectB | <12/01/2009 at 11:00 AM to 05:00 PM | 6h 0m | comment 2 |
|
71
|
+
| 0 | ProjectA | 12/03/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 3 |
|
72
|
+
| 0 | ProjectB | 12/04/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 4 |
|
73
|
+
| 0 | ProjectC | 12/05/2009 at 09:00 AM to 12:00 PM> | 3h 0m | comment 5 |
|
74
|
+
+-----------------------------------------------------------------------------+
|
57
75
|
EOS
|
58
76
|
)
|
59
77
|
end
|
@@ -63,15 +81,15 @@ EOS
|
|
63
81
|
stream = StringIO.new
|
64
82
|
@time_report.report(command_options, stream)
|
65
83
|
stream.string.should eql( <<EOS
|
66
|
-
|
67
|
-
| Id | Project |
|
68
|
-
|
69
|
-
| 0 | ProjectB |
|
70
|
-
| 0 | ProjectA |
|
71
|
-
| 0 | ProjectA |
|
72
|
-
| 0 | ProjectB |
|
73
|
-
| 0 | ProjectC |
|
74
|
-
|
84
|
+
+------------------------------------------------------------------------------+
|
85
|
+
| Id | Project | Start - Stop | Hours | Comment |
|
86
|
+
+------------------------------------------------------------------------------+
|
87
|
+
| 0 | ProjectB | 12/01/2009 at 01:00 AM to 05:00 PM | 16h 0m | comment 2 |
|
88
|
+
| 0 | ProjectA | 12/01/2009 at 09:00 AM to 12:00 PM | 3h 0m | comment 1 |
|
89
|
+
| 0 | ProjectA | 12/03/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 3 |
|
90
|
+
| 0 | ProjectB | 12/04/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 4 |
|
91
|
+
| 0 | ProjectC | 12/05/2009 at 09:00 AM to 05:00 PM | 8h 0m | comment 5 |
|
92
|
+
+------------------------------------------------------------------------------+
|
75
93
|
EOS
|
76
94
|
)
|
77
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timesheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John F. Schank III
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-20 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|