Sha256: 75e788fc25efa41346f8674e7796e2ed3bcc306c73a323b88fef302d27a9ac91

Contents?: true

Size: 841 Bytes

Versions: 48

Compression:

Stored size: 841 Bytes

Contents

require 'awesome_print'

# Monkey patch for AwesomePrint + objects that implement '=='.
# Available in awesome-print 1.6, but requires a cross-platform update.
module AwesomePrint
  class Formatter
    def awesome_self(object, type)
      if @options[:raw] && object.instance_variables.any?
        awesome_object(object)
      elsif object.respond_to?(:to_hash)
        awesome_hash(object.to_hash)
      else
        colorize(object.inspect.to_s, type)
      end
    end
  end
end

module Kernel
  # Patch for BasicObject inspections.
  # https://github.com/awesome-print/awesome_print/pull/253
  def ap(object, options = {})
    if object_id
      begin
        puts object.ai(options)
      rescue NoMethodError => _
        puts "(Object doesn't support #inspect)"
      end

      object unless AwesomePrint.console?
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
run_loop-2.5.1 lib/run_loop/patches/awesome_print.rb
run_loop-2.5.0 lib/run_loop/patches/awesome_print.rb
run_loop-2.4.1 lib/run_loop/patches/awesome_print.rb
run_loop-2.4.0 lib/run_loop/patches/awesome_print.rb
run_loop-2.3.1 lib/run_loop/patches/awesome_print.rb
run_loop-2.3.0 lib/run_loop/patches/awesome_print.rb
run_loop-2.2.4 lib/run_loop/patches/awesome_print.rb
run_loop-2.2.3 lib/run_loop/patches/awesome_print.rb