Class: Puppet::Pops::Binder::SchemeHandler::ModuleScheme
- Inherits:
-
SymbolicScheme
- Object
- Puppetx::Puppet::BindingsSchemeHandler
- SymbolicScheme
- Puppet::Pops::Binder::SchemeHandler::ModuleScheme
- Defined in:
- lib/puppet/pops/binder/scheme_handler/module_scheme.rb
Overview
Does currently only support checking of optionality against files under a module. If the result should be loaded from any other location it can not be marked as optional as it will be ignored.
The module scheme allows loading bindings using the Puppet autoloader. Optional uris are handled by checking if the symbolic name can be resolved to a loadable file from modules.
URI
The uri is on the format: ‘module:/[? | ?optional]` where `fqn` is a fully qualified bindings name starting with the module name or ’*‘ to denote ’any module’. A URI query of ‘?` or `?optional` makes the request optional; if no loadable file is found, it is simply skipped.
Instance Method Summary collapse
-
#expand_excluded(uri, composer) ⇒ Array<URI>
Expands URIs with wildcards.
-
#expand_included(uri, composer) ⇒ Array<URI>
Expands URIs with wildcards and checks optionality.
Methods inherited from SymbolicScheme
#contributed_bindings, #fqn_from_path, #has_wildcard?, #is_optional?
Methods inherited from Puppetx::Puppet::BindingsSchemeHandler
#contributed_bindings, #is_optional?
Instance Method Details
#expand_excluded(uri, composer) ⇒ Array<URI>
Expands URIs with wildcards
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/puppet/pops/binder/scheme_handler/module_scheme.rb', line 65 def (uri, composer) result = [] split_name, fqn = fqn_from_path(uri) case split_name[ 0 ] when '*' # create new URIs, one per module name composer.name_to_module.each_pair do | name, mod | result << URI.parse('module:/' + ([name] + split_name).join('::')) end when nil raise ArgumentError, "Bad bindings uri, the #{uri} has neither module name or wildcard '*' in its first path position" else # create a clean copy (get rid of optional, fragments etc. and any trailing stuff result << URI.parse('module:/' + split_name.join('::')) end result end |
#expand_included(uri, composer) ⇒ Array<URI>
Expands URIs with wildcards and checks optionality.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/puppet/pops/binder/scheme_handler/module_scheme.rb', line 25 def (uri, composer) result = [] split_name, fqn = fqn_from_path(uri) # supports wild card in the module name case split_name[0] when '*' # create new URIs, one per module name that has a corresponding .rb file relative to its # '<root>/lib/puppet/bindings/' # composer.name_to_module.each_pair do | mod_name, mod | = [mod_name] + split_name[1..-1] = .join('::') if Puppet::Pops::Binder::BindingsLoader.loadable?(mod.path, ) result << URI.parse('module:/' + ) end end when nil raise ArgumentError, "Bad bindings uri, the #{uri} has neither module name or wildcard '*' in its first path position" else joined_name = split_name.join('::') # skip optional uri if it does not exist if is_optional?(uri) mod = composer.name_to_module[split_name[0]] if mod && Puppet::Binder::BindingsLoader.loadable?(mod.path, joined_name) result << URI.parse('module:/' + joined_name) end else # assume it exists (do not give error if not, since it may be excluded later) result << URI.parse('module:/' + joined_name) end end result end |