Class: Puppet::Pops::Binder::SchemeHandler::SymbolicScheme Abstract
- Inherits:
-
Puppet::Plugins::BindingSchemes::BindingsSchemeHandler
- Object
- Puppet::Plugins::BindingSchemes::BindingsSchemeHandler
- Puppet::Pops::Binder::SchemeHandler::SymbolicScheme
- Defined in:
- lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb
Overview
Abstract base class for schemes based on symbolic names of bindings. This class helps resolve symbolic names by computing a path from a fully qualified name (fqn). There are also helper methods do determine if the symbolic name contains a wild-card (‘*’) in the first portion of the fqn (with the convention that ‘*’ means ‘any module’).
Direct Known Subclasses
Instance Method Summary collapse
-
#contributed_bindings(uri, scope, composer) ⇒ Object
Shared implementation for module: and confdir: since the distinction is only in checks if a symbolic name exists as a loadable file or not.
- #fqn_from_path(uri) ⇒ Object private
- #has_wildcard?(uri) ⇒ Boolean private
-
#is_optional?(uri) ⇒ Boolean
True if super thinks it is optional or if it contains a wildcard.
Methods inherited from Puppet::Plugins::BindingSchemes::BindingsSchemeHandler
#expand_excluded, #expand_included
Instance Method Details
#contributed_bindings(uri, scope, composer) ⇒ Object
Shared implementation for module: and confdir: since the distinction is only in checks if a symbolic name exists as a loadable file or not. Once this method is called it is assumed that the name is relative and that it should exist relative to some loadable ruby location.
TODO: this needs to be changed once ARM-8 Puppet DSL concrete syntax is also supported.
18 19 20 21 22 23 24 25 |
# File 'lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb', line 18 def contributed_bindings(uri, scope, composer) fqn = fqn_from_path(uri)[1] bindings = Puppet::Pops::Binder::BindingsLoader.provide(scope, fqn) raise ArgumentError, "Cannot load bindings '#{uri}' - no bindings found." unless bindings # Must clone as the rest mutates the model cloned_bindings = Marshal.load(Marshal.dump(bindings)) Puppet::Pops::Binder::BindingsFactory.contributed_bindings(fqn, cloned_bindings) end |
#fqn_from_path(uri) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb', line 28 def fqn_from_path(uri) split_path = uri.path.split('/') if split_path.size > 1 && split_path[-1].empty? split_path.delete_at(-1) end fqn = split_path[ 1 ] raise ArgumentError, "Module scheme binding reference has no name." unless fqn split_name = fqn.split('::') # drop leading '::' split_name.shift if split_name[0] && split_name[0].empty? [split_name, split_name.join('::')] end |
#has_wildcard?(uri) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb', line 50 def has_wildcard?(uri) (path = uri.path) && path.split('/')[1].start_with?('*::') end |
#is_optional?(uri) ⇒ Boolean
True if super thinks it is optional or if it contains a wildcard.
45 46 47 |
# File 'lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb', line 45 def is_optional?(uri) super(uri) || has_wildcard?(uri) end |