Sha256: d9586dedef54cd12a2b0d4b2539866411e3ea5891ae904619129767b976b2113
Contents?: true
Size: 1.26 KB
Versions: 38
Compression:
Stored size: 1.26 KB
Contents
require 'toml-rb' module Bibliothecary module Parsers class Cargo include Bibliothecary::Analyser def self.mapping { match_filename("Cargo.toml") => { kind: 'manifest', parser: :parse_manifest }, match_filename("Cargo.lock") => { kind: 'lockfile', parser: :parse_lockfile } } end def self.parse_manifest(file_contents) manifest = TomlRB.parse(file_contents) manifest.fetch('dependencies', []).map do |name, requirement| if requirement.respond_to?(:fetch) requirement = requirement['version'] or next end { name: name, requirement: requirement, type: 'runtime' } end .compact end def self.parse_lockfile(file_contents) manifest = TomlRB.parse(file_contents) manifest.fetch('package',[]).map do |dependency| next if not dependency['source'] or not dependency['source'].start_with?('registry+') { name: dependency['name'], requirement: dependency['version'], type: 'runtime' } end .compact end end end end
Version data entries
38 entries across 38 versions & 1 rubygems