Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Last active April 23, 2019 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save invisiblefunnel/8621409 to your computer and use it in GitHub Desktop.
Save invisiblefunnel/8621409 to your computer and use it in GitHub Desktop.
Rake task for renaming a Rails app
desc "Rename this application"
task :rename, [:name] => :environment do |t, args|
files = Dir.glob(%w(rb yml).map{ |ext| Rails.root.join("**/*.#{ext}") } + %w(Rakefile))
before = Rails.application.class.name.split('::').first
after = args.name or raise "Pass a new name as an argument: $ rake rename[MyCivicApp]"
files.each do |file|
# Swap in the new name
renamed = File.read(file).gsub(/#{before}/, after).gsub(/#{before.underscore}/, after.underscore)
# Write the updated contents
File.write(file, renamed)
end
end
@ravindart2011
Copy link

pllz send me company names updated code

@ravindart2011
Copy link

using rake task

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