- 
      
- 
        Save inem/300084 to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | 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