Sha256: 7651587b0f4e135c659f4df21b8dffc59d74f6209537b5ed58a6c5a52e5b2956

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

require 'yaml'
require 'json'

module Bibliothecary
  module Parsers
    class CPAN
      include Bibliothecary::Analyser

      def self.mapping
        {
          /(^META\.json$|.*\/META\.json$)/i => {
            kind: 'manifest',
            parser: :parse_json_manifest
          },
          /(^META\.yml$|.*\/META.yml$)/i => {
            kind: 'manifest',
            parser: :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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-6.3.2 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.3.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.3.0 lib/bibliothecary/parsers/cpan.rb