Sha256: 65d53ce58d4e5de648a3bf9b94bafdf5be871d5f71fe6b9f422afa26ad8dc32c

Contents?: true

Size: 1014 Bytes

Versions: 56

Compression:

Stored size: 1014 Bytes

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

      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

56 entries across 56 versions & 1 rubygems

Version Path
bibliothecary-7.3.6 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.5 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.4 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.3.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.2.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.2.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.5 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.4 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.1.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.0.2 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.0.1 lib/bibliothecary/parsers/pub.rb
bibliothecary-7.0.0 lib/bibliothecary/parsers/pub.rb
bibliothecary-6.12.3 lib/bibliothecary/parsers/pub.rb
bibliothecary-6.12.2 lib/bibliothecary/parsers/pub.rb