Browse files

added ability to close view old one things and create new ones

  • Loading branch information...
1 parent eb25d92 commit a3575cd7cdc32891bd6780679652d520968f9ab8 @mgornick committed Oct 7, 2011
Showing with 21 additions and 13 deletions.
  1. +1 −1 models/task.rb
  2. +20 −12 start.rb
View
2 models/task.rb
@@ -1,4 +1,4 @@
class Task < ActiveResource::Base
- self.site = 'http://localhost:3000/'
+ self.site = 'http://www.oneth1ng.net'
self.user = "mgornick@inventables.com"
end
View
32 start.rb
@@ -10,22 +10,30 @@
tasks = Task.find(:all)
task = tasks.first
-description = ARGV[0] || "test"
-if task.action_taken == "unfinished"
- if task.created_at.today? # need to update existing task
- today_task = task
- else # close out old task and start the new task
+if ARGV[0]
+ # set the current one thing for today
+ description = ARGV[0] || "test"
+
+ if Time.parse(task.created_at).today?
+ puts "Looks like a task from today... updating it"
+ task.description = description
+ task.save
+ else
+ puts "closing out old task and making a new one thing for today"
task.action_taken = "finished"
- todays_task = Task.new
task.save
+
+ Task.create(:description => description)
end
- todays_task.description = description
- todays_task.save
+
+ timer = Timer.new(description)
+ timer.save
else
- Task.create(:description => description)
+ # view the past 3 one things
+ tasks = Task.find(:all)
+ tasks.each do |task|
+ puts "I've worked on '#{task.description}' - #{task.action_taken ? task.action_taken : 'unfinished'}"
+ end
end
-t = Task.find(:all).first.description
-timer = Timer.new(t)
-timer.save

0 comments on commit a3575cd

Please sign in to comment.