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: nfs.rb
    path of file: ./repos/vagrant/plugins/hosts/bsd/cap
    
    the code of the file until where you have to start completion: # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

require "log4r"

require "vagrant/util"
require "vagrant/util/shell_quote"
require "vagrant/util/which"

module VagrantPlugins
  module HostBSD
    module Cap
      class NFS
        def self.nfs_export(environment, ui, id, ips, folders)
          nfs_exports_template = environment.host.capability(:nfs_exports_template)
          nfs_restart_command  = environment.host.capability(:nfs_restart_command)
          logger = Log4r::Logger.new("vagrant::hosts::bsd")

          nfs_checkexports! if File.file?("/etc/exports")

          # We need to build up mapping o
    
        def self.nfs_export(environment, ui, id, ips, folders)
          nfs_exports_template = environment.host.capability(:nfs_exports_template)
          nfs_restart_command  = environment.host.capability(:nfs_restart_command)
          logger = Log4r::Logger.new("vagrant::hosts::bsd")

          nfs_checkexports! if File.file?("/etc/exports")

          # We need to build up mapping of directories that are enclosed
          # within each other because the exports file has to have subdirectories
          # of an exported directory on the same line. e.g.:
          #
          #   "/foo" "/foo/bar" ...
          #   "/bar"
          #
          # We build up this mapping within the following hash.
          logger.debug("Compiling map of sub-directories for NFS exports...")
          dirmap = {}
          folders.sort_by { |_, opts| opts[:hostpath] }.each do |_, opts|
            opts[:hostpath] = environment.host.capability(:resolve_host_path, opts[:hostpath].gsub('"', '\"'))
            hostpath = opts[:hostpath].dup

            found = false
            dirmap.each do |dirs, diropts|
              dirs.each do |dir|
                if dir.start_with?(hostpath) || hostpath.start_with?(dir)
                  # TODO: verify opts and diropts are _identical_, raise an error
                  # if not. NFS mandates subdirectories have identical options.
                  dirs << hostpath
                  found = true
                  break
                end
              end

              break if found
            end

            if !found
              dirmap[[hostpath]] = opts.dup
            end