Class: Binding

Inherits:
Object
  • Object
show all
Defined in:
lib/girb.rb

Overview

binding.girb サポート

Instance Method Summary collapse

Instance Method Details

#girb(show_code: true) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/girb.rb', line 54

def girb(show_code: true)
  require "irb"
  Girb.setup! unless defined?(IRB::Command::Qq)

  # .girbrcを読み込む(プロバイダー設定)
  Girb::GirbrcLoader.load_girbrc unless Girb.configuration&.provider

  # キーバインドを再設定(IRBセッション開始前に確実に設定)
  Girb::IrbIntegration.install_ai_keybinding

  # 標準のbinding.irbと同じ方法でIRBを起動
  IRB.setup(source_location[0], argv: []) unless IRB.initialized?
  workspace = IRB::WorkSpace.new(self)
  STDOUT.print(workspace.code_around_binding) if show_code

  binding_irb = IRB::Irb.new(workspace, from_binding: true)
  binding_irb.context.irb_path = File.expand_path(source_location[0])
  binding_irb.run(IRB.conf)
  binding_irb.debug_break
end