Class: Rails::Command::CredentialsCommand

Inherits:
Base
  • Object
show all
Includes:
EnvironmentArgument, Diffing, Helpers::Editor
Defined in:
railties/lib/rails/commands/credentials/credentials_command.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Diffing

Constant Summary

Constants included from Diffing

Diffing::GITATTRIBUTES_ENTRY

Instance Method Summary collapse

Methods included from Diffing

#disenroll_project_from_credentials_diffing, #enroll_project_in_credentials_diffing, #ensure_diffing_driver_is_configured

Methods inherited from Base

banner, base_name, class_usage, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, help, hide_command!, inherited, namespace, perform, printing_commands, usage_path

Methods included from Actions

#boot_application!, #load_environment_config!, #load_generators, #load_tasks, #require_application!, #set_application_directory!

Instance Method Details

#diff(content_path = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'railties/lib/rails/commands/credentials/credentials_command.rb', line 46

def diff(content_path = nil)
  if @content_path = content_path
    self.environment = extract_environment_from_path(content_path)
    load_environment_config!

    say credentials.read.presence || credentials.content_path.read
  else
    disenroll_project_from_credentials_diffing if options[:disenroll]
    enroll_project_in_credentials_diffing if options[:enroll]
  end
rescue ActiveSupport::MessageEncryptor::InvalidMessage
  say credentials.content_path.read
end

#editObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'railties/lib/rails/commands/credentials/credentials_command.rb', line 18

def edit
  load_environment_config!
  load_generators

  if environment_specified?
    @content_path = "config/credentials/#{environment}.yml.enc" unless config.key?(:content_path)
    @key_path = "config/credentials/#{environment}.key" unless config.key?(:key_path)
  end

  ensure_encryption_key_has_been_added
  ensure_credentials_have_been_added
  ensure_diffing_driver_is_configured

  change_credentials_in_system_editor
end

#showObject



35
36
37
38
39
# File 'railties/lib/rails/commands/credentials/credentials_command.rb', line 35

def show
  load_environment_config!

  say credentials.read.presence || missing_credentials_message
end