Sha256: af66fc5df492a7fade52527dba0040b6dbaf048438bb35021798e0929e07aa80

Contents?: true

Size: 815 Bytes

Versions: 14

Compression:

Stored size: 815 Bytes

Contents

require 'yaml'
require 'json'

module Bibliothecary
  module Parsers
    class CPAN
      include Bibliothecary::Analyser

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

14 entries across 14 versions & 1 rubygems

Version Path
bibliothecary-6.2.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.2.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.1.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.0.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.6.2 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.6.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.6.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.5 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.4 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.3 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.2 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.5.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-5.4.0 lib/bibliothecary/parsers/cpan.rb