Class: Dependabot::Nuget::TfmFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nuget/update_checker/tfm_finder.rb

Class Method Summary collapse

Class Method Details

.frameworks(dependency) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dependabot/nuget/update_checker/tfm_finder.rb', line 12

def self.frameworks(dependency)
  discovery_json = DiscoveryJsonReader.discovery_json
  return [] unless discovery_json

  workspace = DiscoveryJsonReader.new(
    discovery_json: discovery_json
  ).workspace_discovery
  return [] unless workspace

  workspace.projects.select do |project|
    all_dependencies = project.dependencies + project.referenced_project_paths.flat_map do |ref|
      workspace.projects.find { |p| p.file_path == ref }&.dependencies || []
    end
    all_dependencies.any? { |d| d.name.casecmp?(dependency.name) }
  end.flat_map(&:target_frameworks).uniq
end