Sha256: f203b30841cdda4348fffdd14685496de2d82d0d0e789eaca2fca79a3cdd6b06

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

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

module Arql
  class Repl
    def initialize
      Pry.config.prompt = Pry::Prompt.new("", "", prompt)
      main_object.pry
    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, _|
         if obj == main_object && nest_level == 0
           nest_level_prompt = ''
         else
           nest_level_prompt = "(#{obj}:#{nest_level})"
         end
         "%s#{Rainbow('@').green}%s#{nest_level_prompt} %s " % [Rainbow('ARQL').red, Rainbow(App.prompt).yellow, Rainbow('❯').green]
       end]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arql-0.1.32 lib/arql/repl.rb
arql-0.1.31 lib/arql/repl.rb