mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
<?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">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>beforeRunningCommand</key>
|
|
<string>nop</string>
|
|
<key>command</key>
|
|
<string>#!/usr/bin/env ruby
|
|
|
|
# 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
|
|
</string>
|
|
<key>fallbackInput</key>
|
|
<string>line</string>
|
|
<key>input</key>
|
|
<string>selection</string>
|
|
<key>keyEquivalent</key>
|
|
<string>^E</string>
|
|
<key>name</key>
|
|
<string>Execute Line / Selection as Ruby</string>
|
|
<key>output</key>
|
|
<string>afterSelectedText</string>
|
|
<key>uuid</key>
|
|
<string>EE5F1FB2-6C02-11D9-92BA-0011242E4184</string>
|
|
</dict>
|
|
</plist>
|