Class: Bibliothecary::Parsers::Clojars
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Clojars
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/clojars.rb
Class Method Summary collapse
- .mapping ⇒ Object
-
.parse_manifest(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
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(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bibliothecary/parsers/clojars.rb', line 20 def self.parse_manifest(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument response = Typhoeus.post("#{Bibliothecary.configuration.clojars_parser_host}/project.clj", body: file_contents) 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 |