You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: path_dependency_builder.rb
    path of file: ./repos/dependabot-core/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher
    
    the code of the file until where you have to start completion: # typed: true
# frozen_string_literal: true

require "json"
require "dependabot/dependency_file"
require "dependabot/errors"
require "dependabot/npm_and_yarn/file_fetcher"

module Dependabot
  module NpmAndYarn
    class FileFetcher
      class PathDependencyBuilder
        def initialize(dependency_name:, path:, directory:, package_lock:,
                       yarn_lock:)
          @dependency_name = dependency_name
          @path = path
          @directory = directory
          @package_lock = package_lock
          @yarn_lock = yarn_lock
        end

        def dependency_file
          filename = File.join(path, "package.json")

          DependencyFile.new(
            name: Pathname.new(filename).cleanpath.to_path,
            content: build_path_dep_content(dependency_name),
            directory: directory,
          
    
        def details_from_yarn_lock
          path_starts = FileFetcher::PATH_DEPENDENCY_STARTS
          parsed_yarn_lock.to_a
                          .find do |n, _|
            next false unless n.split(/(?<=\w)\@/).first == dependency_name

            n.split(/(?<=\w)\@/).last.start_with?(*path_starts)
          end&.last
        end

        def details_from_npm_lock
          path_starts = FileFetcher::NPM_PATH_DEPENDENCY_STARTS
          path_deps = parsed_package_lock.fetch("dependencies", []).to_a
                                         .select do |_, v|
            v.fetch("version", "").start_with?(*path_starts)
          end
          path_deps.find { |n, _| n == dependency_name }&.last
        end

        def build_path_dep_content(dependency_name)
          unless details_from_yarn_lock || details_from_npm_lock
            raise Dependabot::PathDependenciesNotReachable, [dependency_name]
          end

          if details_from_yarn_lock
            {
              name: dependency_name,
              version: details_from_yarn_lock["version"] || "0.0.1",
              dependencies:
                replace_yarn_lockfile_paths(
                  details_from_yarn_lock["dependencies"]
                ),
              optionalDependencies:
                replace_yarn_lockfile_paths(
                  details_from_yarn_lock["optionalDependencies"]
                )
            }.compact.to_json
          else
            {
              name: dependency_name,
              version: "0.0.1",
              dependencies: details_from_npm_lock["requires"]
            }.compact.to_json
          end