Class: Rage::CLINewAppGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/rage/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



368
369
370
# File 'lib/rage/cli.rb', line 368

def self.source_root
  File.expand_path("templates", __dir__)
end

Instance Method Details

#copy_filesObject



380
381
382
# File 'lib/rage/cli.rb', line 380

def copy_files
  inject_templates
end

#create_directoryObject



376
377
378
# File 'lib/rage/cli.rb', line 376

def create_directory
  empty_directory(path)
end

#install_databaseObject



384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/rage/cli.rb', line 384

def install_database
  return unless @use_database

  @app_name = path.tr("-", "_").downcase
  append_to_file "#{path}/Gemfile", <<~RUBY

    gem "#{get_db_gem_name}"
    gem "activerecord"
    gem "standalone_migrations", require: false
  RUBY

  inject_templates("db-templates")
  inject_templates("db-templates/#{database}")
end

#setupObject



372
373
374
# File 'lib/rage/cli.rb', line 372

def setup
  @use_database = !database.nil?
end