Sha256: ba781cb86f71bb8c00293575cdb9cfcda119a9cef0f6642bb23e64a981b994eb

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

desc "Create an app with the provided name (and optional SDK version)"
namespace :rails do

	task :rename, :new_name, :mode do |t, args|
		old_name = Rails.application.class.name.sub(/::Application/,'')
		new_name = args[:new_name].camelize

		command = "grep -lr -e '#{old_name}' *"
		if args[:mode] == 'confirm'
			command += " | xargs sed -i '' 's/#{old_name}/#{new_name}/g'"
		else
			puts "#{old_name} -> #{new_name}, these files will be affected, append 'confirm' to apply"
		end

		puts `#{command}`

		new_name_saved = File.read('config.ru').split(/run |::Application\n/).last
		puts "Current app name is: #{new_name_saved}"
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_rename-0.0.1 lib/tasks/rails_rename.rake