humanisaton of Time output, TODO updated
This commit is contained in:
parent
3954287926
commit
cb430a15ac
4 changed files with 46 additions and 24 deletions
9
TODO
9
TODO
|
@ -2,3 +2,12 @@
|
|||
[2] Code the filter command created:"Thu Jun 11 16:07:59 +0200 2009"
|
||||
[3] Code the automatic sort command (it appear to be a complex function) created:"Thu Jun 11 16:08:27 +0200 2009"
|
||||
[4] Code the modify and extend commands /1\ created:"Thu Jun 11 16:09:24 +0200 2009"
|
||||
[5] Humanize DateTime output created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[6] Code a Start/Stop task could be multiple tasks in parallel created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[7] Code the standard questionning path for organising tasks created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[8] Code a notification system created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[9] Code the 2 minutes counter created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[10] Code the x5 method (10+2) created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[11] Code nice done task output (from last week, from last day...) created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[12] Code the hability to have repetitives tasks (every week, every month...) created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
[13] Recode tag to be able to separate them with commas. created:"Fri Jun 12 20:00:00 +0200 2009"
|
||||
|
|
|
@ -2,24 +2,28 @@
|
|||
|
||||
require 'time'
|
||||
|
||||
module BetterOutput
|
||||
module HumanTimeOutput
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
alias_method :original_to_s, :to_s unless method_defined?(:original_to_s)
|
||||
# alias_method :to_s, :to_s_humanized
|
||||
end
|
||||
end
|
||||
|
||||
def is_today?
|
||||
selfTab=self.to_a
|
||||
nowTab=Time.now.to_a
|
||||
return selfTab[4] == nowTab[4] and
|
||||
selfTab[5] == nowTab[5] and
|
||||
return selfTab[4] == nowTab[4] &&
|
||||
selfTab[5] == nowTab[5] &&
|
||||
selfTab[6] == nowTab[6]
|
||||
end
|
||||
def to_s
|
||||
now=Time.now
|
||||
nowTab=now.to_a
|
||||
selfTab=self.to_a
|
||||
|
||||
if (self < now): # in the past
|
||||
if is_today?:
|
||||
else: # in the future
|
||||
def to_s_humanized
|
||||
if self.is_today?
|
||||
return "today"
|
||||
else
|
||||
self.original_to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
Time.send :include, BetterOutput
|
||||
Time.send :include, HumanTimeOutput
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
require 'rubygems'
|
||||
require 'chronic'
|
||||
require 'time'
|
||||
require 'humanTimeOutput.rb'
|
||||
|
||||
class TaskTime
|
||||
@created # creation date of the task
|
||||
|
|
26
ytodo.rb
26
ytodo.rb
|
@ -7,10 +7,12 @@ require 'readline'
|
|||
#
|
||||
# it lacks a read config from config file
|
||||
listeEnvVariables=[]
|
||||
|
||||
autosave=true
|
||||
listeEnvVariables<<='autosave'
|
||||
defaultTaskFile="TODO"
|
||||
listeEnvVariables<<='defaultTaskFile'
|
||||
|
||||
saveFile="TODO"
|
||||
listeEnvVariables<<='saveFile'
|
||||
|
||||
def showVariable (varname)
|
||||
printf '%20s = ', varname
|
||||
|
@ -24,8 +26,8 @@ if __FILE__ == $0:
|
|||
if not autosave:
|
||||
answer=Readline.readline('Do you want to save your changes? (y/n)',false)
|
||||
if not answer =~ /^no?$/:
|
||||
puts "Changes saved in #{defaultTaskFile}"
|
||||
todoList.save defaultTaskFile
|
||||
puts "Changes saved in #{saveFile}"
|
||||
todoList.save saveFile
|
||||
end
|
||||
end
|
||||
puts "\nGood Bye... See you later for another safe and productive day"
|
||||
|
@ -33,13 +35,13 @@ if __FILE__ == $0:
|
|||
}
|
||||
|
||||
todoList=TodoList.new
|
||||
todoList.load defaultTaskFile
|
||||
todoList.load saveFile
|
||||
while entry = Readline.readline('> ',true):
|
||||
case entry
|
||||
when /^(a|\+|add) / # ça commence par 'a ' '+ ' ou 'add '
|
||||
todoList.addTask( Task.new(entry.sub(/^(a|\+|add) /,"")) )
|
||||
if autosave:
|
||||
todoList.save defaultTaskFile
|
||||
todoList.save saveFile
|
||||
end
|
||||
when /^(l|list)( ?(\d*))?/
|
||||
if $3.length>0: print "number "+$3 end
|
||||
|
@ -48,7 +50,7 @@ if __FILE__ == $0:
|
|||
if $3 and $3.length>0:
|
||||
filename=$3
|
||||
else
|
||||
filename=defaultTaskFile
|
||||
filename=saveFile
|
||||
end
|
||||
puts "saving to " + filename
|
||||
todoList.save filename
|
||||
|
@ -56,7 +58,7 @@ if __FILE__ == $0:
|
|||
if $2.length>0:
|
||||
filename = $2
|
||||
else
|
||||
filename = defaultTaskFile
|
||||
filename = saveFile
|
||||
end
|
||||
todoList.load filename
|
||||
when /^h(elp)?$/
|
||||
|
@ -107,11 +109,17 @@ Date: #due_date, #start_date,due_date
|
|||
eval "puts "+key
|
||||
end
|
||||
end
|
||||
when /^set ([^= ]*)(=|\s*)(.*)$/
|
||||
# default all variable are strings
|
||||
begin
|
||||
eval $1+"="+$3
|
||||
end
|
||||
when /^q(uit)?$/
|
||||
break
|
||||
when /^(!|cmd )(.+)$/
|
||||
system( $2 )
|
||||
# must be the last two entries
|
||||
when /^$/
|
||||
when /^.{1,10}$/
|
||||
# if the entry is not
|
||||
# recognized and less than 10 characters
|
||||
|
@ -122,7 +130,7 @@ Date: #due_date, #start_date,due_date
|
|||
# and not recognized then it is a new entry
|
||||
todoList.addTask( Task.new(entry) )
|
||||
if autosave:
|
||||
todoList.save defaultTaskFile
|
||||
todoList.save saveFile
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue