Class: Bibliothecary::Parsers::Carthage

Inherits:
Object
  • Object
show all
Includes:
Analyser
Defined in:
lib/bibliothecary/parsers/carthage.rb

Class Method Summary collapse

Methods included from Analyser

create_analysis, create_error_analysis, included

Class Method Details

.map_dependencies(manifest, path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bibliothecary/parsers/carthage.rb', line 35

def self.map_dependencies(manifest, path)
  response = Typhoeus.post("#{Bibliothecary.configuration.carthage_parser_host}/#{path}", params: {body: manifest})
  raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.carthage_parser_host}/#{path}", response.response_code) unless response.success?
  json = JSON.parse(response.body)

  json.map do |dependency|
    {
      name: dependency['name'],
      requirement: dependency['version'],
      type: dependency["type"]
    }
  end
end

.mappingObject



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
  {
    match_filename("Cartfile") => {
      kind: 'manifest',
      parser: :parse_cartfile
    },
    match_filename("Cartfile.private") => {
      kind: 'manifest',
      parser: :parse_cartfile_private
    },
    match_filename("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