Method: XCCache::Cache::Cachemap#update_from_graph

Defined in:
lib/xccache/cache/cachemap.rb

#update_from_graph(graph) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/xccache/cache/cachemap.rb', line 63

def update_from_graph(graph)
  cache_data =
    graph["cache"]
    .reject { |k, _| k.end_with?(".xccache") }
    .to_h do |k, v|
      next [k, :hit] if v
      next [k, :ignored] if Config.instance.ignore?(k)
      [k, :missed]
    end

  deps = graph["deps"]
  edges = deps.flat_map { |k, xs| xs.map { |v| { :source => k, :target => v } } }
  nodes = deps.keys.map do |k|
    {
      :id => k,
      :cache => cache_data[k],
      :type => ("agg" if k.end_with?(".xccache")),
      :binary => graph["cache"][k],
    }
  end
  self.raw = {
    "cache" => cache_data,
    "depgraph" => { "nodes" => nodes, "edges" => edges },
  }
  save
  print_stats
end