Sha256: 59d4ee231b118d07871382700e3b13d610a48295c65d290acb85e4ace5256992

Contents?: true

Size: 769 Bytes

Versions: 25

Compression:

Stored size: 769 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#{nest_level_prompt} %s " % [Rainbow('ARQL').red, Rainbow('❯').green]
       end]
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
arql-0.1.27 lib/arql/repl.rb
arql-0.1.26 lib/arql/repl.rb
arql-0.1.25 lib/arql/repl.rb
arql-0.1.24 lib/arql/repl.rb
arql-0.1.23 lib/arql/repl.rb
arql-0.1.22 lib/arql/repl.rb
arql-0.1.21 lib/arql/repl.rb
arql-0.1.20 lib/arql/repl.rb
arql-0.1.19 lib/arql/repl.rb
arql-0.1.18 lib/arql/repl.rb
arql-0.1.17 lib/arql/repl.rb
arql-0.1.16 lib/arql/repl.rb
arql-0.1.15 lib/arql/repl.rb
arql-0.1.14 lib/arql/repl.rb
arql-0.1.13 lib/arql/repl.rb
arql-0.1.12 lib/arql/repl.rb
arql-0.1.11 lib/arql/repl.rb
arql-0.1.10 lib/arql/repl.rb
arql-0.1.9 lib/arql/repl.rb
arql-0.1.8 lib/arql/repl.rb