Sha256: 260186950488db08697c9bdd8b48c8d81d8c8864b177aca49f5656c0fd6b7e87

Contents?: true

Size: 887 Bytes

Versions: 56

Compression:

Stored size: 887 Bytes

Contents

require 'yaml'
require 'json'

module Bibliothecary
  module Parsers
    class CPAN
      include Bibliothecary::Analyser

      def self.mapping
        {
          match_filename("META.json", case_insensitive: true) => {
            kind: 'manifest',
            parser: :parse_json_manifest
          },
          match_filename("META.yml", case_insensitive: true) => {
            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

56 entries across 56 versions & 1 rubygems

Version Path
bibliothecary-6.12.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.12.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.11.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.7 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.6 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.5 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.4 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.3 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.2 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.10.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.8 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.7 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.6 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.5 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.4 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.3 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.2 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.1 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.9.0 lib/bibliothecary/parsers/cpan.rb
bibliothecary-6.8.10 lib/bibliothecary/parsers/cpan.rb