Skip to content

Instantly share code, notes, and snippets.

@elado
Created December 13, 2011 07:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elado/1471108 to your computer and use it in GitHub Desktop.
Save elado/1471108 to your computer and use it in GitHub Desktop.
Convert Entire Ruby Project Hash Syntax to 1.9 ( :sym => value to sym: value )
Dir['**/*.rb', '**/*.rake'].each { |f|
s = open(f).read
awesome_rx = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/
count = s.scan(awesome_rx).length
next if count.zero?
s.gsub!(awesome_rx, '\1\2:')
puts "#{count} replacements @ #{f}"
open(f, 'w') { |b| b << s }
}
@elado
Copy link
Author

elado commented Dec 13, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment