Sha256: 245c786bdb6915a6181d288b1c071254e0bcb978edb6a59c1ab24e417dab39ad
Contents?: true
Size: 541 Bytes
Versions: 4
Compression:
Stored size: 541 Bytes
Contents
module XCPretty class Snippet def self.from_filepath(filepath) path, line = filepath.split(':') file = File.open(path) text = read_snippet(file, line) file.close text rescue '' end private def self.read_snippet(file, around_line) text = "" starting_position = around_line.to_i - 2 starting_position.times { file.gets } 3.times { text += readline(file) } text end def self.readline(file) file.gets $_ || '' end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
learn-xcpretty-0.1.12 | lib/xcpretty/snippet.rb |
learn-xcpretty-0.1.11 | lib/xcpretty/snippet.rb |
xcpretty-0.1.7 | lib/xcpretty/snippet.rb |
xcpretty-0.1.6 | lib/xcpretty/snippet.rb |