Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
68 lines (60 sloc) 1.86 KB
<?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 ruby18
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate.rb"
REQUIRE_RE = /^\s*(?:require|load)\s*(['"])([^'"#]+?)(?:\.rb)?\1[ \t]*$/
Dir.chdir(ENV['TM_DIRECTORY']) if ENV.has_key?('TM_DIRECTORY')
gems_installed = begin
require 'rubygems'
true
rescue LoadError
false
end
requires = if ENV['TM_CURRENT_LINE'].to_s =~ REQUIRE_RE
["#{$2}.rb"]
else
$stdin.read.scan(REQUIRE_RE).map { |_, path| "#{path}.rb" }
end
abort 'No includes found.' if requires.empty?
file = if requires.size &gt; 1
choice = TextMate::UI.menu(requires) or exit
requires[choice]
else
requires.pop
end
dir = $LOAD_PATH.find { |dir| File.exist? File.join(dir, file) }
if not dir and gems_installed and gem_spec = Gem::GemPathSearcher.new.find(file)
dir = File.join(gem_spec.full_gem_path, gem_spec.require_path)
end
if file and dir
dir.sub!(%r{\A\.(?=/|\z)}, ENV['TM_DIRECTORY']) if ENV['TM_DIRECTORY']
file_path = File.join(dir, file)
# puts file_path
TextMate.go_to :file =&gt; file_path
exit
else
puts "File not found: #{file}"
end
</string>
<key>fallbackInput</key>
<string>document</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>@D</string>
<key>name</key>
<string>Open Require</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>8646378E-91F5-4771-AC7C-43FC49A93576</string>
</dict>
</plist>