module Xi::REPL
Constants
- CONFIG_PATH
- DEFAULT_INIT_SCRIPT
- HISTORY_FILE
- INIT_SCRIPT_FILE
Public Instance Methods
configure()
click to toggle source
# File lib/xi/repl.rb, line 25 def configure prepare_config_dir if ENV["INSIDE_EMACS"] Pry.config.correct_indent = false Pry.config.pager = false Pry.config.prompt = [ proc { "" }, proc { "" }] else Pry.config.prompt = [ proc { "xi> " }, proc { "..> " }] end Pry.config.history.file = history_path Pry.hooks.add_hook(:after_eval, "check_for_errors") do |result, pry| more_errors = ErrorLog.instance.more_errors? ErrorLog.instance.each do |msg| puts red("Error: #{msg}") end puts red("There were more errors...") if more_errors end end
history_path()
click to toggle source
# File lib/xi/repl.rb, line 63 def history_path File.join(CONFIG_PATH, HISTORY_FILE) end
init_script_path()
click to toggle source
# File lib/xi/repl.rb, line 67 def init_script_path File.join(CONFIG_PATH, INIT_SCRIPT_FILE) end
load_init_script()
click to toggle source
# File lib/xi/repl.rb, line 51 def load_init_script require(init_script_path) end
prepare_config_dir()
click to toggle source
# File lib/xi/repl.rb, line 55 def prepare_config_dir FileUtils.mkdir_p(CONFIG_PATH) unless File.exists?(init_script_path) File.write(init_script_path, DEFAULT_INIT_SCRIPT) end end
red(string)
click to toggle source
# File lib/xi/repl.rb, line 47 def red(string) "\e[31m\e[1m#{string}\e[22m\e[0m" end
start(irb: false)
click to toggle source
# File lib/xi/repl.rb, line 18 def start(irb: false) configure load_init_script irb ? IRB.start : Pry.start end