Sha256: 2a10ed0f4f2ed4b6671a2debe0e0c373c109292efab344d2b9e5ff807cb23e68
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
require 'json' require 'typhoeus' module Bibliothecary module Parsers class Clojars include Bibliothecary::Analyser def self.mapping { match_filename("project.clj") => { kind: 'manifest', parser: :parse_manifest } } end def self.parse_manifest(file_contents, options: {}) 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems