Sha256: dc4fa7f5c1606d2ac9b0f05847499e37dc20b61cd16f6c7430f444b1eb6b4440

Contents?: true

Size: 739 Bytes

Versions: 25

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/base"
require "active_support/encrypted_file"

module Rails
  module Generators
    class EncryptedFileGenerator < Base # :nodoc:
      def add_encrypted_file_silently(file_path, key_path, template = encrypted_file_template)
        unless File.exist?(file_path)
          setup = { content_path: file_path, key_path: key_path, env_key: "RAILS_MASTER_KEY", raise_if_missing_key: true }
          ActiveSupport::EncryptedFile.new(setup).write(template)
        end
      end

      private
        def encrypted_file_template
          <<~YAML
            # aws:
            #   access_key_id: 123
            #   secret_access_key: 345

          YAML
        end
    end
  end
end

Version data entries

25 entries across 23 versions & 5 rubygems

Version Path
railties-6.0.2.2 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.2.1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.2 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.2.rc2 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.2.rc1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.1.rc1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.0.0 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb