Class: Rails::Generators::MasterKeyGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/rails/master_key/master_key_generator.rb

Overview

:nodoc:

Constant Summary collapse

MASTER_KEY_PATH =
Pathname.new("config/master.key")

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, #after_bundle, #capify!, #environment, #gem, #gem_group, #generate, #git, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Instance Method Details

#add_master_key_fileObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rails/generators/rails/master_key/master_key_generator.rb', line 13

def add_master_key_file
  unless MASTER_KEY_PATH.exist?
    key = ActiveSupport::EncryptedFile.generate_key

    log "Adding #{MASTER_KEY_PATH} to store the master encryption key: #{key}"
    log ""
    log "Save this in a password manager your team can access."
    log ""
    log "If you lose the key, no one, including you, can access anything encrypted with it."

    log ""
    add_master_key_file_silently(key)
    log ""
  end
end

#add_master_key_file_silently(key = nil) ⇒ Object



29
30
31
32
33
# File 'lib/rails/generators/rails/master_key/master_key_generator.rb', line 29

def add_master_key_file_silently(key = nil)
  unless MASTER_KEY_PATH.exist?
    key_file_generator.add_key_file_silently(MASTER_KEY_PATH, key)
  end
end

#ignore_master_key_fileObject



35
36
37
# File 'lib/rails/generators/rails/master_key/master_key_generator.rb', line 35

def ignore_master_key_file
  key_file_generator.ignore_key_file(MASTER_KEY_PATH, ignore: key_ignore)
end

#ignore_master_key_file_silentlyObject



39
40
41
# File 'lib/rails/generators/rails/master_key/master_key_generator.rb', line 39

def ignore_master_key_file_silently
  key_file_generator.ignore_key_file_silently(MASTER_KEY_PATH, ignore: key_ignore)
end