Module: ActionThrottler::Rake::ClassMethods
- Defined in:
- lib/tasks/rake_helper.rb
Instance Method Summary collapse
-
#copy_file(orig_path, dest_path, message = "") ⇒ Object
Copies a file.
-
#copy_initializer_file(message = "") ⇒ Object
Copies the initializer file to ‘config/initializers`.
-
#copy_migration_file(message = "") ⇒ Object
Copies the migration file to ‘db/migrate`.
Instance Method Details
#copy_file(orig_path, dest_path, message = "") ⇒ Object
Copies a file
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tasks/rake_helper.rb', line 43 def copy_file(orig_path, dest_path, = "") dest_path = "#{Rails.root}/#{dest_path}" if File.exists?(dest_path) puts "'#{dest_path}' already exists, therefore it is skipped." else FileUtils.cp(orig_path, dest_path) puts unless .nil? end end |
#copy_initializer_file(message = "") ⇒ Object
Copies the initializer file to ‘config/initializers`
28 29 30 31 32 33 34 35 36 |
# File 'lib/tasks/rake_helper.rb', line 28 def copy_initializer_file( = "") orig_dir = "#{File.dirname(__FILE__)}/initializer/" orig_file = Dir.entries(orig_dir).last orig_path = orig_dir + orig_file dest_path = "config/initializers/#{orig_file}" copy_file(orig_path, dest_path, ) end |
#copy_migration_file(message = "") ⇒ Object
Copies the migration file to ‘db/migrate`
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tasks/rake_helper.rb', line 14 def copy_migration_file( = "") orig_dir = "#{File.dirname(__FILE__)}/migration/" orig_file = Dir.entries(orig_dir).last orig_path = orig_dir + orig_file prefix = Rails::Generator::Commands::Base.new(nil).send(:next_migration_string) dest_path = "db/migrate/#{prefix}_#{orig_file}" copy_file(orig_path, dest_path, ) end |