Skip to content

Instantly share code, notes, and snippets.

@cou929
Created January 9, 2012 03:10
Show Gist options
  • Save cou929/1580812 to your computer and use it in GitHub Desktop.
Save cou929/1580812 to your computer and use it in GitHub Desktop.
Send changelog entry to posterous
#! /usr/bin/ruby
posterous_mailto = '[email protected]'
## get stdin
is_head = true
header = ''
body = ''
while line = gets
if (/exit/ =~ line)
break
end
if is_head
header = line
is_head = false
next
end
body += line
end
## parse header
header =~ /^\* (.*?): (.*?)$/
tag = $1
title = $2
subject = "#{title} ((tag: #{tag}))"
if !tag or !title
STDERR.puts('Cannot parse header. Is stdin changelog?')
exit(1)
end
## add markdown tag to body
body = "<markdown>\n" + body + "</markdown>"
## invoke mail command with popen
f = IO.popen("sendgmail.py -s \"#{subject}\" #{posterous_mailto}", "w")
f.write(body)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment