mirror of
https://github.com/atom/atom.git
synced 2026-01-27 07:47:58 -05:00
66 lines
1.8 KiB
Plaintext
66 lines
1.8 KiB
Plaintext
<?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
|
|
|
|
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]*$/
|
|
|
|
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 > 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 => 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>
|