timesheet 0.2.0 → 0.2.1
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/time_report.rb +9 -4
- data/spec/time_report_spec.rb +16 -0
- metadata +2 -2
data/lib/timesheet.rb
CHANGED
@@ -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
|
-
|
24
|
-
|
25
|
-
|
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
|
data/spec/time_report_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2010-01-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|