Sha256: 5b3d8cdf19e7bbdd485c714c169519167156a3605fd2e9cfe293d0dedbad7e4c
Contents?: true
Size: 922 Bytes
Versions: 3
Compression:
Stored size: 922 Bytes
Contents
require 'yaml' require 'json' module Bibliothecary module Parsers class CPAN include Bibliothecary::Analyser def self.mapping { /^META\.json$/i => :parse_json_manifest, /^META\.yml$/i => :parse_yaml_manifest } end def self.parse_json_manifest(file_contents) manifest = JSON.parse file_contents manifest['prereqs'].map do |_group, deps| map_dependencies(deps, 'requires', 'runtime') end.flatten end def self.parse_yaml_manifest(file_contents) manifest = YAML.load file_contents map_dependencies(manifest, 'requires', 'runtime') 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bibliothecary-5.0.2 | lib/bibliothecary/parsers/cpan.rb |
bibliothecary-5.0.1 | lib/bibliothecary/parsers/cpan.rb |
bibliothecary-5.0.0 | lib/bibliothecary/parsers/cpan.rb |