Sha256: 418c004b8b6036fb51226b396a39104013e592f26bb0e95861bcf733625f74a8
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
require 'deb_control' module Bibliothecary module Parsers class CRAN include Bibliothecary::Analyser REQUIRE_REGEXP = /([a-zA-Z0-9\-_\.]+)\s?\(?([><=\s\d\.,]+)?\)?/ def self.mapping { /^DESCRIPTION$/i => { kind: 'manifest', parser: :parse_description } } end def self.parse_description(file_contents) manifest = DebControl::ControlFileBase.parse(file_contents) parse_section(manifest, 'Depends') + parse_section(manifest, 'Imports') + parse_section(manifest, 'Suggests') + parse_section(manifest, 'Enhances') end def self.parse_section(manifest, name) return [] unless manifest.first[name] deps = manifest.first[name].delete("\n").split(',').map(&:strip) deps.map do |dependency| dep = dependency.match(REQUIRE_REGEXP) { name: dep[1], requirement: dep[2] || '*', type: name.downcase } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems