Sha256: 9dff61dfe1dbf2a76394e5a8d88186382d5a4cac665b43e8c232c26256f07bc7
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
require 'yaml' module Bibliothecary module Parsers class Pub include Bibliothecary::Analyser def self.mapping { /^pubspec\.yaml$/i => { kind: 'manifest', parser: :parse_yaml_manifest }, /^pubspec\.lock$/i => { kind: 'lockfile', parser: :parse_yaml_lockfile } } end def self.parse_yaml_manifest(file_contents) manifest = YAML.load file_contents map_dependencies(manifest, 'dependencies', 'runtime') + map_dependencies(manifest, 'dev_dependencies', 'development') end def self.parse_yaml_lockfile(file_contents) manifest = YAML.load file_contents manifest.fetch('packages', []).map do |name, dep| { name: name, requirement: dep['version'], type: 'runtime' } end end def self.map_dependencies(hash, key, type) hash.fetch(key,[]).map do |name, requirement| { name: name, requirement: requirement, type: type } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems