summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZack Hobson2009-07-30 10:23:41 -0700
committerZack Hobson2009-07-30 10:23:41 -0700
commit711945bc67f2787e2d2d06b75989eadb503ae810 (patch)
tree225985fa11d88620a68112e3041f4370bc18d85a
parentd0b0483311a0838b92b9757ca1648e3410f2cb72 (diff)
downloadhcl-711945bc67f2787e2d2d06b75989eadb503ae810.tar.bz2
Do not write empty task cache, this may affect #23.
-rw-r--r--lib/hcl.rb1
-rw-r--r--lib/hcl/task.rb10
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/hcl.rb b/lib/hcl.rb
index 5237e2d..3231790 100644
--- a/lib/hcl.rb
+++ b/lib/hcl.rb
@@ -212,7 +212,6 @@ EOM
date = args.empty? ? nil : Chronic.parse(args.join(' '))
total_hours = 0.0
DayEntry.all(date).each do |day|
- # TODO more information and formatting options
running = day.running? ? '(running) ' : ''
puts "\t#{as_hours day.hours}\t#{running}#{day.project} #{day.notes}"[0..78]
total_hours = total_hours + day.hours.to_f
diff --git a/lib/hcl/task.rb b/lib/hcl/task.rb
index 5923867..e5dc267 100644
--- a/lib/hcl/task.rb
+++ b/lib/hcl/task.rb
@@ -8,8 +8,10 @@ class HCl
new xml_to_hash(task).merge(:project => project)
end)
end
- File.open(File.join(ENV['HOME'],'.hcl_tasks'), 'w') do |f|
- f.write tasks.uniq.to_yaml
+ unless tasks.empty?
+ File.open(File.join(ENV['HOME'],'.hcl_tasks'), 'w') do |f|
+ f.write tasks.uniq.to_yaml
+ end
end
end
@@ -18,7 +20,9 @@ class HCl
end
def self.find project_id, id
- all.detect {|t| t.project.id == project_id && t.id == id }
+ all.detect do |t|
+ t.project.id.to_i == project_id.to_i && t.id.to_i == id.to_i
+ end
end
def to_s