Created
September 18, 2009 12:37
-
-
Save auxesis/189033 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
desc "build pngs from svgs" | |
task :build do | |
Dir.glob("sources/*.svg").each do |file| | |
if modified?(file) | |
basename = File.basename(file, '.svg') | |
slide = "slides/#{basename}.png" | |
system("inkscape -e #{slide} -f #{file}") | |
end | |
end | |
end | |
def modified?(filename) | |
index_filename = File.join(File.dirname(__FILE__), "cache", "index") | |
# read or initialise index | |
if File.exists?(index_filename) | |
@index = File.open(index_filename, 'r') { |f| Marshal.load(f) } | |
else | |
@index = {} | |
end | |
# check if modified | |
if @index[filename] | |
modified = File.mtime(filename) > @index[filename][:mtime] | |
else | |
modified = true | |
end | |
# update index | |
@index[filename] = {:mtime => File.mtime(filename)} | |
File.open(index_filename, 'w') { |f| Marshal.dump(@index, f) } | |
return modified | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment