Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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/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
Add Comment
Please, Sign In to add comment