Class: Bibliothecary::Parsers::SwiftPM
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::SwiftPM
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/swift_pm.rb
Class Method Summary collapse
Methods included from Analyser
Class Method Details
.mapping ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/bibliothecary/parsers/swift_pm.rb', line 6 def self.mapping { /^Package\.swift$/i => { kind: 'manifest', parser: :parse_package_swift } } end |
.parse_package_swift(manifest) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bibliothecary/parsers/swift_pm.rb', line 15 def self.parse_package_swift(manifest) response = Typhoeus.post("#{Bibliothecary.configuration.swift_parser_host}/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, requirement: version, type: 'runtime' } end end |