Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created November 3, 2013 04:37
Show Gist options
  • Select an option

  • Save psyomn/7286807 to your computer and use it in GitHub Desktop.

Select an option

Save psyomn/7286807 to your computer and use it in GitHub Desktop.
A _very_ naive makefile implementation that suits my purposes.
#!/usr/bin/env ruby
# @author Simon (psyomn) Symeonidis
# Because doing something this simple in a Makefile requires you to read a huge
# fucking manual.
def make(note, output_name)
puts "#{note} >>> #{output_name}"
`pandoc #{note} -o #{output_name}`
end
notes = Dir['*.markdown']
outdir = "pdf/"
notes.each do |note|
output_name = note.split('.')[0..-2].join('.').concat('.pdf')
output_name = "#{outdir}#{output_name}"
# File does not exist, or is not updated
if !File.exist? output_name
make(note, output_name)
elsif File.mtime(output_name).to_i < File.mtime(note).to_i
make(note, output_name)
else
puts "Skip #{note}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment