Created
May 18, 2011 18:18
-
-
Save techpeace/979165 to your computer and use it in GitHub Desktop.
A collection of scripts to automate some Rails 3 upgrade tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Upgrades all files to use Rails.logger, rather than logger | |
Dir['app/**/*.*', 'config/**/*.*', 'lib/**/*.*'].each{ |filename| | |
data = File.read filename | |
File.open(filename,'w'){|f| | |
f.print data.gsub(/\slogger/, ' Rails.logger') | |
} | |
} | |
puts :Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Upgrades all files in child directories to the new erb snytax in Rails 3 | |
# Does not upgrade custom concatination helpers | |
# See <http://asciicasts.com/episodes/208-erb-blocks-in-rails-3> for more info | |
# taken from <http://rbjl.net/24-upgrading-to-rails-3-obstacles-and-helper-scripts> | |
patterns = | |
%w| | |
fields_for | |
form_for | |
div_for | |
content_tag_for | |
field_set_tag | |
form_tag | |
remote_form_for | |
form_remote_for | |
form_remote_tag | |
| # don't forget to update remote helpers to hash option: remote => true | |
Dir['**/*.*'].each{ |filename| | |
data = File.read filename | |
File.open(filename,'w'){|f| | |
f.print data.gsub(/<%\s+(#{ patterns*'|' }).*(do|\{)/){ | |
$&.sub '<%', '<%=' | |
} | |
} | |
} | |
puts :Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment