Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Toggle between 1.9 and Hashrocket hash syntax

  • Loading branch information...
commit 9eeac41279394dcd9e96f0339ebe04e1921d83dc 1 parent 96020fb
@whatcould whatcould authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 Commands/Convert Ruby hash to 1_9 syntax.tmCommand
View
11 Commands/Convert Ruby hash to 1_9 syntax.tmCommand
@@ -7,17 +7,20 @@
<key>command</key>
<string>#!/usr/bin/env ruby
-str = STDIN.read
-print str.gsub(/:(\w+)[\s]+=&gt;[\s]+/, '\1: ')
+print case str = STDIN.read
+ when /=&gt;/; str.gsub(/:(\w+)[\s]+=&gt;[\s]+/, '\1: ')
+ when /(\w+):/; str.gsub(/(\w+):(\s*(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\w+\([^)]*\)|[^,]+))/, ":\\1 =&gt;\\2")
+ else; str
+end
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
- <string>~@=</string>
+ <string>^=</string>
<key>name</key>
- <string>Convert Ruby Hash to 1.9 syntax</string>
+ <string>Toggle Ruby Hash 1.8/1.9 syntax</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>uuid</key>
Please sign in to comment.
Something went wrong with that request. Please try again.