Sha256: ab266600d975996398c67c7d7baaa3def34498cf77409c82fc3b1a87e1b18092

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

Contents

require 'pry'
require 'pry-byebug'
require 'arql/commands'
require 'rainbow'

module Arql
  class Repl
    def initialize
      Pry.config.prompt = Pry::Prompt.new("", "", prompt)
      Pry.start
    end

    def main_object
      return @main if @main
      @main = Object.new
      @main.instance_eval do
        def inspect
          to_s
        end
        def to_s
          "main"
        end
      end
      @main
    end

    def prompt
      [proc do |obj, nest_level, pry_instance|
         if obj == main_object && nest_level == 0
           nest_level_prompt = ''
         else
           nest_level_prompt = if nest_level.zero?
                                 "(#{obj})"
                               else
                                 "(#{obj}:#{nest_level})"
                               end
         end
         "%s#{Rainbow('@').green}%s#{nest_level_prompt} [%d] %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, pry_instance.input_ring.count, Rainbow('❯').green]
       end]
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
arql-0.3.3 lib/arql/repl.rb
arql-0.3.2 lib/arql/repl.rb
arql-0.3.1 lib/arql/repl.rb
arql-0.3.0 lib/arql/repl.rb
arql-0.2.14 lib/arql/repl.rb
arql-0.2.13 lib/arql/repl.rb
arql-0.2.12 lib/arql/repl.rb
arql-0.2.11 lib/arql/repl.rb
arql-0.2.10 lib/arql/repl.rb
arql-0.2.9 lib/arql/repl.rb
arql-0.2.8 lib/arql/repl.rb
arql-0.2.7 lib/arql/repl.rb
arql-0.2.6 lib/arql/repl.rb
arql-0.2.5 lib/arql/repl.rb
arql-0.2.4 lib/arql/repl.rb
arql-0.2.3 lib/arql/repl.rb
arql-0.2.2 lib/arql/repl.rb