Module: Looksee::WirbleCompatibility
- Defined in:
- lib/looksee/wirble_compatibility.rb
Defined Under Namespace
Modules: WirbleLoadHook
Class Method Summary collapse
- .hook_into_irb_output_value ⇒ Object
- .hook_into_wirble_colorize ⇒ Object
- .hook_into_wirble_load ⇒ Object
- .hooked_into_irb_output_value? ⇒ Boolean
- .init ⇒ Object
- .wirble_colorizing? ⇒ Boolean
- .wirble_loaded? ⇒ Boolean
Class Method Details
.hook_into_irb_output_value ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/looksee/wirble_compatibility.rb', line 38 def hook_into_irb_output_value IRB::Irb.class_eval do def output_value_with_looksee case @context.last_value when Looksee::LookupPath, Looksee::Help non_color_output_value else output_value_without_looksee end end alias output_value_without_looksee output_value alias output_value output_value_with_looksee end end |
.hook_into_wirble_colorize ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/looksee/wirble_compatibility.rb', line 21 def hook_into_wirble_colorize class << Wirble def colorize_with_looksee(*args) # If this gets called twice, Wirble will fuck up the # aliases. Disable colorizing first to reset them. if WirbleCompatibility.hooked_into_irb_output_value? Wirble::Colorize.disable end colorize_without_looksee(*args) WirbleCompatibility.hook_into_irb_output_value end alias colorize_without_looksee colorize alias colorize colorize_with_looksee end end |
.hook_into_wirble_load ⇒ Object
14 15 16 17 18 19 |
# File 'lib/looksee/wirble_compatibility.rb', line 14 def hook_into_wirble_load unless Object.const_defined?(:Wirble) Object.const_set :Wirble, Module.new end Wirble.send :extend, WirbleLoadHook end |
.hooked_into_irb_output_value? ⇒ Boolean
54 55 56 |
# File 'lib/looksee/wirble_compatibility.rb', line 54 def hooked_into_irb_output_value? IRB::Irb.method_defined?(:output_value_with_looksee) end |
.init ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/looksee/wirble_compatibility.rb', line 58 def init # # How wirble is used: # # * Wirble is required/loaded. Defines Wirble module, with methods like Wirble.colorize. # * Wirble.init is called. Nothing interesting. # * Wirble.colorize is called. Hooks into IRB::Irb.output_value via an alias. # if !wirble_loaded? hook_into_wirble_load elsif !wirble_colorizing? hook_into_wirble_colorize else hook_into_irb_output_value end end |
.wirble_colorizing? ⇒ Boolean
10 11 12 |
# File 'lib/looksee/wirble_compatibility.rb', line 10 def wirble_colorizing? IRB::Irb.method_defined?(:non_color_output_value) end |
.wirble_loaded? ⇒ Boolean
4 5 6 7 8 |
# File 'lib/looksee/wirble_compatibility.rb', line 4 def wirble_loaded? Object.const_defined?(:Wirble) && Wirble.is_a?(Module) && Wirble.respond_to?(:colorize) end |