Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding a drag command for requiring Ruby files.

git-svn-id: http://svn.textmate.org/trunk/Bundles/Ruby.tmbundle@10197 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
commit a18ccd413a76d7012275a920f518982d2914f2c2 1 parent 6f1158b
@JEG2 JEG2 authored
Showing with 41 additions and 1 deletion.
  1. +39 −0 DragCommands/Require Ruby File.tmDragCommand
  2. +2 −1  info.plist
View
39 DragCommands/Require Ruby File.tmDragCommand
@@ -0,0 +1,39 @@
+<?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>#!/usr/bin/env ruby -wKU
+
+require 'pathname'
+
+require "#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb"
+
+from_path = Pathname.new(ENV['TM_FILEPATH'] || '.').dirname.realpath
+to_path = Pathname.new(ENV['TM_DROPPED_FILE']).realpath
+begin
+ path = to_path.relative_path_from(from_path)
+rescue ArgumentError
+ path = to_path
+end
+lib = path.to_s.sub(/\.rb\z/i, '')
+puts %Q{require "#{e_sn(lib).gsub('"', '\"')}"}
+</string>
+ <key>draggedFileExtensions</key>
+ <array>
+ <string>rb</string>
+ </array>
+ <key>input</key>
+ <string>selection</string>
+ <key>name</key>
+ <string>Require Ruby File</string>
+ <key>output</key>
+ <string>insertAsSnippet</string>
+ <key>scope</key>
+ <string>source.ruby</string>
+ <key>uuid</key>
+ <string>C122CD92-DDBE-4869-9C7A-CC2B254C9411</string>
+</dict>
+</plist>
View
3  info.plist
@@ -1,5 +1,5 @@
<?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>contactEmailRot13</key>
@@ -426,6 +426,7 @@
<string>97054C4D-E4A3-45B1-9C00-B82DBCB30CAD</string>
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
<string>47D203ED-EB9B-4653-A07B-A897800CEB76</string>
+ <string>C122CD92-DDBE-4869-9C7A-CC2B254C9411</string>
<string>7990EE60-C850-4779-A8C0-7FD2C853B99B</string>
<string>121B334B-2AA6-4E9A-A8B8-BF93B627982B</string>
<string>58FDEA60-10AF-4C49-AA09-29B77030DB25</string>
Please sign in to comment.
Something went wrong with that request. Please try again.