Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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