Module: AwesomePrint

Defined in:
lib/awesome_print/version.rb,
lib/awesome_print/colorize.rb,
lib/awesome_print/formatter.rb,
lib/awesome_print/inspector.rb,
lib/awesome_print/ext/ripple.rb,
lib/awesome_print/ext/sequel.rb,
lib/awesome_print/formatters.rb,
lib/awesome_print/indentator.rb,
lib/awesome_print/ext/mongoid.rb,
lib/awesome_print/ext/ostruct.rb,
lib/awesome_print/ext/nokogiri.rb,
lib/awesome_print/ext/nobrainer.rb,
lib/awesome_print/core_ext/logger.rb,
lib/awesome_print/custom_defaults.rb,
lib/awesome_print/ext/action_view.rb,
lib/awesome_print/ext/mongo_mapper.rb,
lib/awesome_print/ext/active_record.rb,
lib/awesome_print/ext/active_support.rb,
lib/awesome_print/formatters/dir_formatter.rb,
lib/awesome_print/formatters/base_formatter.rb,
lib/awesome_print/formatters/file_formatter.rb,
lib/awesome_print/formatters/hash_formatter.rb,
lib/awesome_print/formatters/array_formatter.rb,
lib/awesome_print/formatters/class_formatter.rb,
lib/awesome_print/formatters/method_formatter.rb,
lib/awesome_print/formatters/object_formatter.rb,
lib/awesome_print/formatters/simple_formatter.rb,
lib/awesome_print/formatters/struct_formatter.rb

Overview

Copyright © 2010-2016 Michael Dvorkin and contributors

Awesome Print is freely distributable under the terms of MIT license. See LICENSE file or www.opensource.org/licenses/mit-license.php


Defined Under Namespace

Modules: ActionView, ActiveRecord, ActiveSupport, Colorize, Formatters, Logger, MongoMapper, Mongoid, NoBrainer, Nokogiri, OpenStruct, Ripple, Sequel Classes: Formatter, Indentator, Inspector

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.defaultsObject

Returns the value of attribute defaults.



3
4
5
# File 'lib/awesome_print/custom_defaults.rb', line 3

def defaults
  @defaults
end

.force_colorsObject

Returns the value of attribute force_colors.



3
4
5
# File 'lib/awesome_print/custom_defaults.rb', line 3

def force_colors
  @force_colors
end

Class Method Details

.console?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/awesome_print/custom_defaults.rb', line 12

def console?
  boolean(defined?(IRB) || defined?(Pry))
end

.diet_rbObject



20
21
22
23
24
25
26
# File 'lib/awesome_print/custom_defaults.rb', line 20

def diet_rb
  IRB.formatter = Class.new(IRB::Formatter) do
    def inspect_object(object)
      object.ai
    end
  end.new
end

.force_colors!(value = true) ⇒ Object

Class accessor to force colorized output (ex. forked subprocess where TERM might be dumb).




8
9
10
# File 'lib/awesome_print/custom_defaults.rb', line 8

def force_colors!(value = true)
  @force_colors = value
end

.irb!Object



38
39
40
41
42
# File 'lib/awesome_print/custom_defaults.rb', line 38

def irb!
  return unless defined?(IRB)

  IRB.version.include?('DietRB') ? diet_rb : usual_rb
end

.pry!Object



44
45
46
# File 'lib/awesome_print/custom_defaults.rb', line 44

def pry!
  Pry.print = proc { |output, value| output.puts value.ai } if defined?(Pry)
end

.rails_console?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/awesome_print/custom_defaults.rb', line 16

def rails_console?
  console? && boolean(defined?(Rails::Console) || ENV['RAILS_ENV'])
end

.usual_rbObject



28
29
30
31
32
33
34
35
36
# File 'lib/awesome_print/custom_defaults.rb', line 28

def usual_rb
  IRB::Irb.class_eval do
    def output_value(*args)
      ap @context.last_value
    rescue NoMethodError
      puts "(Object doesn't support #ai)"
    end
  end
end

.versionObject



7
8
9
# File 'lib/awesome_print/version.rb', line 7

def self.version
  '1.9.2'
end