Sha256: 206bae2037b642145fafc4941c65763c5f35f8c43b36db811214d8ce97d53e11

Contents?: true

Size: 979 Bytes

Versions: 166

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

require "active_support/encrypted_file"

module Rails
  module Command
    module Helpers
      module Editor
        private
          def ensure_editor_available(command:)
            if ENV["EDITOR"].to_s.empty?
              say "No $EDITOR to open file in. Assign one like this:"
              say ""
              say %(EDITOR="mate --wait" #{command})
              say ""
              say "For editors that fork and exit immediately, it's important to pass a wait flag,"
              say "otherwise the credentials will be saved immediately with no chance to edit."

              false
            else
              true
            end
          end

          def catch_editing_exceptions
            yield
          rescue Interrupt
            say "Aborted changing file: nothing saved."
          rescue ActiveSupport::EncryptedFile::MissingKeyError => error
            say error.message
          end
      end
    end
  end
end

Version data entries

166 entries across 153 versions & 12 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/railties-7.0.8.6/lib/rails/command/helpers/editor.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/railties-7.0.8.7/lib/rails/command/helpers/editor.rb
railties-7.0.8.7 lib/rails/command/helpers/editor.rb
railties-7.0.8.6 lib/rails/command/helpers/editor.rb
railties-6.1.7.10 lib/rails/command/helpers/editor.rb
railties-6.1.7.9 lib/rails/command/helpers/editor.rb
railties-7.0.8.5 lib/rails/command/helpers/editor.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.4/lib/rails/command/helpers/editor.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/command/helpers/editor.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/command/helpers/editor.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/railties-7.0.5.1/lib/rails/command/helpers/editor.rb
railties-7.0.8.4 lib/rails/command/helpers/editor.rb
railties-6.1.7.8 lib/rails/command/helpers/editor.rb
railties-7.0.8.1 lib/rails/command/helpers/editor.rb
railties-6.1.7.7 lib/rails/command/helpers/editor.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.2.3/lib/rails/command/helpers/editor.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-7.0.3.1/lib/rails/command/helpers/editor.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/command/helpers/editor.rb
railties-7.0.8 lib/rails/command/helpers/editor.rb
railties-7.0.7.2 lib/rails/command/helpers/editor.rb