Skip to content

Instantly share code, notes, and snippets.

@nex3
Created February 10, 2010 03:25
Show Gist options
  • Save nex3/299992 to your computer and use it in GitHub Desktop.
Save nex3/299992 to your computer and use it in GitHub Desktop.
require 'parse_tree'
require 'ruby2ruby'
require 'parse_tree_extensions'
require 'shellwords'
class Proc
def to_sh
ruby = `which ruby`.strip
command = Shellwords.shellescape(to_ruby.gsub(/\Aproc \{(.*)\}\Z/m, '\1').strip)
paths = $LOAD_PATH.map {|p| Shellwords.shellescape("-I" + p)}.join(" ")
requires = $LOADED_FEATURES.reverse.map {|p| Shellwords.shellescape("-r" + p)}.join(" ")
"#{ruby} #{paths} #{requires} -e #{command}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment