Created
January 9, 2012 03:10
-
-
Save cou929/1580812 to your computer and use it in GitHub Desktop.
Send changelog entry to posterous
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
#! /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