Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created April 30, 2010 21:40
Show Gist options
  • Save eqdw/385800 to your computer and use it in GitHub Desktop.
Save eqdw/385800 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'yaml'
require 'chronic'
require 'date'
require 'time'
FILENAME = File.expand_path "~/.growls"
class Growl
attr_reader :title, :message, :time
def initialize(title, message, time)
@title = title
@message = message
@time = time
end
def <=>(other)
@time <=> other.time
end
end
list = nil
begin
list = YAML::load(File.read(FILENAME))
puts "Successfully loaded file"
rescue
list = []
end
case ARGV[0]
when "-p"
needs_growling, list = list.partition{|elem| (elem.time <=> Time.now) <= 0}
needs_growling.each do |growl|
`echo \"#{growl.message}\" | growlnotify #{growl.title}`
end
when "-a"
#ARGV[1] = title
#ARGV[2] = message
#ARGV[3] = date
#ARGV[4] = time
list << Growl.new(ARGV[1], ARGV[2], Chronic.parse("#{ARGV[3]} #{ARGV[4]}"))
else
puts "TESTING"
end
File.open(FILENAME,"w"){|f|f.puts YAML::dump(list)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment