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