Class: Rails::Command::EncryptedCommand
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base ,
Thor
|
|
Instance Chain:
|
|
Inherits: |
Rails::Command::Base
|
Defined in: | railties/lib/rails/commands/encrypted/encrypted_command.rb |
Class Attribute Summary
Base
- Inherited
.bin, .bin?, | |
.engine? | Returns true when the app is a Rails engine. |
.exit_on_failure? |
Class Method Summary
Base
- Inherited
.banner, | |
.base_name | Sets the base_name taking into account the current class namespace. |
.command_name | Return command name without namespaces. |
.default_command_root | Default file root to place extra files a command might need, placed one folder above the command file. |
.desc | Tries to get the description from a USAGE file one folder above the command root. |
.executable, | |
.hide_command! | Convenience method to hide this command from the available ones when running rails command. |
.namespace | Convenience method to get the namespace from the class name. |
.printing_commands, | |
.usage_path | Path to lookup a USAGE description in a file. |
.create_command | Allow the command method to be called perform. |
.namespaced_name, .resolve_path, .class_usage, | |
.help | Override Thor’s class-level help to also show the USAGE. |
.inherited, .perform |
Instance Method Summary
- #edit
- #show
- #change_encrypted_configuration_in_system_editor private
- #content_path private
- #encrypted_configuration private
- #encrypted_file_generator private
- #encryption_key_file_generator private
- #ensure_encrypted_configuration_has_been_added private
- #ensure_encryption_key_has_been_added private
- #key_path private
- #missing_encrypted_configuration_message private
- #warn_if_encrypted_configuration_is_invalid private
Helpers::Editor
- Included
Actions
- Included
#boot_application!, #load_environment_config!, | |
#load_generators | See additional method definition at line 36. |
#load_tasks | See additional method definition at line 31. |
#require_application!, | |
#set_application_directory! | Change to the application’s path if there is no |
Instance Method Details
#change_encrypted_configuration_in_system_editor (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 55
def change_encrypted_configuration_in_system_editor using_system_editor do encrypted_configuration.change { |tmp_path| system_editor(tmp_path) } say "File encrypted and saved." warn_if_encrypted_configuration_is_invalid end rescue ActiveSupport::EncryptedFile::MissingKeyError => error say error. rescue ActiveSupport::MessageEncryptor::InvalidMessage say "Couldn't decrypt #{content_path}. Perhaps you passed the wrong key?" end
#content_path (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 33
def content_path @content_path ||= args[0] end
#edit
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 16
def edit(*) load_environment_config! ensure_encryption_key_has_been_added ensure_encrypted_configuration_has_been_added change_encrypted_configuration_in_system_editor end
#encrypted_configuration (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 41
def encrypted_configuration @encrypted_configuration ||= Rails.application.encrypted(content_path, key_path: key_path) end
#encrypted_file_generator (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 82
def encrypted_file_generator require "rails/generators" require "rails/generators/rails/encrypted_file/encrypted_file_generator" Rails::Generators::EncryptedFileGenerator.new end
#encryption_key_file_generator (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 75
def encryption_key_file_generator require "rails/generators" require "rails/generators/rails/encryption_key_file/encryption_key_file_generator" Rails::Generators::EncryptionKeyFileGenerator.new end
#ensure_encrypted_configuration_has_been_added (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 51
def ensure_encrypted_configuration_has_been_added encrypted_file_generator.add_encrypted_file_silently(content_path, key_path) end
#ensure_encryption_key_has_been_added (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 45
def ensure_encryption_key_has_been_added return if encrypted_configuration.key? encryption_key_file_generator.add_key_file(key_path) encryption_key_file_generator.ignore_key_file(key_path) end
#key_path (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 37
def key_path [:key] end
#missing_encrypted_configuration_message (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 89
def if !encrypted_configuration.key? "Missing '#{key_path}' to decrypt data. See `#{executable(:help)}`" else "File '#{content_path}' does not exist. Use `#{executable(:edit)} #{content_path}` to change that." end end
#show
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 26
def show(*) load_environment_config! say encrypted_configuration.read.presence || end
#warn_if_encrypted_configuration_is_invalid (private)
[ GitHub ]# File 'railties/lib/rails/commands/encrypted/encrypted_command.rb', line 67
def warn_if_encrypted_configuration_is_invalid encrypted_configuration.validate! rescue ActiveSupport::EncryptedConfiguration::InvalidContentError => error say "WARNING: #{error.}", :red say "" say "Your application will not be able to load '#{content_path}' until the error has been fixed.", :red end