Class: FastCov::TestMap::Reader
- Inherits:
-
Object
- Object
- FastCov::TestMap::Reader
- Defined in:
- lib/fast_cov/test_map/reader.rb
Overview
Reads a single sorted fragment file (gzipped or plain text). Merges consecutive entries with the same file path, which occur when multiple fragments are concatenated and sorted into an intermediate.
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #advance ⇒ Object
- #close ⇒ Object
- #exhausted? ⇒ Boolean
-
#initialize(path) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(path) ⇒ Reader
Returns a new instance of Reader.
13 14 15 16 17 18 19 20 |
# File 'lib/fast_cov/test_map/reader.rb', line 13 def initialize(path) @io = path.to_s.end_with?(".gz") ? Zlib::GzipReader.open(path) : File.open(path) @exhausted = false @next_file_path = nil @next_dependencies = nil read_line advance end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
11 12 13 |
# File 'lib/fast_cov/test_map/reader.rb', line 11 def dependencies @dependencies end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
11 12 13 |
# File 'lib/fast_cov/test_map/reader.rb', line 11 def file_path @file_path end |
Instance Method Details
#advance ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fast_cov/test_map/reader.rb', line 26 def advance if @next_file_path.nil? @exhausted = true @file_path = nil @dependencies = [] return end @file_path = @next_file_path @dependencies = @next_dependencies read_line # Merge consecutive lines with the same file path while @next_file_path == @file_path @dependencies.concat(@next_dependencies) read_line end end |
#close ⇒ Object
45 46 47 |
# File 'lib/fast_cov/test_map/reader.rb', line 45 def close @io.close end |
#exhausted? ⇒ Boolean
22 23 24 |
# File 'lib/fast_cov/test_map/reader.rb', line 22 def exhausted? @exhausted end |