Class: DEBUGGER__::SourceRepository
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Color
|
|
Inherits: | Object |
Defined in: | lib/debug/source_repository.rb |
Class Method Summary
- .new ⇒ SourceRepository constructor
Instance Method Summary
-
#add(iseq, src)
See additional method definition at line 36.
- #file_src(iseq)
- #get(iseq)
-
#get_colored(iseq)
See additional method definition at line 58.
- #initialize ⇒ SourceRepository constructor
-
#orig_src(iseq)
See additional method definition at line 48.
- #add_iseq(iseq, src) private
- #add_path(path) private
- #all_iseq(iseq, rs = []) private
- #get_si(iseq) private
Color
- Included
#color_pp | See additional method definition at line 50. |
#colored_inspect, | |
#colorize | See additional method definition at line 36. |
#colorize_blue, | |
#colorize_code | See additional method definition at line 79. |
#colorize_cyan, #colorize_dim, #colorize_magenta, | |
#irb_colorize | See additional method definition at line 27. |
#with_inspection_error_guard |
Constructor Details
.new ⇒ SourceRepository
# File 'lib/debug/source_repository.rb', line 30
def initialize # cache @cmap = ObjectSpace::WeakMap.new @loaded_file_map = {} # path => nil end
#initialize ⇒ SourceRepository
# File 'lib/debug/source_repository.rb', line 73
def initialize @files = {} # filename => SrcInfo end
Instance Method Details
#add(iseq, src)
See additional method definition at line 36.
# File 'lib/debug/source_repository.rb', line 77
def add iseq, src # do nothing if (path = (iseq.absolute_path || iseq.path)) && File.exist?(path) if @loaded_file_map.has_key? path return path, true # reloaded else @loaded_file_map[path] = path return path, false end end end
#add_iseq(iseq, src) (private)
[ GitHub ]#add_path(path) (private)
[ GitHub ]#all_iseq(iseq, rs = []) (private)
[ GitHub ]# File 'lib/debug/source_repository.rb', line 96
private def all_iseq iseq, rs = [] rs << iseq iseq.each_child{|ci| all_iseq(ci, rs) } rs end
#file_src(iseq)
[ GitHub ]# File 'lib/debug/source_repository.rb', line 9
def file_src iseq if (path = (iseq.absolute_path || iseq.path)) && File.exist?(path) File.readlines(path, chomp: true) end end
#get(iseq)
[ GitHub ]#get_colored(iseq)
See additional method definition at line 58.
# File 'lib/debug/source_repository.rb', line 141
def get_colored iseq if lines = @cmap[iseq] lines else if src_lines = get(iseq) @cmap[iseq] = colorize_code(src_lines.join("\n")).lines else nil end end end
#get_si(iseq) (private)
[ GitHub ]# File 'lib/debug/source_repository.rb', line 123
private def get_si iseq return unless iseq if iseq.instance_variable_defined?(:@debugger_si) iseq.instance_variable_get(:@debugger_si) elsif @files.has_key?(path = (iseq.absolute_path || iseq.path)) @files[path] elsif path add_path(path) end end
#orig_src(iseq)
See additional method definition at line 48.
# File 'lib/debug/source_repository.rb', line 135
def orig_src iseq lines = iseq.script_lines&.map(&:chomp) line = iseq.first_line if line > 1 lines = [*([''] * (line - 1)), *lines] else lines end end