Sha256: 4f64f469746b63c29870edb7caf8c128edbaee8827ca06327db3d5a6fcd6c7e6
Contents?: true
Size: 1.84 KB
Versions: 8
Compression:
Stored size: 1.84 KB
Contents
require "json" module Bibliothecary module Parsers class Hex include Bibliothecary::Analyser def self.mapping { match_filename("mix.exs") => { kind: "manifest", parser: :parse_mix, }, match_filename("mix.lock") => { kind: "lockfile", parser: :parse_mix_lock, }, } end add_multi_parser(Bibliothecary::MultiParsers::CycloneDX) add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV) add_multi_parser(Bibliothecary::MultiParsers::Spdx) def self.parse_mix(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument response = Typhoeus.post("#{Bibliothecary.configuration.mix_parser_host}/", body: file_contents) raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.mix_parser_host}/", response.response_code) unless response.success? json = JSON.parse response.body json.map do |name, version| Dependency.new( name: name, requirement: version, type: "runtime", ) end end def self.parse_mix_lock(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument response = Typhoeus.post("#{Bibliothecary.configuration.mix_parser_host}/lock", body: file_contents) raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.mix_parser_host}/", response.response_code) unless response.success? json = JSON.parse response.body json.map do |name, info| Dependency.new( name: name, requirement: info["version"], type: "runtime", ) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems