mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Load necessary files when Rails console is running under Pry
This commit is contained in:
parent
5f00926d80
commit
67cde1be8d
2 changed files with 17 additions and 7 deletions
|
@ -4,8 +4,8 @@
|
||||||
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# AwesomePrint might be loaded implicitly through ~/.irbrc so do nothing
|
# AwesomePrint might be loaded implicitly through ~/.irbrc or ~/.pryrc
|
||||||
# for subsequent requires.
|
# so do nothing for subsequent requires.
|
||||||
#
|
#
|
||||||
unless defined?(AwesomePrint::Inspector)
|
unless defined?(AwesomePrint::Inspector)
|
||||||
%w(array string method object class kernel).each do |file|
|
%w(array string method object class kernel).each do |file|
|
||||||
|
@ -16,13 +16,15 @@ unless defined?(AwesomePrint::Inspector)
|
||||||
require File.dirname(__FILE__) + "/awesome_print/formatter"
|
require File.dirname(__FILE__) + "/awesome_print/formatter"
|
||||||
require File.dirname(__FILE__) + "/awesome_print/version"
|
require File.dirname(__FILE__) + "/awesome_print/version"
|
||||||
require File.dirname(__FILE__) + "/awesome_print/core_ext/logger" if defined?(Logger)
|
require File.dirname(__FILE__) + "/awesome_print/core_ext/logger" if defined?(Logger)
|
||||||
|
#
|
||||||
# Load the following under normal circumstances as well as in Rails
|
# Load the following under normal circumstances as well as in Rails
|
||||||
# console when required from ~/.irbrc.
|
# console when required from ~/.irbrc or ~/.pryrc.
|
||||||
require File.dirname(__FILE__) + "/awesome_print/ext/active_record" if defined?(ActiveRecord) || (defined?(IRB) && ENV['RAILS_ENV'])
|
#
|
||||||
require File.dirname(__FILE__) + "/awesome_print/ext/active_support" if defined?(ActiveSupport) || (defined?(IRB) && ENV['RAILS_ENV'])
|
require File.dirname(__FILE__) + "/awesome_print/ext/active_record" if defined?(ActiveRecord) || AwesomePrint.rails_console?
|
||||||
|
require File.dirname(__FILE__) + "/awesome_print/ext/active_support" if defined?(ActiveSupport) || AwesomePrint.rails_console?
|
||||||
|
#
|
||||||
# Load remaining extensions.
|
# Load remaining extensions.
|
||||||
|
#
|
||||||
require File.dirname(__FILE__) + "/awesome_print/ext/action_view" if defined?(ActionView::Base)
|
require File.dirname(__FILE__) + "/awesome_print/ext/action_view" if defined?(ActionView::Base)
|
||||||
require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper)
|
require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper)
|
||||||
require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid)
|
require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid)
|
||||||
|
|
|
@ -14,6 +14,14 @@ module AwesomePrint
|
||||||
def force_colors!(value = true)
|
def force_colors!(value = true)
|
||||||
@force_colors = value
|
@force_colors = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def console?
|
||||||
|
defined?(IRB) || defined?(Pry)
|
||||||
|
end
|
||||||
|
|
||||||
|
def rails_console?
|
||||||
|
console? && (defined?(Rails::Console) || ENV["RAILS_ENV"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Inspector
|
class Inspector
|
||||||
|
|
Loading…
Reference in a new issue