Module: SpiritHands::Print
- Defined in:
- lib/spirit_hands/print.rb
Constant Summary collapse
- PRINT_FUNCTION =
->(_output, value, _pry_) do ::SpiritHands::Print.print(_output, value, _pry_) end
Class Method Summary collapse
- .hirb_unicode_enabled? ⇒ Boolean
- .install! ⇒ Object
- .pretty(value) ⇒ Object
- .print(_output, value, _pry_) ⇒ Object
Class Method Details
.hirb_unicode_enabled? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/spirit_hands/print.rb', line 23 def hirb_unicode_enabled? ::Hirb::Formatter.dynamic_config.keys.any? do |key| if opts = ::Hirb::Formatter.dynamic_config[key][:options] opts && opts[:unicode] end end end |
.install! ⇒ Object
8 9 10 |
# File 'lib/spirit_hands/print.rb', line 8 def install! ::Pry.config.print = PRINT_FUNCTION end |
.pretty(value) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spirit_hands/print.rb', line 12 def pretty(value) if ::SpiritHands.awesome_print require 'awesome_print' unless defined?(AwesomePrint) opts = { :indent => ::SpiritHands.value_indent } opts[:plain] = true if !SpiritHands.color value.ai(opts) else value.inspect end end |
.print(_output, value, _pry_) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/spirit_hands/print.rb', line 31 def print(_output, value, _pry_) if ::Hirb.enabled? setup_hirb_unicode return if ::Hirb::View.view_or_page_output(value) end _pry_.pager.open do |pager| pager.print ::SpiritHands.value_prompt pager.puts pretty(value) end end |