Sha256: 79640273c9584ac1662191ab060d4437a5bfe338a6220b43dc215f0bc51a21b4
Contents?: true
Size: 1.33 KB
Versions: 8
Compression:
Stored size: 1.33 KB
Contents
module Bibliothecary module Parsers class SwiftPM include Bibliothecary::Analyser def self.mapping { match_filename("Package.swift", case_insensitive: true) => { kind: "manifest", parser: :parse_package_swift, }, } end add_multi_parser(Bibliothecary::MultiParsers::CycloneDX) add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV) add_multi_parser(Bibliothecary::MultiParsers::Spdx) def self.parse_package_swift(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument response = Typhoeus.post("#{Bibliothecary.configuration.swift_parser_host}/to-json", body: file_contents) raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.swift_parser_host}/to-json", response.response_code) unless response.success? json = JSON.parse(response.body) json["dependencies"].map do |dependency| name = dependency["url"].gsub(/^https?:\/\//, "").gsub(/\.git$/,"") version = "#{dependency['version']['lowerBound']} - #{dependency['version']['upperBound']}" Dependency.new( name: name, requirement: version, type: "runtime", ) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems