lib/sculd/manager.rb in sculd-0.0.1 vs lib/sculd/manager.rb in sculd-0.0.2
- old
+ new
@@ -1,10 +1,14 @@
#! /usr/bin/env ruby
# coding: utf-8
require "date"
require "sculd.rb"
+
+require "rubygems"
+gem "highline"
+require "highline"
#require "/home/ippei/devel/sculd/lib/sculd.rb"
#
#
#
@@ -18,11 +22,11 @@
def initialize(file, io = $stdout)
@source_file = file
load_file(@source_file, io)
end
- def show(num_event, num_task)
+ def show(num_event, num_task, io = $stdout)
show_events(num_event)
show_tasks(num_task)
end
private
@@ -61,24 +65,39 @@
end
# Show events in 'num' days from todary.
def show_events(num, today = Date.today, io = $stdout)
return if num == 0
+ hl = HighLine.new($stdin, io)
d_e = days_events
io.puts "Events:"
num.times do |i|
date = today + i
+ str = " #{date.to_s} #{WEEKDAYS[date.wday]} "
+
+ case date.wday
+ when 0
+ hl.say(" <%= color('#{str}', :white, :on_red) %>")
+ when 6
+ hl.say(" <%= color('#{str}', :white, :on_blue) %>")
+ else
+ hl.say(" <%= color('#{str}', :white, :on_black) %>")
+ end
+
events = d_e[date]
if events # if plan is not empty.
- io.puts " #{date.to_s} #{WEEKDAYS[date.wday]}"
+ #HIGHLINE.say("<%= color('red', :red) %>!")
+ #HIGHLINE.say(" <%= color(#{date.to_s} #{WEEKDAYS[date.wday]}, :white, :red) %>")
+ #hl.say(" <%= color('red', :red) %>!")
+ #io.puts str
events.sort_by{|i| i.datetime}.each do |job|
io.puts " #{job.description.strip}"
end
- io.puts
else
- next
+ io.puts " (no plan)"
end
+ io.puts
end
end
# Return a hash of dates and events.
# The eventes generated from @schedules sorted by date and time.