Class: PhobosDBCheckpoint::CLI::Commands
- Inherits:
-
Thor
- Object
- Thor
- PhobosDBCheckpoint::CLI::Commands
- Includes:
- Thor::Actions
- Defined in:
- lib/phobos_db_checkpoint/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
56 57 58 |
# File 'lib/phobos_db_checkpoint/cli.rb', line 56 def self.source_root File.(File.join(File.dirname(__FILE__), '../..')) end |
Instance Method Details
#copy_migrations ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/phobos_db_checkpoint/cli.rb', line 37 def copy_migrations destination_fullpath = File.join(destination_root, [:destination]) generated_migrations = list_migrations(destination_fullpath) FileUtils.mkdir_p(destination_fullpath) .each do || if migration_exists?(generated_migrations, [:name]) say_status('exists', [:name]) else file_path = File.join([:destination], "#{[:number]}_#{[:name]}") template_path = File.join('templates/migrate', [:path]) template(template_path, file_path) end end end |
#init ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phobos_db_checkpoint/cli.rb', line 19 def init create_file('Rakefile') unless File.exist?(File.join(destination_root, 'Rakefile')) prepend_to_file 'Rakefile', "require 'phobos_db_checkpoint'\nPhobosDBCheckpoint.load_tasks\n" copy_file 'templates/database.yml.example', 'config/database.yml' cmd = self.class.new cmd.destination_root = destination_root cmd.invoke(:copy_migrations) create_file('phobos_boot.rb') unless File.exist?(File.join(destination_root, 'phobos_boot.rb')) append_to_file 'phobos_boot.rb', File.read(phobos_boot_template) end |
#version ⇒ Object
14 15 16 |
# File 'lib/phobos_db_checkpoint/cli.rb', line 14 def version puts PhobosDBCheckpoint::VERSION end |