Sha256: 45415de3ea401abd37b84d23c61c762cdd9dfbda665d2643a6ae4d5d591ac8ca

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require "pry"
require "singleton"

module Safeconsole
  class Console
    include Singleton
    include Messages

    extend Commands

    class << self
      attr_accessor :__console_done, :__console_commit

      def run
        print_message(:welcome)
        print_message(:commands)

        SessionWatcher.watch_session! if Safeconsole.watch_session?

        print_message(:session_start)

        loop do
          @__console_done = false
          @__console_commit = false
          print_message(:transaction_start)

          ActiveRecord::Base.transaction do
            binding.pry quiet: true, prompt_name: "safeconsole" # standard:disable Lint/Debugger

            raise ActiveRecord::Rollback unless @__console_commit
          end

          break print_message(:done) if @__console_done

          print_message(:refresh)
          sleep 0.5
        end
      end

      def done!
        @__console_done = true
        @__exit_safeconsole = true
      end

      def done?
        @__console_done
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
safeconsole-1.0.0 lib/safeconsole/console.rb