Skip to content

Instantly share code, notes, and snippets.

@rujmah
Forked from ebot/rename.rake
Created December 13, 2012 14:40
Show Gist options
  • Save rujmah/4276769 to your computer and use it in GitHub Desktop.
Save rujmah/4276769 to your computer and use it in GitHub Desktop.
namespace 'rails' do
desc 'Renames the current app'
task 'rename' do
# Get the new name
new_name = ENV["NEW_NAME"].capitalize || nil
if new_name.nil?
puts "\nYou must pass in a new name"
exit
end
# Get the current name of the app
current_name = IO.readlines('config/routes.rb').first.split('::')[0]
puts "Renaming #{current_name} to #{new_name}"
files = [ 'config.ru',
'rakefile',
'config/application.rb',
'config/environment.rb',
'config/mongoid.yml',
'config/routes.rb',
'config/environments/development.rb',
'config/environments/test.rb',
'config/environments/production.rb',
'config/initializers/secret_token.rb',
'config/initializers/session_store.rb' ]
files.each do |file|
puts " Updating #{file}"
input = IO.read(file)
output = File.new file, 'w'
output << input.gsub(current_name, new_name)
output.close
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment