Class: Rails::Generators::Db::System::ChangeGenerator
- Inherits:
-
Base
- Object
- Thor::Group
- Base
- Rails::Generators::Db::System::ChangeGenerator
show all
- Includes:
- AppName
- Defined in:
- lib/rails/generators/rails/db/system/change/change_generator.rb
Overview
Constant Summary
collapse
- BASE_PACKAGES =
%w( curl libvips )
- BUILD_PACKAGES =
%w( build-essential git )
Constants included
from AppName
AppName::RESERVED_NAMES
Class Method Summary
collapse
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, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor
Constructor Details
Returns a new instance of ChangeGenerator.
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 25
def initialize(*)
super
unless Database::DATABASES.include?(options[:to])
raise Error, "Invalid value for --to option. Supported preconfigurations are: #{Database::DATABASES.join(", ")}."
end
opt = options.dup
opt[:database] ||= opt[:to]
self.options = opt.freeze
end
|
Class Method Details
.default_generator_root ⇒ Object
20
21
22
23
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 20
def self.default_generator_root
path = File.expand_path(File.join(base_name, "app"), base_root)
path if File.exist?(path)
end
|
Instance Method Details
#edit_database_config ⇒ Object
37
38
39
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 37
def edit_database_config
template("config/databases/#{options[:database]}.yml", "config/database.yml")
end
|
#edit_devcontainer_files ⇒ Object
55
56
57
58
59
60
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 55
def edit_devcontainer_files
return unless devcontainer?
edit_devcontainer_json
edit_compose_yaml
end
|
#edit_dockerfile ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 47
def edit_dockerfile
dockerfile_path = File.expand_path("Dockerfile", destination_root)
return unless File.exist?(dockerfile_path)
gsub_file("Dockerfile", all_docker_bases_regex, docker_base_packages(database.base_package))
gsub_file("Dockerfile", all_docker_builds_regex, docker_build_packages(database.build_package))
end
|
#edit_gemfile ⇒ Object
41
42
43
44
45
|
# File 'lib/rails/generators/rails/db/system/change/change_generator.rb', line 41
def edit_gemfile
name, version = database.gem
gsub_file("Gemfile", all_database_gems_regex, name)
gsub_file("Gemfile", gem_entry_regex_for(name), gem_entry_for(name, *version))
end
|