Permalink
Browse files

Execute using TM_RUBY.

  • Loading branch information...
1 parent aa7701c commit 84072d00d5737b7c8eb2f03fa3c3ec18274df4a7 @infininight infininight committed Sep 8, 2011
Showing with 41 additions and 26 deletions.
  1. +15 −26 Commands/Execute Line with Ruby.plist
  2. +26 −0 Support/bin/execute_line.rb
@@ -1,47 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
- <string>#!/usr/bin/env ruby
+ <string>#!/usr/bin/env bash
+[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
-# be smart, dont print something if we already have..
-$write_count = 0
-def STDOUT.write(what)
- $write_count += 1
- super(what)
-end
+export TM_RUBY=$(which "${TM_RUBY:-ruby}")
-# execure the code
-begin
- # insert a space if input was a selection, if it was a line insert \n
- print(ENV['TM_SELECTED_TEXT'] ? " " : "\n")
- r = eval(STDIN.read)
-rescue Object
- r = $!.class.to_s
-end
-
-# try to_s, if it doesnt work use inspect
-# Array and Hash are shown via inspect because they look better with formating
-# do this just if the script did not print anything itself
-if $write_count == 1
- print( (r.class != Hash and r.class != Array and not r.nil? and r.respond_to? :to_s) ? r.to_s : r.inspect )
- print( "\n" ) unless ENV.has_key?('TM_SELECTED_TEXT')
-end
+"${TM_RUBY}" "$TM_BUNDLE_SUPPORT/bin/execute_line.rb"
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
+ <key>inputFormat</key>
+ <string>text</string>
<key>keyEquivalent</key>
<string>^E</string>
<key>name</key>
<string>Execute Line / Selection as Ruby</string>
- <key>output</key>
- <string>afterSelectedText</string>
+ <key>outputCaret</key>
+ <string>afterOutput</string>
+ <key>outputFormat</key>
+ <string>text</string>
+ <key>outputLocation</key>
+ <string>afterInput</string>
<key>uuid</key>
<string>EE5F1FB2-6C02-11D9-92BA-0011242E4184</string>
+ <key>version</key>
+ <integer>2</integer>
</dict>
</plist>
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+# encoding: utf-8
+
+# be smart, dont print something if we already have..
+$write_count = 0
+def STDOUT.write(what)
+ $write_count += 1
+ super(what)
+end
+
+# execure the code
+begin
+ # insert a space if input was a selection, if it was a line insert \n
+ print(ENV['TM_SELECTED_TEXT'] ? " " : "\n")
+ r = eval(STDIN.read)
+rescue Object
+ r = $!.class.to_s
+end
+
+# try to_s, if it doesnt work use inspect
+# Array and Hash are shown via inspect because they look better with formating
+# do this just if the script did not print anything itself
+if $write_count == 1
+ print( (r.class != Hash and r.class != Array and not r.nil? and r.respond_to? :to_s) ? r.to_s : r.inspect )
+ print( "\n" ) unless ENV.has_key?('TM_SELECTED_TEXT')
+end

0 comments on commit 84072d0

Please sign in to comment.