class Bibliothecary::Parsers::Pub

Public Class Methods

mapping() click to toggle source
# File lib/bibliothecary/parsers/pub.rb, line 8
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
parse_yaml_lockfile(file_contents, options: {}) click to toggle source
# File lib/bibliothecary/parsers/pub.rb, line 29
def self.parse_yaml_lockfile(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
  manifest = YAML.load file_contents
  manifest.fetch("packages", []).map do |name, dep|
    Dependency.new(
      name: name,
      requirement: dep["version"],
      type: "runtime",
    )
  end
end
parse_yaml_manifest(file_contents, options: {}) click to toggle source
# File lib/bibliothecary/parsers/pub.rb, line 23
def self.parse_yaml_manifest(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
  manifest = YAML.load file_contents
  map_dependencies(manifest, "dependencies", "runtime") +
  map_dependencies(manifest, "dev_dependencies", "development")
end