Sha256: 612b2ecca01fcc96b08d4249bd0126c2ee4ee059bf8e21a9366f386ae18caa82

Contents?: true

Size: 1.08 KB

Versions: 35

Compression:

Stored size: 1.08 KB

Contents

require 'yaml'

module Bibliothecary
  module Parsers
    class Pub
      include Bibliothecary::Analyser

      def self.mapping
        {
          match_filename("pubspec.yaml", case_insensitive: true) => {
            kind: 'manifest',
            parser: :parse_yaml_manifest
          },
          match_filename("pubspec.lock", case_insensitive: true) => {
            kind: 'lockfile',
            parser: :parse_yaml_lockfile
          }
        }
      end

      add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)

      def self.parse_yaml_manifest(file_contents, options: {})
        manifest = YAML.load file_contents
        map_dependencies(manifest, 'dependencies', 'runtime') +
        map_dependencies(manifest, 'dev_dependencies', 'development')
      end

      def self.parse_yaml_lockfile(file_contents, options: {})
        manifest = YAML.load file_contents
        manifest.fetch('packages', []).map do |name, dep|
          {
            name: name,
            requirement: dep['version'],
            type: 'runtime'
          }
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
bibliothecary-8.7.4 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.7.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.7.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.7.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.7.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.5 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.4 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.6.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.5.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.5.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.6 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.5 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.4 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-8.4.0 lib/bibliothecary/parsers/pub.rb