class Rails::Generators::EncryptionKeyFileGenerator

def ignore_key_file(key_path, ignore: key_ignore(key_path))

def ignore_key_file(key_path, ignore: key_ignore(key_path))
  if File.exist?(".gitignore")
    unless File.read(".gitignore").include?(ignore)
      log "Ignoring #{key_path} so it won't end up in Git history:"
      log ""
      append_to_file ".gitignore", ignore
      log ""
    end
  else
    log "IMPORTANT: Don't commit #{key_path}. Add this to your ignore file:"
    log ignore, :on_green
    log ""
  end
end