Class: GeonamesDump::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- GeonamesDump::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/geonames_dump/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(path) ⇒ Object
33 34 35 36 |
# File 'lib/generators/geonames_dump/install_generator.rb', line 33 def self.next_migration_number(path) sleep 1 # OPTIMIZE: there might be a better way to do this ... @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i.to_s end |
Instance Method Details
#copy_migrations_files ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/geonames_dump/install_generator.rb', line 12 def copy_migrations_files Dir.glob(File.join(File.(File.join('..', 'templates', 'db', 'migrate'), __FILE__), '*')).each do |full_path| file = File.basename(full_path, File.extname(full_path)) migration_folder = File.join('db', 'migrate') if self.class.migration_exists?(migration_folder, file) say_status("skip", "Migration #{file} already exists", :yellow) else srcdst = File.join(migration_folder, "#{file}.rb") migration_template(srcdst, srcdst) end end end |
#copy_models_files ⇒ Object
26 27 28 29 30 31 |
# File 'lib/generators/geonames_dump/install_generator.rb', line 26 def copy_models_files Dir.glob(File.join(File.(File.join('..', 'templates', 'app', 'models'), __FILE__), '*')).each do |full_path| file = File.basename(full_path, File.extname(full_path)) copy_file File.join('app', 'models', "#{file}.rb") end end |