Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[NEW] Add a ScriptMate based “Run Script” command to the IO bundle.

git-svn-id: http://svn.textmate.org/trunk/Bundles/Io.tmbundle@9900 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
commit a811f35fcab0b85fb356ce13d6aca1c4187e3001 1 parent c971a1a
@lasersox lasersox authored
Showing with 47 additions and 0 deletions.
  1. +23 −0 Commands/Run Script.tmCommand
  2. +24 −0 Support/run_script.rb
View
23 Commands/Run Script.tmCommand
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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>export TM_RUBY=$(type -p "${TM_RUBY:-ruby}")
+"$TM_RUBY" -- "$TM_BUNDLE_SUPPORT/run_script.rb"</string>
+ <key>input</key>
+ <string>document</string>
+ <key>keyEquivalent</key>
+ <string>@r</string>
+ <key>name</key>
+ <string>Run Script</string>
+ <key>output</key>
+ <string>showAsHTML</string>
+ <key>scope</key>
+ <string>source.io</string>
+ <key>uuid</key>
+ <string>F35C936A-92CD-4D36-925D-F4457A52BCEE</string>
+</dict>
+</plist>
View
24 Support/run_script.rb
@@ -0,0 +1,24 @@
+require "#{ENV["TM_SUPPORT_PATH"]}/lib/scriptmate"
+require "pathname"
+$KCODE = 'u'
+require 'jcode'
+
+STDOUT.sync = true
+
+$SCRIPTMATE_VERSION = "$Revision: 9890 $"
+
+class IOScript < UserScript
+ def lang; "IO" end
+ def executable; @hashbang || ENV['TM_IO'] || 'io' end
+ def args; [] end
+ def version_string
+ res = %x{#{executable} 2>&1 <<< "System version; System exit;"}.chomp.match(/\d*/)[0]
+ res + " (#{executable})"
+ end
+ def default_extension; ".io" end
+end
+
+class IOMate < ScriptMate; end
+
+script = IOScript.new(STDIN.read)
+IOMate.new(script).emit_html
Please sign in to comment.
Something went wrong with that request. Please try again.