Class: Dependabot::Swift::FileParser::ManifestParser
- Inherits:
-
Object
- Object
- Dependabot::Swift::FileParser::ManifestParser
- Defined in:
- lib/dependabot/swift/file_parser/manifest_parser.rb
Constant Summary collapse
- DEPENDENCY =
/(?<declaration>\.package\(\s* (?:name:\s+"[^"]+",\s*)?url:\s+"(?<url>[^"]+)",\s*(?<requirement>#{NativeRequirement::REGEXP})\s* \))/x
Instance Method Summary collapse
-
#initialize(manifest, source:) ⇒ ManifestParser
constructor
A new instance of ManifestParser.
- #requirements ⇒ Object
Constructor Details
#initialize(manifest, source:) ⇒ ManifestParser
Returns a new instance of ManifestParser.
16 17 18 19 |
# File 'lib/dependabot/swift/file_parser/manifest_parser.rb', line 16 def initialize(manifest, source:) @manifest = manifest @source = source end |
Instance Method Details
#requirements ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dependabot/swift/file_parser/manifest_parser.rb', line 21 def requirements found = manifest.content.scan(DEPENDENCY).find do |_declaration, url, _requirement| SharedHelpers.scp_to_standard(url) == source[:url] end return [] unless found declaration = found.first requirement = NativeRequirement.new(found.last) [ { requirement: requirement.to_s, groups: ["dependencies"], file: manifest.name, source: source, metadata: { declaration_string: declaration, requirement_string: requirement.declaration } } ] end |