Sha256: 9430fe83db897d32500b7b77e30d027e67732aae1d6ef7a66f31cf3442e2e68e

Contents?: true

Size: 857 Bytes

Versions: 5

Compression:

Stored size: 857 Bytes

Contents

class LoadTracer
  class DefaultFormatter
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
load_tracer-0.6.1 lib/load_tracer/formatter/default.rb
load_tracer-0.6.0 lib/load_tracer/formatter/default.rb
load_tracer-0.4.0 lib/load_tracer/formatter/default.rb
load_tracer-0.3.0 lib/load_tracer/formatter/default.rb
load_tracer-0.2.0 lib/load_tracer/formatter/default.rb