Sha256: 67f00e24b9c3167996b753c73a660370a2abc424906fb6df258e5f22c4d10e23

Contents?: true

Size: 771 Bytes

Versions: 136

Compression:

Stored size: 771 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)
          ActiveSupport::EncryptedFile.new(
            content_path: file_path,
            key_path: key_path,
            env_key: "RAILS_MASTER_KEY",
            raise_if_missing_key: true
          ).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

136 entries across 131 versions & 9 rubygems

Version Path
omg-railties-8.0.0.alpha9 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
omg-railties-8.0.0.alpha8 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
omg-railties-8.0.0.alpha7 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
omg-railties-8.0.0.alpha4 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
omg-railties-8.0.0.alpha3 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.1.4 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.2.1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.2.0 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.2.0.rc1 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.4/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.1.3.4/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.2.0.beta3 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/railties-7.1.3.4/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.2.0.beta2 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.1.3.4 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-7.0.8.4 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb
railties-6.1.7.8 lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb