Class: Bibliothecary::Parsers::Swift
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Swift
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/swift.rb
Class Method Summary collapse
Methods included from Analyser
Class Method Details
.parse(filename, path) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/bibliothecary/parsers/swift.rb', line 6 def self.parse(filename, path) if filename.match(/^Package\.swift$/i) file_contents = File.open(path).read parse_package_swift(file_contents) else [] end end |
.parse_package_swift(manifest) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bibliothecary/parsers/swift.rb', line 15 def self.parse_package_swift(manifest) response = Typhoeus.post("http://swiftpm.honza.tech/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 |