Created
January 8, 2009 20:08
-
-
Save nogweii/44859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Sample code to take a file formatted similarly to event.template and create an iCalendar VEVENT (using the Icalendar library) | |
require 'rubygems' | |
require 'icalendar' | |
require 'chronic' | |
require 'fileutils' | |
require 'lib/yaml' | |
require 'tempfile' | |
# Copy the template to a tmp file & have the user edit it | |
#tmp_file = File.join(ENV['TMP'] || ENV['TEMP'] || "/tmp", "ical.event.#{$$}") | |
#FileUtils.cp File.config_path('template'), tmp_file | |
tmp_file = Tempfile.open("pipcal") | |
tmp_file.print "#{File.readlines(File.config_path('template'))\n}" | |
tmp_file.fsync # Flush Ruby's buffer to disk | |
tmp_file.close | |
system("#{ENV['EDITOR'] || 'vim'} #{tmp_file}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment