Class: Bibliothecary::Parsers::Carthage
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Carthage
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/carthage.rb
Class Method Summary collapse
- .map_dependencies(manifest, path) ⇒ Object
- .mapping ⇒ Object
- .parse_cartfile(manifest) ⇒ Object
- .parse_cartfile_private(manifest) ⇒ Object
- .parse_cartfile_resolved(manifest) ⇒ Object
Methods included from Analyser
Class Method Details
.map_dependencies(manifest, path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 35 def self.map_dependencies(manifest, path) response = Typhoeus.post("https://carthage.libraries.io/#{path}", params: {body: manifest}) json = JSON.parse(response.body) json.map do |dependency| { name: dependency['name'], version: dependency['version'], type: dependency["type"] } end end |
.mapping ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 6 def self.mapping { /^Cartfile$/ => { kind: 'manifest', parser: :parse_cartfile }, /^Cartfile\.private$/ => { kind: 'manifest', parser: :parse_cartfile_private }, /^Cartfile\.resolved$/ => { kind: 'lockfile', parser: :parse_cartfile_resolved } } end |
.parse_cartfile(manifest) ⇒ Object
23 24 25 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 23 def self.parse_cartfile(manifest) map_dependencies(manifest, 'cartfile') end |
.parse_cartfile_private(manifest) ⇒ Object
27 28 29 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 27 def self.parse_cartfile_private(manifest) map_dependencies(manifest, 'cartfile.private') end |
.parse_cartfile_resolved(manifest) ⇒ Object
31 32 33 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 31 def self.parse_cartfile_resolved(manifest) map_dependencies(manifest, 'cartfile.resolved') end |