3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/load_tracer/formatter/default.rb', line 3
def self.export(dependencies:, reverse_dependencies:)
report = dependencies.map do |path, deps|
FileSpec.new(
name: File.basename(path),
path: path,
dependencies: deps,
reverse_dependencies: [],
)
end
reverse_dependencies.each do |path, rdeps|
fs = report.find { |fs| fs.path == path }
if fs.nil?
report << FileSpec.new(
name: File.basename(path),
path: path,
dependencies: [],
reverse_dependencies: rdeps,
)
else
fs.reverse_dependencies = rdeps
end
end
report.each do |fs|
fs.dependencies.sort!.uniq!
fs.reverse_dependencies.sort!.uniq!
end
report.sort_by(&:name)
end
|