-
Notifications
You must be signed in to change notification settings - Fork 210
/
Require Rails File.tmDragCommand
41 lines (40 loc) · 1.1 KB
/
Require Rails File.tmDragCommand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?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
file_path = ENV['TM_DROPPED_FILE'].gsub(/\.rb$/, '')
full_file_path = File.expand_path(file_path)
relative_path = nil
known_load_path = %w[app/controllers app/models app/helpers app config lib]
known_load_path.each do |path|
if full_file_path =~ %r{^#{File.join(ENV['TM_PROJECT_DIRECTORY'], path)}/(.*)}
relative_path = $1
break
end
end
if relative_path
puts "require '#{relative_path}'"
else
puts "require File.dirname(__FILE__) + '/#{file_path}'"
end
</string>
<key>draggedFileExtensions</key>
<array>
<string>rb</string>
</array>
<key>input</key>
<string>selection</string>
<key>name</key>
<string>Require Rails File</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.ruby.rails</string>
<key>uuid</key>
<string>56151E60-589F-4CE7-8062-3E087732E2F1</string>
</dict>
</plist>