Class: Bibliothecary::Parsers::SwiftPM
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::SwiftPM
show all
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/swift_pm.rb
Class Method Summary
collapse
Methods included from Analyser
create_analysis, create_error_analysis, included
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
{
match_filename("Package.swift", case_insensitive: true) => {
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
28
|
# 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)
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
|