Sha256: 4586b41cd5f0f169981d3b271e83762ef49fe260993c9a388a62e6fdc726c3b8
Contents?: true
Size: 1.04 KB
Versions: 3
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.parse(filename, path) if filename.match(/^DESCRIPTION$/i) file_contents = File.open(path).read control = DebControl::ControlFileBase.parse(file_contents) parse_description(control) else [] end end def self.parse_description(manifest) parse_section(manifest, 'Depends') + parse_section(manifest, 'Imports') + parse_section(manifest, 'Suggests') + parse_section(manifest, 'Enhances') end def self.parse_section(manifest, name) deps = manifest.first[name].gsub("\n", '').split(',').map(&:strip) deps.map do |dependency| dep = dependency.match(REQUIRE_REGEXP) { name: dep[1], version: dep[2] || '*', type: name.downcase } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bibliothecary-4.0.0 | lib/bibliothecary/parsers/cran.rb |
bibliothecary-3.0.1 | lib/bibliothecary/parsers/cran.rb |
bibliothecary-3.0.0 | lib/bibliothecary/parsers/cran.rb |