|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 |
| -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
3 | 3 | <plist version="1.0">
|
4 | 4 | <dict>
|
5 | 5 | <key>beforeRunningCommand</key>
|
6 | 6 | <string>nop</string>
|
7 | 7 | <key>command</key>
|
8 |
| - <string>#!/usr/bin/env perl |
9 |
| -$/=\0;$_=<>; # Read all input |
| 8 | + <string>#!/usr/bin/env ruby |
10 | 9 |
|
11 |
| -s/\s*\-\-.*$//g; # Strip comments |
| 10 | +res = STDIN.read |
12 | 11 |
|
13 |
| -1while s@^(([^'"]*["'][^'"]*["'])*[^"']*)(\n+|\s{2,})@$1 @; # Compact whitespace |
| 12 | +# Remove extraneous scope xml |
| 13 | +res.gsub!(/<(?!\/?(string|comment)\.)[^>]*>/, '') |
14 | 14 |
|
15 |
| -# set defaultCStringEncoding to UTF-8 and open pbcopy |
16 |
| -open(PBCOPY, '|__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbcopy'); |
17 |
| -print PBCOPY; # Print the SQL to pbcopy |
18 |
| -close PBCOPY; |
19 |
| -print "Copied SQL to Clipboard";</string> |
| 15 | +# Remove comments |
| 16 | +res.gsub!(/<comment\.[^>]*>[^<]*?<\/comment\.[^>]*>/, '') |
| 17 | +
|
| 18 | +# Compact whitespace, leaving strings alone |
| 19 | +res.gsub!(/(?:([^<]+)|(<string\.[^>]*>[^<]*?<\/string\.[^>]*>))/) { |
| 20 | + if $1 |
| 21 | + out = $1 |
| 22 | + out = out.gsub(/\n/, ' ') |
| 23 | + out = out.gsub(/\s{2,}/, ' ') |
| 24 | + elsif $2 |
| 25 | + $2 |
| 26 | + end |
| 27 | +} |
| 28 | +
|
| 29 | +# Remove string tags |
| 30 | +res.gsub!(/<\/?string\.[^>]*>/, '') |
| 31 | +
|
| 32 | +# Un-encode entities |
| 33 | +res.gsub!(/&amp;/, '&') |
| 34 | +res.gsub!(/&lt;/, '<') |
| 35 | +
|
| 36 | +IO.popen('pbcopy', 'w') { |io| io << res } |
| 37 | +
|
| 38 | +puts "Copied SQL to Clipboard" |
| 39 | +</string> |
20 | 40 | <key>input</key>
|
21 | 41 | <string>selection</string>
|
| 42 | + <key>inputFormat</key> |
| 43 | + <string>xml</string> |
22 | 44 | <key>keyEquivalent</key>
|
23 | 45 | <string>~@C</string>
|
24 | 46 | <key>name</key>
|
25 | 47 | <string>Copy Condensed SQL</string>
|
26 |
| - <key>output</key> |
27 |
| - <string>showAsTooltip</string> |
| 48 | + <key>outputCaret</key> |
| 49 | + <string>afterOutput</string> |
| 50 | + <key>outputFormat</key> |
| 51 | + <string>text</string> |
| 52 | + <key>outputLocation</key> |
| 53 | + <string>toolTip</string> |
28 | 54 | <key>scope</key>
|
29 | 55 | <string>source.sql</string>
|
30 | 56 | <key>uuid</key>
|
31 | 57 | <string>37E7E7F5-DD1E-4306-B258-0F9176DC8D7E</string>
|
| 58 | + <key>version</key> |
| 59 | + <integer>2</integer> |
32 | 60 | </dict>
|
33 | 61 | </plist>
|
0 commit comments