Sha256: ccad4c12fa6848c0ca26514d949f2ff6d3a4a4ee688b64946d59d5a11a21b91c
Contents?: true
Size: 1.39 KB
Versions: 20
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true require "nokogiri" require "pathname" require "dependabot/file_fetchers/dotnet/nuget" module Dependabot module FileFetchers module Dotnet class Nuget class ImportPathsFinder def initialize(project_file:) @project_file = project_file end def import_paths doc = Nokogiri::XML(project_file.content) doc.remove_namespaces! doc.xpath("/Project/Import").map do |import_node| path = import_node.attribute("Project").value.strip.tr("\\", "/") path = File.join(current_dir, path) unless current_dir.nil? Pathname.new(path).cleanpath.to_path end end def project_reference_paths doc = Nokogiri::XML(project_file.content) doc.remove_namespaces! doc.xpath("/Project/ItemGroup/ProjectReference").map do |node| path = node.attribute("Include").value.strip.tr("\\", "/") path = File.join(current_dir, path) unless current_dir.nil? Pathname.new(path).cleanpath.to_path end end private attr_reader :project_file def current_dir parts = project_file.name.split("/")[0..-2] return if parts.empty? parts.join("/") end end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems