Class: Bibliothecary::Parsers::Clojars
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Clojars
show all
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/clojars.rb
Class Method Summary
collapse
Methods included from Analyser
create_analysis, create_error_analysis, included
Class Method Details
.mapping ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/bibliothecary/parsers/clojars.rb', line 9
def self.mapping
{
match_filename("project.clj") => {
kind: 'manifest',
parser: :parse_manifest
}
}
end
|
.parse_manifest(manifest) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/bibliothecary/parsers/clojars.rb', line 18
def self.parse_manifest(manifest)
response = Typhoeus.post("#{Bibliothecary.configuration.clojars_parser_host}/project.clj", body: manifest)
raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.clojars_parser_host}/project.clj", response.response_code) unless response.success?
json = JSON.parse response.body
index = json.index("dependencies")
return [] unless index;
dependencies = json[index + 1]
dependencies.map do |dependency|
{
name: dependency[0],
requirement: dependency[1],
type: "runtime"
}
end
end
|