module Puppet::Pops::Loader::UriHelper

Public Instance Methods

path_for_uri(uri, subdir='lib') click to toggle source

Raises an exception if specified gem can not be located

   # File lib/puppet/pops/loader/uri_helper.rb
 4 def path_for_uri(uri, subdir='lib')
 5   case uri.scheme
 6   when "gem"
 7     begin
 8       spec = Gem::Specification.find_by_name(uri.hostname)
 9       # if path given append that, else append given subdir
10       File.join(spec.gem_dir, uri.path.empty?() ? subdir : uri.path)
11     rescue StandardError => e
12       raise "TODO TYPE: Failed to located gem #{uri}. #{e.message}"
13     end
14   when "file"
15     File.join(uri.path, subdir)
16   when nil
17     File.join(uri.path, subdir)
18   else
19     raise "Not a valid scheme for a loader: #{uri.scheme}. Use a 'file:' (or just a path), or 'gem://gemname[/path]"
20   end
21 end