Skip to content

Commit

Permalink
Adding a drag command for requiring Ruby files.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.textmate.org/trunk/Bundles/Ruby.tmbundle@10197 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
JEG2 committed Jul 8, 2008
1 parent 6f1158b commit a18ccd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
39 changes: 39 additions & 0 deletions DragCommands/Require Ruby File.tmDragCommand
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 2 additions & 1 deletion info.plist
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit a18ccd4

Please sign in to comment.