mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1130 from robgleeson/ls-command-update
update 'ls' command to go through `_pry_.config`. closes #1126.
This commit is contained in:
commit
9a04bf5314
11 changed files with 36 additions and 36 deletions
|
@ -5,7 +5,7 @@ rvm:
|
|||
- 2.1.0
|
||||
- ruby-head
|
||||
- rbx
|
||||
- jruby-19mode
|
||||
- jruby
|
||||
- jruby-head
|
||||
|
||||
script:
|
||||
|
|
|
@ -59,11 +59,10 @@ class Pry
|
|||
|
||||
ls_entity = LsEntity.new({
|
||||
:interrogatee => @interrogatee,
|
||||
:target => target,
|
||||
:no_user_opts => no_user_opts?,
|
||||
:opts => opts,
|
||||
:sticky_locals => _pry_.sticky_locals,
|
||||
:args => args
|
||||
:args => args,
|
||||
:_pry_ => _pry_
|
||||
})
|
||||
|
||||
stagger_output(ls_entity.entities_table)
|
||||
|
|
|
@ -3,11 +3,11 @@ require 'pry/commands/ls/interrogatable'
|
|||
class Pry
|
||||
class Command::Ls < Pry::ClassCommand
|
||||
class Constants < Pry::Command::Ls::Formatter
|
||||
|
||||
include Pry::Command::Ls::Interrogatable
|
||||
|
||||
def initialize(interrogatee, target, no_user_opts, opts)
|
||||
super(target)
|
||||
|
||||
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
||||
super(_pry_)
|
||||
@interrogatee = interrogatee
|
||||
@no_user_opts = no_user_opts
|
||||
@default_switch = opts[:constants]
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
class Pry
|
||||
class Command::Ls < Pry::ClassCommand
|
||||
class Formatter
|
||||
|
||||
attr_accessor :grep
|
||||
attr_reader :_pry_
|
||||
|
||||
def initialize(target)
|
||||
@target = target
|
||||
def initialize(_pry_)
|
||||
@_pry_ = _pry_
|
||||
@target = _pry_.current_context
|
||||
end
|
||||
|
||||
def write_out
|
||||
|
@ -16,7 +17,7 @@ class Pry
|
|||
private
|
||||
|
||||
def color(type, str)
|
||||
Pry::Helpers::Text.send(Pry.config.ls.send(:"#{type}_color"), str)
|
||||
Pry::Helpers::Text.send _pry_.config.ls["#{type}_color"], str
|
||||
end
|
||||
|
||||
# Add a new section to the output.
|
||||
|
|
|
@ -19,8 +19,8 @@ class Pry
|
|||
$CHILD_STATUS $SAFE $ERROR_INFO $ERROR_POSITION $LAST_MATCH_INFO
|
||||
$LAST_PAREN_MATCH $LAST_READ_LINE $MATCH $POSTMATCH $PREMATCH)
|
||||
|
||||
def initialize(target, opts)
|
||||
super(target)
|
||||
def initialize(opts, _pry_)
|
||||
super(_pry_)
|
||||
@default_switch = opts[:globals]
|
||||
end
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ require 'pry/commands/ls/interrogatable'
|
|||
class Pry
|
||||
class Command::Ls < Pry::ClassCommand
|
||||
class InstanceVars < Pry::Command::Ls::Formatter
|
||||
|
||||
include Pry::Command::Ls::Interrogatable
|
||||
|
||||
def initialize(interrogatee, no_user_opts, opts)
|
||||
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
||||
super(_pry_)
|
||||
@interrogatee = interrogatee
|
||||
@no_user_opts = no_user_opts
|
||||
@default_switch = opts[:ivars]
|
||||
|
|
|
@ -2,11 +2,11 @@ class Pry
|
|||
class Command::Ls < Pry::ClassCommand
|
||||
class LocalNames < Pry::Command::Ls::Formatter
|
||||
|
||||
def initialize(target, no_user_opts, sticky_locals, args)
|
||||
super(target)
|
||||
def initialize(no_user_opts, args, _pry_)
|
||||
super(_pry_)
|
||||
@no_user_opts = no_user_opts
|
||||
@sticky_locals = sticky_locals
|
||||
@args = args
|
||||
@sticky_locals = _pry_.sticky_locals
|
||||
end
|
||||
|
||||
def correct_opts?
|
||||
|
|
|
@ -2,10 +2,10 @@ class Pry
|
|||
class Command::Ls < Pry::ClassCommand
|
||||
class LocalVars < Pry::Command::Ls::Formatter
|
||||
|
||||
def initialize(target, sticky_locals, opts)
|
||||
super(target)
|
||||
@sticky_locals = sticky_locals
|
||||
def initialize(opts, _pry_)
|
||||
super(_pry_)
|
||||
@default_switch = opts[:locals]
|
||||
@sticky_locals = _pry_.sticky_locals
|
||||
end
|
||||
|
||||
def output_self
|
||||
|
|
|
@ -12,15 +12,15 @@ class Pry
|
|||
class Command::Ls < Pry::ClassCommand
|
||||
|
||||
class LsEntity
|
||||
attr_reader :_pry_
|
||||
|
||||
def initialize(opts)
|
||||
@interrogatee = opts[:interrogatee]
|
||||
@target = opts[:target]
|
||||
@no_user_opts = opts[:no_user_opts]
|
||||
@opts = opts[:opts]
|
||||
@sticky_locals = opts[:sticky_locals]
|
||||
@args = opts[:args]
|
||||
@grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
|
||||
@_pry_ = opts.delete(:_pry_)
|
||||
end
|
||||
|
||||
def entities_table
|
||||
|
@ -34,38 +34,37 @@ class Pry
|
|||
end
|
||||
|
||||
def globals
|
||||
grep(Globals.new(@target, @opts))
|
||||
grep Globals.new(@opts, _pry_)
|
||||
end
|
||||
|
||||
def constants
|
||||
grep(Constants.new(@interrogatee, @target, @no_user_opts, @opts))
|
||||
grep Constants.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
||||
end
|
||||
|
||||
def methods
|
||||
grep(Methods.new(@interrogatee, @no_user_opts, @opts))
|
||||
grep(Methods.new(@interrogatee, @no_user_opts, @opts, _pry_))
|
||||
end
|
||||
|
||||
def self_methods
|
||||
grep(SelfMethods.new(@interrogatee, @no_user_opts, @opts))
|
||||
grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
||||
end
|
||||
|
||||
def instance_vars
|
||||
grep(InstanceVars.new(@interrogatee, @no_user_opts, @opts))
|
||||
grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
||||
end
|
||||
|
||||
def local_names
|
||||
grep(LocalNames.new(@target, @no_user_opts, @sticky_locals, @args))
|
||||
grep LocalNames.new(@no_user_opts, @args, _pry_)
|
||||
end
|
||||
|
||||
def local_vars
|
||||
LocalVars.new(@target, @sticky_locals, @opts)
|
||||
LocalVars.new(@opts, _pry_)
|
||||
end
|
||||
|
||||
def entities
|
||||
[globals, constants, methods, self_methods, instance_vars, local_names,
|
||||
local_vars]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,8 @@ class Pry
|
|||
include Pry::Command::Ls::Interrogatable
|
||||
include Pry::Command::Ls::MethodsHelper
|
||||
|
||||
def initialize(interrogatee, no_user_opts, opts)
|
||||
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
||||
super(_pry_)
|
||||
@interrogatee = interrogatee
|
||||
@no_user_opts = no_user_opts
|
||||
@default_switch = opts[:methods]
|
||||
|
@ -42,11 +43,11 @@ class Pry
|
|||
def below_ceiling
|
||||
ceiling = if @quiet_switch
|
||||
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
|
||||
Pry.config.ls.ceiling
|
||||
_pry_.config.ls.ceiling
|
||||
elsif @verbose_switch
|
||||
[]
|
||||
else
|
||||
Pry.config.ls.ceiling.dup
|
||||
_pry_.config.ls.ceiling.dup
|
||||
end
|
||||
lambda { |klass| !ceiling.include?(klass) }
|
||||
end
|
||||
|
|
|
@ -4,11 +4,11 @@ require 'pry/commands/ls/methods_helper'
|
|||
class Pry
|
||||
class Command::Ls < Pry::ClassCommand
|
||||
class SelfMethods < Pry::Command::Ls::Formatter
|
||||
|
||||
include Pry::Command::Ls::Interrogatable
|
||||
include Pry::Command::Ls::MethodsHelper
|
||||
|
||||
def initialize(interrogatee, no_user_opts, opts)
|
||||
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
||||
super(_pry_)
|
||||
@interrogatee = interrogatee
|
||||
@no_user_opts = no_user_opts
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue