Class: Dependabot::Nuget::FileParser::PropertyValueFinder
- Inherits:
-
Object
- Object
- Dependabot::Nuget::FileParser::PropertyValueFinder
- Defined in:
- lib/dependabot/nuget/file_parser/property_value_finder.rb
Constant Summary collapse
- PROPERTY_REGEX =
/\$\((?<property>.*?)\)/.freeze
Instance Method Summary collapse
- #check_next_level_of_stack(node_details, stack) ⇒ Object
-
#initialize(dependency_files:) ⇒ PropertyValueFinder
constructor
A new instance of PropertyValueFinder.
- #property_details(property_name:, callsite_file:, stack: []) ⇒ Object
Constructor Details
#initialize(dependency_files:) ⇒ PropertyValueFinder
Returns a new instance of PropertyValueFinder.
15 16 17 |
# File 'lib/dependabot/nuget/file_parser/property_value_finder.rb', line 15 def initialize(dependency_files:) @dependency_files = dependency_files end |
Instance Method Details
#check_next_level_of_stack(node_details, stack) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dependabot/nuget/file_parser/property_value_finder.rb', line 49 def check_next_level_of_stack(node_details, stack) property_name = node_details.fetch(:value). match(PROPERTY_REGEX). named_captures.fetch("property") callsite_file = dependency_files. find { |f| f.name == node_details.fetch(:file) } if stack.include?([property_name, callsite_file.name]) raise "Circular reference!" end property_details( property_name: property_name, callsite_file: callsite_file, stack: stack ) end |
#property_details(property_name:, callsite_file:, stack: []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dependabot/nuget/file_parser/property_value_finder.rb', line 19 def property_details(property_name:, callsite_file:, stack: []) stack += [[property_name, callsite_file.name]] return if property_name.include?("(") node_details = deep_find_prop_node( property: property_name, file: callsite_file ) node_details ||= find_property_in_directory_build_targets( property: property_name, callsite_file: callsite_file ) node_details ||= find_property_in_directory_build_props( property: property_name, callsite_file: callsite_file ) node_details ||= find_property_in_packages_props(property: property_name) return unless node_details return node_details unless node_details[:value] =~ PROPERTY_REGEX check_next_level_of_stack(node_details, stack) end |