module Rigor::ModuleGraph::NodeIO
JSONL reader / writer for Node rows.
Public Instance Methods
Source
# File lib/rigor/module_graph/node.rb, line 124 def read(io) nodes = [] io.each_line do |line| line = line.strip next if line.empty? row = JSON.parse(line) nodes << Node.build( kind: row.fetch("kind"), name: row.fetch("name"), owner: row["owner"], path: row["path"], line: row["line"], column: row["column"], visibility: row["visibility"], access: row["access"] ) end nodes end
Source
# File lib/rigor/module_graph/node.rb, line 113 def write(nodes, io) seen = {} nodes.each do |node| key = node.dedup_key next if seen[key] seen[key] = true io.puts(JSON.generate(node.to_h)) end end