Sha256: 05ae0895f623f1e1be0a254832c631c0c448da940bfc8b6e11aafb65d618958a

Contents?: true

Size: 942 Bytes

Versions: 14

Compression:

Stored size: 942 Bytes

Contents

require 'yaml'

module Bibliothecary
  module Parsers
    class Pub
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^pubspec\.yaml$/i => {
            kind: 'manifest',
            parser: :parse_yaml_manifest
          },
          /^pubspec\.lock$/i => {
            kind: 'lockfile',
            parser: :parse_yaml_lockfile
          }
        }
      end

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

      def self.parse_yaml_lockfile(file_contents)
        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

14 entries across 14 versions & 1 rubygems

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