Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (49 sloc) 1.723 kB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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 ruby18
class String
def escape(char)
gsub(/\\.|#{Regexp.quote(char)}/) { |match| match == char ? "\\#{char}" : match }
end
def unescape(char)
gsub(/\\./) { |match| match == "\\#{char}" ? char : match }
end
end
print case str = STDIN.read
# Handle standard quotes
when /\A"(.*)"\z/m; "'" + $1.unescape('"').escape("'") + "'"
when /\A'(.*)'\z/m; "%Q{" + $1.unescape("'").escape("}") + "}"
when /\A%[Qq]?\{(.*)\}\z/m; '"' + $1.unescape("}").escape('"') + '"'
# Handle the more esoteric quote styles
when /\A%[Qq]?\[(.*)(\])\z/m,
/\A%[Qq]?\((.*)(\))\z/m,
/\A%[Qq]?&lt;(.*)(&gt;)\z/m; '"' + $1.unescape($2).escape('"') + '"'
when /\A%[Qq]?(.)(.*)\1\z/m; '"' + $2.unescape($1).escape('"') + '"'
# Handle shell escapes
when /\A`(.*)`\z/m; "%x{" + $1.unescape("`").escape("}") + "}"
when /\A%x\{(.*)\}\z/m; "`" + $1.unescape("}").escape("`") + "`"
# Default case
else str
end
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^"</string>
<key>name</key>
<string>Toggle Quote Style</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
<string>source.ruby string.quoted.double, source.ruby string.quoted.single, source.ruby string</string>
<key>uuid</key>
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
</dict>
</plist>
Jump to Line
Something went wrong with that request. Please try again.