Class: Rails::Generators::DevcontainerGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/rails/devcontainer/devcontainer_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

base_root, class_option, default_source_root, desc, exit_on_failure?, hide!, hook_for, inherited, namespace, remove_hook_for, source_root

Methods included from Actions

#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Instance Method Details

#create_devcontainerObject



37
38
39
40
41
42
43
# File 'lib/rails/generators/rails/devcontainer/devcontainer_generator.rb', line 37

def create_devcontainer
  empty_directory ".devcontainer"

  template "devcontainer/devcontainer.json", ".devcontainer/devcontainer.json"
  template "devcontainer/Dockerfile", ".devcontainer/Dockerfile"
  template "devcontainer/compose.yaml", ".devcontainer/compose.yaml"
end

#update_application_system_test_caseObject



45
46
47
48
49
50
51
52
# File 'lib/rails/generators/rails/devcontainer/devcontainer_generator.rb', line 45

def update_application_system_test_case
  return unless options[:system_test]

  system_test_case_path = File.expand_path "test/application_system_test_case.rb", destination_root
  return unless File.exist? system_test_case_path

  gsub_file(system_test_case_path, /^\s*driven_by\b.*/, system_test_configuration)
end

#update_database_ymlObject



54
55
56
57
58
59
# File 'lib/rails/generators/rails/devcontainer/devcontainer_generator.rb', line 54

def update_database_yml
  # Only postgresql has devcontainer specific configuration, so only update database.yml if we are using postgres
  return unless options[:database] == "postgresql"

  template("config/databases/#{options[:database]}.yml", "config/database.yml")
end