Sha256: 888c3cbca50bd56e42d7903dccf6d98eff96a01783e3a9d5b401dc2d5e434724
Contents?: true
Size: 1.22 KB
Versions: 29
Compression:
Stored size: 1.22 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) def self.parse_package_swift(file_contents, options: {}) 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']}" { name: name, requirement: version, type: 'runtime' } end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems