1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Show unloaded constants in yellow

This commit is contained in:
Conrad Irwin 2012-04-04 14:15:23 -07:00
parent 3fcbb975b2
commit e6688b55da
2 changed files with 7 additions and 3 deletions

View file

@ -30,7 +30,8 @@ class Pry
opt.on :g, "globals", "Show global variables, including those builtin to Ruby (in cyan)"
opt.on :l, "locals", "Show locals, including those provided by Pry (in red)"
opt.on :c, "constants", "Show constants, highlighting classes (in blue), and exceptions (in purple)"
opt.on :c, "constants", "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" +
" " * 32 + "Constants that are pending autoload? are also shown (in yellow)."
opt.on :i, "ivars", "Show instance variables (in blue) and class variables (in bright blue)"
@ -206,7 +207,7 @@ class Pry
def format_constants(mod, constants)
constants.sort_by(&:downcase).map do |name|
if const = (!mod.autoload?(name) && mod.const_get(name) rescue nil)
if const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil)
if (const < Exception rescue false)
color(:exception_constant, name)
elsif (Module === mod.const_get(name) rescue false)
@ -214,6 +215,8 @@ class Pry
else
color(:constant, name)
end
else
color(:unloaded_constant, name)
end
end
end

View file

@ -284,9 +284,10 @@ class Pry
:builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID
:pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
:constant_color => :default, # e.g. VERSION, ARGF
:constant_color => :default, # e.g. VERSION, ARGF
:class_constant_color => :blue, # e.g. Object, Kernel
:exception_constant_color => :magenta, # e.g. Exception, RuntimeError
:unloaded_constant_color => :yellow, # Any constant that is still in .autoload? state
# What should separate items listed by ls? (TODO: we should allow a columnar layout)
:separator => " ",