timesheet 0.2.5 → 0.2.6

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/lib/timesheet.rb CHANGED
@@ -17,7 +17,7 @@ require 'timesheet/timesheet_parser'
17
17
 
18
18
  class Timesheet
19
19
 
20
- VERSION = '0.2.5'
20
+ VERSION = '0.2.6'
21
21
 
22
22
  def self.run(params)
23
23
  command_hash = {}
@@ -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 @time_entry.to_range.include?(@report.report_start)
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 to_range.include?(@report.report_end)
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 << @time_entry.duration.strftime("%d Days ") if @time_entry.duration.days > 0
48
- str << @time_entry.duration.strftime("%hh %mm")
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)
@@ -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 | 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
- +----------------------------------------------------------------------------+
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 | Start - Stop | Hours | Comment |
68
- +----------------------------------------------------------------------------+
69
- | 0 | ProjectB | 12/01/2009 at 01:00 AM to 05:00 PM | 16h 0m | comment 2 |
70
- | 0 | ProjectA | 12/01/2009 at 09:00 AM to 12:00 PM | 3h 0m | comment 1 |
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 05:00 PM | 8h 0m | comment 5 |
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.5
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-07 00:00:00 -05:00
12
+ date: 2010-02-20 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency