Module: Ripl::ColorResult

Defined in:
lib/ripl/color_result.rb

Constant Summary collapse

VERSION =
'0.4.1'

Instance Method Summary collapse

Instance Method Details

#before_loopObject



7
8
9
10
11
12
13
# File 'lib/ripl/color_result.rb', line 7

def before_loop
  super
  if Ripl.config[:color_result_engine] == :default
    require 'wirb' unless defined?(Wirb)
    Ripl.config[:color_result_default_schema].merge! Wirb.schema
  end
end

#format_result(result) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ripl/color_result.rb', line 15

def format_result(result)
  return super if !config[:color_result_engine]

  @result_prompt + case config[:color_result_engine].to_sym
  when :coderay
    require 'coderay' unless defined?(CodeRay)
    CodeRay.scan( result.inspect, :ruby ).term
  when :ap, :awesome_print
    require 'ap' unless defined?(AwesomePrint)
    result.awesome_inspect( config[:color_result_ap_options] || {} )
  else # :default
    require 'wirb' unless defined?(Wirb)
    Wirb.start unless Wirb.running?
    Wirb.colorize_result result.inspect, Ripl.config[:color_result_default_schema]
  end
end