Created
January 7, 2012 22:54
-
-
Save commuterjoy/1576369 to your computer and use it in GitHub Desktop.
Inline documentation of system commands
This file contains hidden or 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
# Was trying to figure out a nice way to document oblique system | |
# commands embedded in a ruby script. I think a nice way is to | |
# write inline comments then gsub them out and collapse newlines | |
# before running system(). | |
uri = 'http://example.com' | |
command = ("curl | |
-i # print header | |
-L # follow HTTP 302s | |
-H 'Cache-control: no-cache' | |
--cert ~/ca.pem | |
-k # ignore dodgy certificates | |
-s | |
%s" % [uri]).gsub!(/#([^\n]+)|\n/m, '') | |
puts `#{command}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://rubular.com/r/A8eyPz8Zwp