forked from drnic/ruby-tmbundle
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rak.tmCommand
53 lines (45 loc) · 1.42 KB
/
Rak.tmCommand
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
42
43
44
45
46
47
48
49
50
51
52
53
<?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>#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
rak_options = TextMate::UI.request_string(:title => "Rak", :prompt => "Rak parameters", :default => "")
Dir.chdir(ENV['TM_PROJECT_DIRECTORY'])
results = `rak #{rak_options}`
p results
out = ''
current_file = nil
results.split("\n").each do |line|
out_line = line
#file path
if line =~ /^[A-Za-z\/].*$/
current_file = line
out_line = "<h2>#{line}</h2>"
#line no
elsif line =~ /^\s*\d+\|/
line_number = line.match(/^\s*(\d+)\|/)[1]
path = File.join(ENV['TM_PROJECT_DIRECTORY'], current_file)
out_line = %Q!<a href="txmt://open?url=file://#{path}&line=#{line_number}">#{line}</a>!
end
out << out_line
end
puts out</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>~R</string>
<key>name</key>
<string>Rak</string>
<key>output</key>
<string>openAsNewDocument</string>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>2C505CAB-DF37-4542-804D-30F404B346C3</string>
</dict>
</plist>