Sha256: 6b05910ed3d4767a6ef41fc99c64bde9cf2ea93772e99e66675b4b70022e173a
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
Contents
module PutsDebuggerer class SourceFile def initialize(file_path) @file = File.new(file_path) if file_path && File.exist?(file_path) end def source(source_line_count, source_line_number) @source = '' return @source if RUBY_ENGINE == 'opal' # For Opal Ruby compatibility, skip source lines if file does not respond to readline (as in Opal) lines = source_lines(source_line_count, source_line_number) @source = lines.join(' '*5) if @file.respond_to?(:readline) @source end def source_lines(source_line_count, source_line_number) lines = [] begin while @file && @file.lineno < source_line_number + source_line_count file_line_number = @file.lineno + 1 file_line = @file.readline if file_line_number >= source_line_number && file_line_number < source_line_number + source_line_count lines << file_line end end rescue EOFError # Done end lines end end end
Version data entries
6 entries across 6 versions & 1 rubygems