Skip to content

Instantly share code, notes, and snippets.

@druttka
Created April 2, 2014 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save druttka/9927030 to your computer and use it in GitHub Desktop.
Save druttka/9927030 to your computer and use it in GitHub Desktop.
drafts_dir = "_drafts" # directory for blog draft files
desc "post drafts"
task :post_drafts do
Dir.foreach("#{source_dir}/#{drafts_dir}") do |item|
itemDate = /(\d{4}-\d{2}-\d{2})-.*.markdown/.match(item)
next unless itemDate
system "mv #{source_dir}/#{drafts_dir}/#{item} #{source_dir}/#{posts_dir}" if Date.strptime(itemDate[1],'%Y-%m-%d') <= Date.today
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment