Sha256: c8ee0376e8e918bf8128d8d7bad4a29ceae118bb4b7496cd055398a9b2131a36

Contents?: true

Size: 767 Bytes

Versions: 20

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true
module Puppet::Pops::Loader::UriHelper
  # Raises an exception if specified gem can not be located
  #
  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
    when "file"
      File.join(uri.path, subdir)
    when nil
      File.join(uri.path, subdir)
    else
      raise "Not a valid scheme for a loader: #{uri.scheme}. Use a 'file:' (or just a path), or 'gem://gemname[/path]"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.0-x86-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.0-x64-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.0-universal-darwin lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.1 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.1-x86-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.1-x64-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.3.1-universal-darwin lib/puppet/pops/loader/uri_helper.rb
puppet-8.2.0 lib/puppet/pops/loader/uri_helper.rb
puppet-8.2.0-x86-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.2.0-x64-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.2.0-universal-darwin lib/puppet/pops/loader/uri_helper.rb
puppet-8.1.0 lib/puppet/pops/loader/uri_helper.rb
puppet-8.1.0-x86-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.1.0-x64-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.1.0-universal-darwin lib/puppet/pops/loader/uri_helper.rb
puppet-8.0.1 lib/puppet/pops/loader/uri_helper.rb
puppet-8.0.1-x86-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.0.1-x64-mingw32 lib/puppet/pops/loader/uri_helper.rb
puppet-8.0.1-universal-darwin lib/puppet/pops/loader/uri_helper.rb