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: uri_helper.rb
    path of file: ./repos/puppet/lib/puppet/pops/loader
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Puppet::Pops::Loader::UriHelper
  # Raises an exc
    
  def path_for_uri(uri, subdir = 'lib')
    case uri.scheme
    when "gem"
      begin
        spec = Gem::Specification.find_by_name(uri.hostname)
        # if path given append that, else append given subdir
        File.join(spec.gem_dir, uri.path.empty?() ? subdir : uri.path)
      rescue StandardError => e
        raise "TODO TYPE: Failed to located gem #{uri}. #{e.message}"
      end