forked from textmate/ruby.tmbundle
/
Reformat Document.tmCommand
72 lines (66 loc) · 1.83 KB
/
Reformat Document.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?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>saveActiveFile</string>
<key>command</key>
<string>#!/bin/bash
cd "${TM_PROJECT_DIRECTORY:-$(dirname "$TM_FILEPATH")}"
[[ -f "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
(
if [[ -f "Gemfile" ]]; then
bundle list rubocop && bundler_rubocop='bundle exec rubocop'
fi
if [[ ! `which rubocop` && -z "$bundler_rubocop" ]]; then
"$DIALOG" tooltip --text "This command requires RuboCop.
Please install RuboCop via “gem install rubocop”."
exit
fi
aha_found=`which aha`
if [[ $aha_found ]]; then
color='n';
format='--html'
else
format='--text'
fi
rubocop="${bundler_rubocop:-"${TM_RUBOCOP:-rubocop}"}"
output=`$rubocop -a$color "$TM_FILEPATH"`
if [[ $aha_found ]]; then output=`echo "$output" | aha`; fi
"$DIALOG" tooltip "$format" "$output"
) &>/dev/null &</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^H</string>
<key>name</key>
<string>Reformat Document</string>
<key>outputCaret</key>
<string>interpolateByChar</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>rubocop</string>
<key>locations</key>
<array>
<string>/usr/local/bin/rubocop</string>
<string>$HOME/.rbenv/shims/rubocop</string>
<string>$HOME/.rvm/scripts/rvm</string>
</array>
</dict>
</array>
<key>scope</key>
<string>source.ruby</string>
<key>uuid</key>
<string>64BB4EE2-2803-410C-B140-EA545A13F250</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>