Class: Dependabot::Nuget::FileFetcher::ImportPathsFinder
- Inherits:
-
Object
- Object
- Dependabot::Nuget::FileFetcher::ImportPathsFinder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nuget/file_fetcher/import_paths_finder.rb
Instance Method Summary collapse
- #import_paths ⇒ Object
-
#initialize(project_file:) ⇒ ImportPathsFinder
constructor
A new instance of ImportPathsFinder.
- #project_file_paths ⇒ Object
- #project_reference_paths ⇒ Object
Constructor Details
#initialize(project_file:) ⇒ ImportPathsFinder
Returns a new instance of ImportPathsFinder.
16 17 18 |
# File 'lib/dependabot/nuget/file_fetcher/import_paths_finder.rb', line 16 def initialize(project_file:) @project_file = T.let(project_file, Dependabot::DependencyFile) end |
Instance Method Details
#import_paths ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/dependabot/nuget/file_fetcher/import_paths_finder.rb', line 21 def import_paths doc = T.let(Nokogiri::XML(project_file.content), Nokogiri::XML::Document) doc.remove_namespaces! doc.xpath("/Project/Import").filter_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 |
#project_file_paths ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dependabot/nuget/file_fetcher/import_paths_finder.rb', line 46 def project_file_paths doc = T.let(Nokogiri::XML(project_file.content), Nokogiri::XML::Document) doc.remove_namespaces! doc.xpath("/Project/ItemGroup/ProjectFile").filter_map do |node| attribute = node.attribute("Include") next unless attribute path = attribute.value.strip.tr("\\", "/") path = File.join(current_dir, path) unless current_dir.nil? Pathname.new(path).cleanpath.to_path end end |
#project_reference_paths ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dependabot/nuget/file_fetcher/import_paths_finder.rb', line 32 def project_reference_paths doc = T.let(Nokogiri::XML(project_file.content), Nokogiri::XML::Document) doc.remove_namespaces! doc.xpath("/Project/ItemGroup/ProjectReference").filter_map do |node| attribute = node.attribute("Include") next unless attribute path = attribute.value.strip.tr("\\", "/") path = File.join(current_dir, path) unless current_dir.nil? Pathname.new(path).cleanpath.to_path end end |