Sha256: 7e7e956254ee7d8a2fe20390d76056cfb9e8f0f1a533d023503c5cc090809841

Contents?: true

Size: 1.07 KB

Versions: 56

Compression:

Stored size: 1.07 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

      def self.parse_package_swift(manifest)
        response = Typhoeus.post("#{Bibliothecary.configuration.swift_parser_host}/to-json", body: manifest)
        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

56 entries across 56 versions & 1 rubygems

Version Path
bibliothecary-7.3.6 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.5 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.4 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.3 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.2 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.1 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.3.0 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.2.1 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.2.0 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.5 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.4 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.3 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.2 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.1 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.1.0 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.0.2 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.0.1 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-7.0.0 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-6.12.3 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-6.12.2 lib/bibliothecary/parsers/swift_pm.rb