timesheet 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ require 'timesheet/timesheet_parser'
16
16
 
17
17
  class Timesheet
18
18
 
19
- VERSION = '0.2.0'
19
+ VERSION = '0.2.1'
20
20
 
21
21
  def self.run(params)
22
22
  command_hash = {}
@@ -18,11 +18,16 @@ class TimeReport
18
18
  end
19
19
 
20
20
  def report(command_options, outstream = STDOUT)
21
- trim(command_options[:start], command_options[:end])
22
21
 
23
- detail_report(outstream) if command_options[:detail]
24
- summary_report(outstream) if command_options[:summary]
25
- byday_report(outstream) if command_options[:byday]
22
+ if (@entries.nil? || @entries.empty?)
23
+ outstream.puts("No data available.")
24
+ else
25
+ trim(command_options[:start], command_options[:end])
26
+
27
+ detail_report(outstream) if command_options[:detail]
28
+ summary_report(outstream) if command_options[:summary]
29
+ byday_report(outstream) if command_options[:byday]
30
+ end
26
31
  end
27
32
 
28
33
  private
@@ -24,6 +24,22 @@ describe TimeReport do
24
24
  @time_report.entries[-1].end_time.should eql(Time.local(2009, 12, 5, 17, 0, 0))
25
25
  end
26
26
 
27
+ it "should show 'no data' if entries is missing" do
28
+ stream = StringIO.new
29
+ time_report = TimeReport.new(nil)
30
+ command_options = {:summary => true, :start => Time.local(2009, 12, 1), :end => Time.local(2009, 12, 6)}
31
+ time_report.report(command_options, stream)
32
+ stream.string.should eql("No data available.\n")
33
+ end
34
+
35
+ it "should show 'no data' if there are no entries to report" do
36
+ stream = StringIO.new
37
+ time_report = TimeReport.new([])
38
+ command_options = {:summary => true, :start => Time.local(2009, 12, 1), :end => Time.local(2009, 12, 6)}
39
+ time_report.report(command_options, stream)
40
+ stream.string.should eql("No data available.\n")
41
+ end
42
+
27
43
  it "should be able to produce a detail report" do
28
44
  command_options = {:detail => true, :start => Time.local(2009, 12, 1), :end => Time.local(2009, 12, 6)}
29
45
  stream = StringIO.new
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.0
4
+ version: 0.2.1
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-01-05 00:00:00 -05:00
12
+ date: 2010-01-11 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency