Class: Rails::Generators::CredentialsGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/rails/credentials/credentials_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, #after_bundle, #capify!, #environment, #gem, #gem_group, #generate, #git, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Instance Method Details

#add_credentials_fileObject



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

def add_credentials_file
  unless credentials.content_path.exist?
    template = credentials_template

    say "Adding #{credentials.content_path} to store encrypted credentials."
    say ""
    say "The following content has been encrypted with the Rails master key:"
    say ""
    say template, :on_green
    say ""

    add_credentials_file_silently(template)

    say "You can edit encrypted credentials with `bin/rails credentials:edit`."
    say ""
  end
end

#add_credentials_file_silently(template = nil) ⇒ Object



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

def add_credentials_file_silently(template = nil)
  unless credentials.content_path.exist?
    credentials.write(credentials_template)
  end
end