Sha256: e71cce9163fb932fafecfeea01485281ec09292f2518e84425bea2fb1944fe3e

Contents?: true

Size: 750 Bytes

Versions: 3

Compression:

Stored size: 750 Bytes

Contents

module Bibliothecary
  module Parsers
    class SwiftPM
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^Package\.swift$/i => :parse_package_swift
        }
      end

      def self.parse_package_swift(manifest)
        response = Typhoeus.post("http://swift.libraries.io/to-json", body: manifest)
        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,
            version: version,
            type: 'runtime'
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-5.0.2 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-5.0.1 lib/bibliothecary/parsers/swift_pm.rb
bibliothecary-5.0.0 lib/bibliothecary/parsers/swift_pm.rb