Class: Puppet::Pops::Model::Factory Private
- Defined in:
- lib/puppet/pops/model/factory.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: ArgsToNonCallError
Constant Summary collapse
- STATEMENT_CALLS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'require' => true, 'realize' => true, 'include' => true, 'contain' => true, 'tag' => true, 'debug' => true, 'info' => true, 'notice' => true, 'warning' => true, 'err' => true, 'fail' => true, 'import' => true # discontinued, but transform it to make it call error reporting function }
- @@build_visitor =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
Shared build_visitor, since there are many instances of Factory being used
Visitor.new(self, "build")
- @@interpolation_visitor =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
Visitor.new(self, "interpolate")
Instance Attribute Summary collapse
- #current ⇒ Object (also: #model) private
Class Method Summary collapse
- .APPLICATION(name, parameters, body) ⇒ Object private
- .ATTR(name, type_expr = nil) ⇒ Object private
- .ATTRIBUTE_OP(name, op, expr) ⇒ Object private
- .ATTRIBUTES_OP(expr) ⇒ Object private
- .block(*args) ⇒ Object private
-
.block_or_expression(*args) ⇒ Object
private
Builds a BlockExpression if args size > 1, else the single expression/value in args.
- .CALL_METHOD(functor, argument_list) ⇒ Object private
- .CALL_NAMED(name, rval_required, argument_list) ⇒ Object private
- .CAPABILITY_MAPPING(kind, component, cap_name, mappings) ⇒ Object private
- .CASE(test_e, *options) ⇒ Object private
- .COLLECT(type_expr, query_expr, attribute_operations) ⇒ Object private
- .concat(*args) ⇒ Object private
- .DEFINITION(name, parameters, body) ⇒ Object private
- .ENUM(*args) ⇒ Object private
- .EPP(parameters, body) ⇒ Object private
- .EXPORTED_QUERY(query_expr) ⇒ Object private
-
.fqn(o) ⇒ Object
private
Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.
-
.fqr(o) ⇒ Object
private
Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.
- .FUNCTION(name, parameters, body) ⇒ Object private
- .HASH(entries) ⇒ Object private
- .HEREDOC(name, expr) ⇒ Object private
- .HOSTCLASS(name, parameters, parent, body) ⇒ Object private
- .IF(test_e, then_e, else_e) ⇒ Object private
- .KEY_ENTRY(key, val) ⇒ Object private
- .LAMBDA(parameters, body) ⇒ Object private
- .LIST(entries) ⇒ Object private
-
.literal(o) ⇒ Object
private
Factory starting points.
- .MAP(match, value) ⇒ Object private
- .minus(o) ⇒ Object private
- .NAMED_ACCESS(type_name, bodies) ⇒ Object private
- .NODE(hosts, parent, body) ⇒ Object private
- .nop?(o) ⇒ Boolean private
- .NUMBER(name_or_numeric) ⇒ Object private
- .PARAM(name, expr = nil) ⇒ Object private
- .PROGRAM(body, definitions, locator) ⇒ Object private
-
.QNAME(name) ⇒ Object
private
TODO: This is the same a fqn factory method, don’t know if callers to fqn and QNAME can live with the same result or not yet - refactor into one method when decided.
-
.QNAME_OR_NUMBER(name) ⇒ Object
private
Convert input string to either a qualified name, a LiteralInteger with radix, or a LiteralFloat.
- .QREF(name) ⇒ Object private
- .record_position(o, start_locatable, end_locateable) ⇒ Object private
- .RENDER_EXPR(expr) ⇒ Object private
-
.RENDER_STRING(o) ⇒ Object
private
TODO_EPP.
- .RESERVED(name, future = false) ⇒ Object private
- .RESOURCE(type_name, bodies) ⇒ Object private
- .RESOURCE_BODY(resource_title, attribute_operations) ⇒ Object private
- .RESOURCE_DEFAULTS(type_name, attribute_operations) ⇒ Object private
- .RESOURCE_OVERRIDE(resource_ref, attribute_operations) ⇒ Object private
-
.resource_shape(expr) ⇒ Object
private
Returns symbolic information about an expected shape of a resource expression given the LHS of a resource expr.
-
.set_resource_form(expr, form) ⇒ Object
private
Sets the form of the resource expression (:regular (the default), :virtual, or :exported).
- .SITE(body) ⇒ Object private
- .string(*args) ⇒ Object private
- .SUBLOCATE(token, expr) ⇒ Object private
- .TEXT(expr) ⇒ Object private
- .text(o) ⇒ Object private
-
.transform_calls(expressions) ⇒ Object
private
Transforms an array of expressions containing literal name expressions to calls if followed by an expression, or expression list.
-
.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_token) ⇒ Object
private
Transforms a left expression followed by an untitled resource (in the form of attribute_operations).
- .TYPE(name, super_name = nil) ⇒ Object private
- .TYPE_ALIAS(name, type_expr) ⇒ Object private
- .TYPE_DEFINITION(name, parent, body) ⇒ Object private
- .unfold(o) ⇒ Object private
- .UNLESS(test_e, then_e, else_e) ⇒ Object private
- .var(o) ⇒ Object private
- .VIRTUAL_QUERY(query_expr) ⇒ Object private
- .WHEN(values_list, block) ⇒ Object private
Instance Method Summary collapse
- #%(r) ⇒ Object private
- #*(r) ⇒ Object private
- #+(r) ⇒ Object private
- #-(r) ⇒ Object private
- #/(r) ⇒ Object private
- #<(r) ⇒ Object private
- #<<(r) ⇒ Object private
- #<=(r) ⇒ Object private
- #==(r) ⇒ Object private
- #=~(r) ⇒ Object private
- #>(r) ⇒ Object private
- #>=(r) ⇒ Object private
- #>>(r) ⇒ Object private
- #[](*r) ⇒ Object private
- #and(r) ⇒ Object private
- #attributes(*args) ⇒ Object private
-
#build(o, *args) ⇒ Object
private
Polymorphic build.
- #build_AccessExpression(o, left, *keys) ⇒ Object private
-
#build_Application(o, n, ps, body) ⇒ Object
private
Building of Model classes.
- #build_ArithmeticExpression(o, op, a, b) ⇒ Object private
-
#build_Array(o) ⇒ Object
private
Creates a LiteralList instruction from an Array, where the entries are built.
- #build_AssignmentExpression(o, op, a, b) ⇒ Object private
- #build_AttributeOperation(o, name, op, value) ⇒ Object private
- #build_AttributesOperation(o, value) ⇒ Object private
- #build_BinaryExpression(o, left, right) ⇒ Object private
- #build_BlockExpression(o, *args) ⇒ Object private
- #build_CallExpression(o, functor, rval_required, *args) ⇒ Object private
- #build_CallMethodExpression(o, functor, rval_required, lambda, *args) ⇒ Object private
- #build_CapabilityMapping(o, kind, component, capability, mappings) ⇒ Object private
- #build_CaseExpression(o, test, *args) ⇒ Object private
- #build_CaseOption(o, value_list, then_expr) ⇒ Object private
-
#build_Class(o, *args) ⇒ Object
private
Build a Class by creating an instance of it, and then calling build on the created instance with the given arguments.
- #build_CollectExpression(o, type_expr, query_expr, attribute_operations) ⇒ Object private
- #build_ComparisonExpression(o, op, a, b) ⇒ Object private
- #build_ConcatenatedString(o, *args) ⇒ Object private
- #build_CreateAttributeExpression(o, name, datatype_expr) ⇒ Object private
- #build_CreateEnumExpression(o, *args) ⇒ Object private
- #build_CreateTypeExpression(o, name, super_name = nil) ⇒ Object private
- #build_EppExpression(o, parameters_specified, body) ⇒ Object private
-
#build_Factory(o) ⇒ Object
private
If building a factory, simply unwrap the model oject contained in the factory.
- #build_FalseClass(o) ⇒ Object private
- #build_Fixnum(o) ⇒ Object private
- #build_Float(o) ⇒ Object private
-
#build_Hash(o) ⇒ Object
private
Create a LiteralHash instruction from a hash, where keys and values are built The hash entries are added in sorted order based on key.to_s.
- #build_HeredocExpression(o, name, expr) ⇒ Object private
-
#build_HostClassDefinition(o, name, parameters, parent_class_name, body) ⇒ HostClassDefinition
private
Configured from the parameters.
- #build_IfExpression(o, t, ift, els) ⇒ Object private
- #build_KeyedEntry(o, k, v) ⇒ Object private
- #build_LambdaExpression(o, parameters, body) ⇒ Object private
- #build_LiteralFloat(o, val) ⇒ Object private
- #build_LiteralHash(o, *keyed_entries) ⇒ Object private
- #build_LiteralInteger(o, val, radix) ⇒ Object private
- #build_LiteralList(o, *values) ⇒ Object private
- #build_MatchExpression(o, op, a, b) ⇒ Object private
- #build_NamedDefinition(o, name, parameters, body) ⇒ Object private
- #build_NilClass(o) ⇒ Object private
- #build_NodeDefinition(o, hosts, parent, body) ⇒ Object private
- #build_Parameter(o, name, expr) ⇒ Object private
- #build_Program(o, body, definitions, locator) ⇒ Object private
- #build_QualifiedName(o, name) ⇒ Object private
- #build_QualifiedReference(o, name) ⇒ Object private
- #build_QueryExpression(o, expr) ⇒ Object private
- #build_Regexp(o) ⇒ Object private
- #build_RelationshipExpression(o, op, a, b) ⇒ Object private
- #build_RenderStringExpression(o, string) ⇒ Object private
- #build_ReservedWord(o, name, future) ⇒ Object private
- #build_ResourceBody(o, title_expression, attribute_operations) ⇒ Object private
- #build_ResourceDefaultsExpression(o, type_ref, attribute_operations) ⇒ Object private
- #build_ResourceExpression(o, type_name, bodies) ⇒ Object private
- #build_ResourceOverrideExpression(o, resources, attribute_operations) ⇒ Object private
- #build_SelectorEntry(o, matching, value) ⇒ Object private
- #build_SelectorExpression(o, left, *selectors) ⇒ Object private
- #build_SiteDefinition(o, body) ⇒ Object private
-
#build_String(o) ⇒ Object
private
Building model equivalences of Ruby objects Allows passing regular ruby objects to the factory to produce instructions that when evaluated produce the same thing.
-
#build_SubLocatedExpression(o, token, expression) ⇒ Object
private
Builds a SubLocatedExpression - this wraps the expression in a sublocation configured from the given token A SubLocated holds its own locator that is used for subexpressions holding positions relative to what it describes.
-
#build_Symbol(o) ⇒ Object
private
Creates a String literal, unless the symbol is one of the special :undef, or :default which instead creates a LiterlUndef, or a LiteralDefault.
- #build_TokenValue(o) ⇒ Object private
- #build_TrueClass(o) ⇒ Object private
- #build_TypeAlias(o, name, type_expr) ⇒ Object private
- #build_TypeDefinition(o, name, parent, body) ⇒ Object private
- #build_UnaryExpression(o, expr) ⇒ Object private
-
#captures_rest ⇒ Object
private
Mark parameter as capturing the rest of arguments.
-
#default(r) ⇒ Object
private
For CaseExpression, setting the default for an already build CaseExpression.
- #dot(r) ⇒ Object private
- #f_arithmetic(op, r) ⇒ Object private
- #f_build_binary(klazz, left, right) ⇒ Object private
- #f_build_binary_op(klazz, op, left, right) ⇒ Object private
-
#f_build_body(body) ⇒ Object
private
Builds body :) from different kinds of input.
-
#f_build_unary(klazz, expr) ⇒ Object
private
Factory helpers.
- #f_build_vararg(klazz, left, *arg) ⇒ Object private
- #f_comparison(op, r) ⇒ Object private
- #f_match(op, r) ⇒ Object private
-
#in(r) ⇒ Object
private
Operator helpers.
-
#initialize(o, *args) ⇒ Factory
constructor
private
Initialize a factory with a single object, or a class with arguments applied to build of created instance.
-
#interpolate ⇒ Object
private
Polymorphic interpolate.
-
#interpolate_AccessExpression(o) ⇒ Object
private
rewrite left expression to variable if it is name, number, and recurse if it is an access expression this is for interpolation support in new lexer ($NAME, $NAME[}, $Factory.NUMBER, $NUMBER[] - all other expressions requires variables to be preceded with $.
-
#interpolate_CallMethodExpression(o) ⇒ Object
private
Rewrite method calls on the form $… to $$x$x.each.
- #interpolate_Factory(o) ⇒ Object private
- #interpolate_LiteralInteger(o) ⇒ Object private
- #interpolate_NamedAccessExpression(o) ⇒ Object private
- #interpolate_Object(o) ⇒ Object private
- #interpolate_QualifiedName(o) ⇒ Object private
- #is_interop_rewriteable?(o) ⇒ Boolean private
- #lambda=(lambda) ⇒ Object private
- #length ⇒ Object private
-
#loc ⇒ Puppet::Pops::Adapters::SourcePosAdapter
private
With location information.
-
#method_missing(meth, *args, &block) ⇒ Object
private
Catch all delegation to current.
- #minus ⇒ Object private
-
#minus_set(r) ⇒ Object
private
Assignment -=.
- #mne(r) ⇒ Object private
-
#name_is_statement(name) ⇒ Object
private
Returns true if the given name is a “statement keyword” (require, include, contain, error, notice, info, debug.
- #ne(r) ⇒ Object private
- #not ⇒ Object private
- #offset ⇒ Object private
- #or(r) ⇒ Object private
- #paren ⇒ Object private
-
#plus_set(r) ⇒ Object
private
Assignment +=.
-
#record_position(start_locatable, end_locatable) ⇒ Object
private
Records the position (start -> end) and computes the resulting length.
- #relop(op, r) ⇒ Object private
- #respond_to?(meth, include_all = false) ⇒ Boolean private
- #select(*args) ⇒ Object private
-
#set(r) ⇒ Object
private
Assignment =.
- #text ⇒ Object private
-
#to_ops(o, *args) ⇒ Object
private
Checks if the object is already a model object, or build it.
- #to_s ⇒ Object private
-
#type_expr(o) ⇒ Object
private
Set Expression that should evaluate to the parameter’s type.
- #unfold ⇒ Object private
- #var ⇒ Object private
Constructor Details
#initialize(o, *args) ⇒ Factory
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.
Initialize a factory with a single object, or a class with arguments applied to build of created instance
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/pops/model/factory.rb', line 23 def initialize(o, *args) @current = if o.instance_of?(Class) @@build_visitor.visit_this(self, o.new, args) elsif o.is_a?(PopsObject) o elsif o.instance_of?(Factory) o.current else @@build_visitor.visit_this(self, o, args) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ 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.
Catch all delegation to current
499 500 501 502 503 504 505 |
# File 'lib/puppet/pops/model/factory.rb', line 499 def method_missing(meth, *args, &block) if current.respond_to?(meth) current.send(meth, *args, &block) else super end end |
Instance Attribute Details
#current ⇒ Object Also known as: model
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.
12 13 14 |
# File 'lib/puppet/pops/model/factory.rb', line 12 def current @current end |
Class Method Details
.APPLICATION(name, parameters, body) ⇒ 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.
797 798 799 |
# File 'lib/puppet/pops/model/factory.rb', line 797 def self.APPLICATION(name, parameters, body) new(Application, name, parameters, body) end |
.ATTR(name, type_expr = nil) ⇒ 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.
603 |
# File 'lib/puppet/pops/model/factory.rb', line 603 def self.ATTR(name, type_expr=nil); new(CreateAttributeExpression, name, type_expr); end |
.ATTRIBUTE_OP(name, op, expr) ⇒ 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.
729 730 731 |
# File 'lib/puppet/pops/model/factory.rb', line 729 def self.ATTRIBUTE_OP(name, op, expr) new(AttributeOperation, name, op, expr) end |
.ATTRIBUTES_OP(expr) ⇒ 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.
733 734 735 |
# File 'lib/puppet/pops/model/factory.rb', line 733 def self.ATTRIBUTES_OP(expr) new(AttributesOperation, expr) end |
.block(*args) ⇒ 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.
585 |
# File 'lib/puppet/pops/model/factory.rb', line 585 def self.block(*args); new(BlockExpression, *args); end |
.block_or_expression(*args) ⇒ 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.
Builds a BlockExpression if args size > 1, else the single expression/value in args
777 778 779 780 781 782 783 |
# File 'lib/puppet/pops/model/factory.rb', line 777 def self.block_or_expression(*args) if args.size > 1 new(BlockExpression, *args) else new(args[0]) end end |
.CALL_METHOD(functor, argument_list) ⇒ 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.
744 745 746 |
# File 'lib/puppet/pops/model/factory.rb', line 744 def self.CALL_METHOD(functor, argument_list) new(CallMethodExpression, functor, true, nil, *argument_list) end |
.CALL_NAMED(name, rval_required, argument_list) ⇒ 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.
737 738 739 740 741 742 |
# File 'lib/puppet/pops/model/factory.rb', line 737 def self.CALL_NAMED(name, rval_required, argument_list) unless name.kind_of?(PopsObject) name = Factory.fqn(name) unless name.instance_of?(Factory) end new(CallNamedFunctionExpression, name, rval_required, *argument_list) end |
.CAPABILITY_MAPPING(kind, component, cap_name, mappings) ⇒ 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.
793 794 795 |
# File 'lib/puppet/pops/model/factory.rb', line 793 def self.CAPABILITY_MAPPING(kind, component, cap_name, mappings) new(CapabilityMapping, kind, component, cap_name, mappings) end |
.CASE(test_e, *options) ⇒ 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.
595 |
# File 'lib/puppet/pops/model/factory.rb', line 595 def self.CASE(test_e,*); new(CaseExpression, test_e, *); end |
.COLLECT(type_expr, query_expr, attribute_operations) ⇒ 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.
748 749 750 |
# File 'lib/puppet/pops/model/factory.rb', line 748 def self.COLLECT(type_expr, query_expr, attribute_operations) new(CollectExpression, type_expr, query_expr, attribute_operations) end |
.concat(*args) ⇒ 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.
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
# File 'lib/puppet/pops/model/factory.rb', line 1096 def self.concat(*args) new(args.map do |e| e = e.current if e.is_a?(self) case e when LiteralString e.value when String e else raise ArgumentError, "can only concatenate strings, got #{e.class}" end end.join('')) end |
.DEFINITION(name, parameters, body) ⇒ 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.
789 790 791 |
# File 'lib/puppet/pops/model/factory.rb', line 789 def self.DEFINITION(name, parameters, body) new(ResourceTypeDefinition, name, parameters, body) end |
.ENUM(*args) ⇒ 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.
605 |
# File 'lib/puppet/pops/model/factory.rb', line 605 def self.ENUM(*args); new(CreateEnumExpression, *args); end |
.EPP(parameters, body) ⇒ 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.
666 667 668 669 670 671 672 673 674 675 |
# File 'lib/puppet/pops/model/factory.rb', line 666 def self.EPP(parameters, body) if parameters.nil? params = [] parameters_specified = false else params = parameters parameters_specified = true end LAMBDA(params, new(EppExpression, parameters_specified, body)) end |
.EXPORTED_QUERY(query_expr) ⇒ 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.
725 726 727 |
# File 'lib/puppet/pops/model/factory.rb', line 725 def self.EXPORTED_QUERY(query_expr) new(ExportedQuery, query_expr) end |
.fqn(o) ⇒ 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.
Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.
638 639 640 641 642 |
# File 'lib/puppet/pops/model/factory.rb', line 638 def self.fqn(o) o = o.current if o.instance_of?(Factory) o = new(QualifiedName, o) unless o.is_a? QualifiedName o end |
.fqr(o) ⇒ 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.
Creates a QualifiedName representation of o, unless o already represents a QualifiedName in which case it is returned.
647 648 649 650 651 |
# File 'lib/puppet/pops/model/factory.rb', line 647 def self.fqr(o) o = o.current if o.instance_of?(Factory) o = new(QualifiedReference, o) unless o.is_a? QualifiedReference o end |
.FUNCTION(name, parameters, body) ⇒ 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.
801 802 803 |
# File 'lib/puppet/pops/model/factory.rb', line 801 def self.FUNCTION(name, parameters, body) new(FunctionDefinition, name, parameters, body) end |
.HASH(entries) ⇒ 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.
609 |
# File 'lib/puppet/pops/model/factory.rb', line 609 def self.HASH(entries); new(LiteralHash, *entries); end |
.HEREDOC(name, expr) ⇒ 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.
611 |
# File 'lib/puppet/pops/model/factory.rb', line 611 def self.HEREDOC(name, expr); new(HeredocExpression, name, expr); end |
.HOSTCLASS(name, parameters, parent, body) ⇒ 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.
785 786 787 |
# File 'lib/puppet/pops/model/factory.rb', line 785 def self.HOSTCLASS(name, parameters, parent, body) new(HostClassDefinition, name, parameters, parent, body) end |
.IF(test_e, then_e, else_e) ⇒ 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.
591 |
# File 'lib/puppet/pops/model/factory.rb', line 591 def self.IF(test_e,then_e,else_e); new(IfExpression, test_e, then_e, else_e); end |
.KEY_ENTRY(key, val) ⇒ 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.
607 |
# File 'lib/puppet/pops/model/factory.rb', line 607 def self.KEY_ENTRY(key, val); new(KeyedEntry, key, val); end |
.LAMBDA(parameters, body) ⇒ 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.
805 806 807 |
# File 'lib/puppet/pops/model/factory.rb', line 805 def self.LAMBDA(parameters, body) new(LambdaExpression, parameters, body) end |
.LIST(entries) ⇒ 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.
615 |
# File 'lib/puppet/pops/model/factory.rb', line 615 def self.LIST(entries); new(LiteralList, *entries); end |
.literal(o) ⇒ 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.
Factory starting points
577 |
# File 'lib/puppet/pops/model/factory.rb', line 577 def self.literal(o); new(o); end |
.MAP(match, value) ⇒ 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.
599 |
# File 'lib/puppet/pops/model/factory.rb', line 599 def self.MAP(match, value); new(SelectorEntry, match, value); end |
.minus(o) ⇒ 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.
579 |
# File 'lib/puppet/pops/model/factory.rb', line 579 def self.minus(o); new(o).minus; end |
.NAMED_ACCESS(type_name, bodies) ⇒ 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.
752 753 754 |
# File 'lib/puppet/pops/model/factory.rb', line 752 def self.NAMED_ACCESS(type_name, bodies) new(NamedAccessExpression, type_name, bodies) end |
.NODE(hosts, parent, body) ⇒ 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.
619 |
# File 'lib/puppet/pops/model/factory.rb', line 619 def self.NODE(hosts, parent, body); new(NodeDefinition, hosts, parent, body); end |
.nop?(o) ⇒ 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.
817 818 819 |
# File 'lib/puppet/pops/model/factory.rb', line 817 def self.nop? o o.nil? || o.is_a?(Nop) end |
.NUMBER(name_or_numeric) ⇒ 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.
688 689 690 691 692 693 694 695 696 697 698 699 700 |
# File 'lib/puppet/pops/model/factory.rb', line 688 def self.NUMBER(name_or_numeric) if n_radix = Utils.to_n_with_radix(name_or_numeric) val, radix = n_radix if val.is_a?(Float) new(LiteralFloat, val) else new(LiteralInteger, val, radix) end else # Bad number should already have been caught by lexer - this should never happen raise ArgumentError, "Internal Error, NUMBER token does not contain a valid number, #{name_or_numeric}" end end |
.PARAM(name, expr = nil) ⇒ 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.
617 |
# File 'lib/puppet/pops/model/factory.rb', line 617 def self.PARAM(name, expr=nil); new(Parameter, name, expr); end |
.PROGRAM(body, definitions, locator) ⇒ 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.
772 773 774 |
# File 'lib/puppet/pops/model/factory.rb', line 772 def self.PROGRAM(body, definitions, locator) new(Program, body, definitions, locator) end |
.QNAME(name) ⇒ 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.
TODO: This is the same a fqn factory method, don’t know if callers to fqn and QNAME can live with the same result or not yet - refactor into one method when decided.
684 685 686 |
# File 'lib/puppet/pops/model/factory.rb', line 684 def self.QNAME(name) new(QualifiedName, name) end |
.QNAME_OR_NUMBER(name) ⇒ 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.
Convert input string to either a qualified name, a LiteralInteger with radix, or a LiteralFloat
704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'lib/puppet/pops/model/factory.rb', line 704 def self.QNAME_OR_NUMBER(name) if n_radix = Utils.to_n_with_radix(name) val, radix = n_radix if val.is_a?(Float) new(LiteralFloat, val) else new(LiteralInteger, val, radix) end else new(QualifiedName, name) end end |
.QREF(name) ⇒ 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.
717 718 719 |
# File 'lib/puppet/pops/model/factory.rb', line 717 def self.QREF(name) new(QualifiedReference, name) end |
.record_position(o, start_locatable, end_locateable) ⇒ 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.
511 512 513 |
# File 'lib/puppet/pops/model/factory.rb', line 511 def self.record_position(o, start_locatable, end_locateable) new(o).record_position(start_locatable, end_locateable) end |
.RENDER_EXPR(expr) ⇒ 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.
662 663 664 |
# File 'lib/puppet/pops/model/factory.rb', line 662 def self.RENDER_EXPR(expr) new(RenderExpression, expr) end |
.RENDER_STRING(o) ⇒ 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.
TODO_EPP
658 659 660 |
# File 'lib/puppet/pops/model/factory.rb', line 658 def self.RENDER_STRING(o) new(RenderStringExpression, o) end |
.RESERVED(name, future = false) ⇒ 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.
677 678 679 |
# File 'lib/puppet/pops/model/factory.rb', line 677 def self.RESERVED(name, future=false) new(ReservedWord, name, future) end |
.RESOURCE(type_name, bodies) ⇒ 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.
756 757 758 |
# File 'lib/puppet/pops/model/factory.rb', line 756 def self.RESOURCE(type_name, bodies) new(ResourceExpression, type_name, bodies) end |
.RESOURCE_BODY(resource_title, attribute_operations) ⇒ 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.
768 769 770 |
# File 'lib/puppet/pops/model/factory.rb', line 768 def self.RESOURCE_BODY(resource_title, attribute_operations) new(ResourceBody, resource_title, attribute_operations) end |
.RESOURCE_DEFAULTS(type_name, attribute_operations) ⇒ 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.
760 761 762 |
# File 'lib/puppet/pops/model/factory.rb', line 760 def self.RESOURCE_DEFAULTS(type_name, attribute_operations) new(ResourceDefaultsExpression, type_name, attribute_operations) end |
.RESOURCE_OVERRIDE(resource_ref, attribute_operations) ⇒ 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.
764 765 766 |
# File 'lib/puppet/pops/model/factory.rb', line 764 def self.RESOURCE_OVERRIDE(resource_ref, attribute_operations) new(ResourceOverrideExpression, resource_ref, attribute_operations) end |
.resource_shape(expr) ⇒ 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.
Returns symbolic information about an expected shape of a resource expression given the LHS of a resource expr.
-
‘name { }` => `:resource`, create a resource of the given type
-
‘Name { }` => ’:defaults`, set defaults for the referenced type
-
‘Name[] { }` => `:override`, overrides instances referenced by LHS
-
_any other_ => ‘:error’, all other are considered illegal
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/puppet/pops/model/factory.rb', line 555 def self.resource_shape(expr) expr = expr.current if expr.instance_of?(Factory) case expr when QualifiedName :resource when QualifiedReference :defaults when AccessExpression # if Resource[e], then it is not resource specific if expr.left_expr.is_a?(QualifiedReference) && expr.left_expr.value == 'resource' && expr.keys.size == 1 :defaults else :override end when 'class' :class else :error end end |
.set_resource_form(expr, form) ⇒ 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.
Sets the form of the resource expression (:regular (the default), :virtual, or :exported). Produces true if the expression was a resource expression, false otherwise.
540 541 542 543 544 545 546 |
# File 'lib/puppet/pops/model/factory.rb', line 540 def self.set_resource_form(expr, form) expr = expr.current if expr.instance_of?(Factory) # Note: Validation handles illegal combinations return false unless expr.is_a?(AbstractResource) expr.form = form return true end |
.SITE(body) ⇒ 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.
621 |
# File 'lib/puppet/pops/model/factory.rb', line 621 def self.SITE(body); new(SiteDefinition, body); end |
.string(*args) ⇒ 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.
587 |
# File 'lib/puppet/pops/model/factory.rb', line 587 def self.string(*args); new(ConcatenatedString, *args); end |
.SUBLOCATE(token, expr) ⇒ 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.
613 |
# File 'lib/puppet/pops/model/factory.rb', line 613 def self.SUBLOCATE(token, expr) new(SubLocatedExpression, token, expr); end |
.TEXT(expr) ⇒ 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.
653 654 655 |
# File 'lib/puppet/pops/model/factory.rb', line 653 def self.TEXT(expr) new(TextExpression, new(expr).interpolate) end |
.text(o) ⇒ 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.
589 |
# File 'lib/puppet/pops/model/factory.rb', line 589 def self.text(o); new(o).text; end |
.transform_calls(expressions) ⇒ 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.
Transforms an array of expressions containing literal name expressions to calls if followed by an expression, or expression list.
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
# File 'lib/puppet/pops/model/factory.rb', line 855 def self.transform_calls(expressions) expressions.reduce([]) do |memo, expr| expr = expr.current if expr.instance_of?(Factory) name = memo[-1] if name.is_a?(QualifiedName) && STATEMENT_CALLS[name.value] if expr.is_a?(Array) expr = expr.reject {|e| e.is_a?(Parser::LexerSupport::TokenValue) } else expr = [expr] end the_call = Factory.CALL_NAMED(name, false, expr) # last positioned is last arg if there are several record_position(the_call, name, expr.is_a?(Array) ? expr[-1] : expr) memo[-1] = the_call if expr.is_a?(CallNamedFunctionExpression) # Patch statement function call to expression style # This is needed because it is first parsed as a "statement" and the requirement changes as it becomes # an argument to the name to call transform above. expr.rval_required = true end elsif expr.is_a?(Array) raise ArgsToNonCallError.new(expr, name) else memo << expr if expr.is_a?(CallNamedFunctionExpression) # Patch rvalue expression function call to statement style. # This is not really required but done to be AST model compliant expr.rval_required = false end end memo end end |
.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_token) ⇒ 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.
Transforms a left expression followed by an untitled resource (in the form of attribute_operations)
892 893 894 895 896 897 898 899 900 901 902 903 904 |
# File 'lib/puppet/pops/model/factory.rb', line 892 def self.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_token) # Returning nil means accepting the given as a potential resource expression return nil unless attribute_ops.is_a? Array return nil unless left.current.is_a?(QualifiedName) keyed_entries = attribute_ops.map do |ao| return nil if ao.operator == :'+>' KEY_ENTRY(ao.attribute_name, ao.value_expr) end a_hash = HASH(keyed_entries) a_hash.record_position(lbrace_token, rbrace_token) result = block_or_expression(*transform_calls([left, a_hash])) result end |
.TYPE(name, super_name = nil) ⇒ 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.
601 |
# File 'lib/puppet/pops/model/factory.rb', line 601 def self.TYPE(name, super_name=nil); new(CreateTypeExpression, name, super_name); end |
.TYPE_ALIAS(name, type_expr) ⇒ 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.
809 810 811 |
# File 'lib/puppet/pops/model/factory.rb', line 809 def self.TYPE_ALIAS(name, type_expr) new(TypeAlias, name, type_expr) end |
.TYPE_DEFINITION(name, parent, body) ⇒ 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.
813 814 815 |
# File 'lib/puppet/pops/model/factory.rb', line 813 def self.TYPE_DEFINITION(name, parent, body) new(TypeDefinition, name, parent, body) end |
.unfold(o) ⇒ 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.
581 |
# File 'lib/puppet/pops/model/factory.rb', line 581 def self.unfold(o); new(o).unfold; end |
.UNLESS(test_e, then_e, else_e) ⇒ 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.
593 |
# File 'lib/puppet/pops/model/factory.rb', line 593 def self.UNLESS(test_e,then_e,else_e); new(UnlessExpression, test_e, then_e, else_e); end |
.var(o) ⇒ 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.
583 |
# File 'lib/puppet/pops/model/factory.rb', line 583 def self.var(o); new(o).var; end |
.VIRTUAL_QUERY(query_expr) ⇒ 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.
721 722 723 |
# File 'lib/puppet/pops/model/factory.rb', line 721 def self.VIRTUAL_QUERY(query_expr) new(VirtualQuery, query_expr) end |
.WHEN(values_list, block) ⇒ 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.
597 |
# File 'lib/puppet/pops/model/factory.rb', line 597 def self.WHEN(values_list, block); new(CaseOption, values_list, block); end |
Instance Method Details
#%(r) ⇒ 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.
435 |
# File 'lib/puppet/pops/model/factory.rb', line 435 def % r; f_arithmetic(:%, r); end |
#*(r) ⇒ 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.
433 |
# File 'lib/puppet/pops/model/factory.rb', line 433 def * r; f_arithmetic(:*, r); end |
#+(r) ⇒ 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.
427 |
# File 'lib/puppet/pops/model/factory.rb', line 427 def + r; f_arithmetic(:+, r); end |
#-(r) ⇒ 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.
429 |
# File 'lib/puppet/pops/model/factory.rb', line 429 def - r; f_arithmetic(:-, r); end |
#/(r) ⇒ 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.
431 |
# File 'lib/puppet/pops/model/factory.rb', line 431 def / r; f_arithmetic(:/, r); end |
#<(r) ⇒ 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.
441 |
# File 'lib/puppet/pops/model/factory.rb', line 441 def < r; f_comparison(:<, r); end |
#<<(r) ⇒ 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.
437 |
# File 'lib/puppet/pops/model/factory.rb', line 437 def << r; f_arithmetic(:<<, r); end |
#<=(r) ⇒ 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.
443 |
# File 'lib/puppet/pops/model/factory.rb', line 443 def <= r; f_comparison(:<=, r); end |
#==(r) ⇒ 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.
449 |
# File 'lib/puppet/pops/model/factory.rb', line 449 def == r; f_comparison(:==, r); end |
#=~(r) ⇒ 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.
453 |
# File 'lib/puppet/pops/model/factory.rb', line 453 def =~ r; f_match(:'=~', r); end |
#>(r) ⇒ 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.
445 |
# File 'lib/puppet/pops/model/factory.rb', line 445 def > r; f_comparison(:>, r); end |
#>=(r) ⇒ 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.
447 |
# File 'lib/puppet/pops/model/factory.rb', line 447 def >= r; f_comparison(:>=, r); end |
#>>(r) ⇒ 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.
439 |
# File 'lib/puppet/pops/model/factory.rb', line 439 def >> r; f_arithmetic(:>>, r); end |
#[](*r) ⇒ 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.
423 |
# File 'lib/puppet/pops/model/factory.rb', line 423 def [](*r); f_build_vararg(AccessExpression, current, *r); end |
#and(r) ⇒ 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.
411 |
# File 'lib/puppet/pops/model/factory.rb', line 411 def and(r) f_build_binary(AndExpression, current, r); end |
#attributes(*args) ⇒ 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.
493 494 495 496 |
# File 'lib/puppet/pops/model/factory.rb', line 493 def attributes(*args) args.each {|a| current.addAttributes(build(a)) } self end |
#build(o, *args) ⇒ 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.
Polymorphic build
36 37 38 |
# File 'lib/puppet/pops/model/factory.rb', line 36 def build(o, *args) @@build_visitor.visit_this(self, o, args) end |
#build_AccessExpression(o, left, *keys) ⇒ 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.
77 78 79 80 81 |
# File 'lib/puppet/pops/model/factory.rb', line 77 def build_AccessExpression(o, left, *keys) o.left_expr = to_ops(left) o.keys = keys.map {|expr| to_ops(expr) } o end |
#build_Application(o, n, ps, body) ⇒ 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.
Building of Model classes
47 48 49 50 51 52 53 |
# File 'lib/puppet/pops/model/factory.rb', line 47 def build_Application(o, n, ps, body) o.name = n ps.each { |p| o.addParameters(build(p)) } b = f_build_body(body) o.body = b.current if b o end |
#build_ArithmeticExpression(o, op, a, b) ⇒ 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.
55 56 57 58 |
# File 'lib/puppet/pops/model/factory.rb', line 55 def build_ArithmeticExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end |
#build_Array(o) ⇒ 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.
Creates a LiteralList instruction from an Array, where the entries are built.
979 980 981 982 983 |
# File 'lib/puppet/pops/model/factory.rb', line 979 def build_Array(o) x = LiteralList.new o.each { |v| x.addValues(build(v)) } x end |
#build_AssignmentExpression(o, op, a, b) ⇒ 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.
60 61 62 63 |
# File 'lib/puppet/pops/model/factory.rb', line 60 def build_AssignmentExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end |
#build_AttributeOperation(o, name, op, value) ⇒ 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.
65 66 67 68 69 70 |
# File 'lib/puppet/pops/model/factory.rb', line 65 def build_AttributeOperation(o, name, op, value) o.operator = op o.attribute_name = name.to_s # BOOLEAN is allowed in the grammar o.value_expr = build(value) o end |
#build_AttributesOperation(o, value) ⇒ 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.
72 73 74 75 |
# File 'lib/puppet/pops/model/factory.rb', line 72 def build_AttributesOperation(o, value) o.expr = build(value) o end |
#build_BinaryExpression(o, left, right) ⇒ 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.
83 84 85 86 87 |
# File 'lib/puppet/pops/model/factory.rb', line 83 def build_BinaryExpression(o, left, right) o.left_expr = to_ops(left) o.right_expr = to_ops(right) o end |
#build_BlockExpression(o, *args) ⇒ 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.
89 90 91 92 |
# File 'lib/puppet/pops/model/factory.rb', line 89 def build_BlockExpression(o, *args) o.statements = args.map {|expr| to_ops(expr) } o end |
#build_CallExpression(o, functor, rval_required, *args) ⇒ 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.
995 996 997 998 999 1000 |
# File 'lib/puppet/pops/model/factory.rb', line 995 def build_CallExpression(o, functor, rval_required, *args) o.functor_expr = to_ops(functor) o.rval_required = rval_required args.each {|x| o.addArguments(to_ops(x)) } o end |
#build_CallMethodExpression(o, functor, rval_required, lambda, *args) ⇒ 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.
1002 1003 1004 1005 1006 |
# File 'lib/puppet/pops/model/factory.rb', line 1002 def build_CallMethodExpression(o, functor, rval_required, lambda, *args) build_CallExpression(o, functor, rval_required, *args) o.lambda = lambda o end |
#build_CapabilityMapping(o, kind, component, capability, mappings) ⇒ 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.
233 234 235 236 237 238 239 240 |
# File 'lib/puppet/pops/model/factory.rb', line 233 def build_CapabilityMapping(o, kind, component, capability, mappings) o.kind = kind component = component.current if component.instance_of?(Factory) o.component = component o.capability = capability o.mappings = mappings.map { |m| build(m) } o end |
#build_CaseExpression(o, test, *args) ⇒ 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.
1008 1009 1010 1011 1012 |
# File 'lib/puppet/pops/model/factory.rb', line 1008 def build_CaseExpression(o, test, *args) o.test = build(test) args.each {|opt| o.addOptions(build(opt)) } o end |
#build_CaseOption(o, value_list, then_expr) ⇒ 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.
1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/puppet/pops/model/factory.rb', line 1014 def build_CaseOption(o, value_list, then_expr) value_list = [value_list] unless value_list.is_a? Array value_list.each { |v| o.addValues(build(v)) } b = f_build_body(then_expr) o.then_expr = to_ops(b) if b o end |
#build_Class(o, *args) ⇒ 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.
Build a Class by creating an instance of it, and then calling build on the created instance with the given arguments
1024 1025 1026 |
# File 'lib/puppet/pops/model/factory.rb', line 1024 def build_Class(o, *args) build(o.new(), *args) end |
#build_CollectExpression(o, type_expr, query_expr, attribute_operations) ⇒ 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.
94 95 96 97 98 99 |
# File 'lib/puppet/pops/model/factory.rb', line 94 def build_CollectExpression(o, type_expr, query_expr, attribute_operations) o.type_expr = to_ops(type_expr) o.query = build(query_expr) o.operations = attribute_operations.map {|op| build(op) } o end |
#build_ComparisonExpression(o, op, a, b) ⇒ 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.
101 102 103 104 |
# File 'lib/puppet/pops/model/factory.rb', line 101 def build_ComparisonExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end |
#build_ConcatenatedString(o, *args) ⇒ 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.
106 107 108 109 |
# File 'lib/puppet/pops/model/factory.rb', line 106 def build_ConcatenatedString(o, *args) o.segments = args.map {|expr| build(expr) } o end |
#build_CreateAttributeExpression(o, name, datatype_expr) ⇒ 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.
123 124 125 126 127 |
# File 'lib/puppet/pops/model/factory.rb', line 123 def build_CreateAttributeExpression(o, name, datatype_expr) o.name = name o.type = to_ops(datatype_expr) o end |
#build_CreateEnumExpression(o, *args) ⇒ 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.
117 118 119 120 121 |
# File 'lib/puppet/pops/model/factory.rb', line 117 def build_CreateEnumExpression(o, *args) o.name = args.slice(0) if args.size == 2 o.values = build(args.last) o end |
#build_CreateTypeExpression(o, name, super_name = nil) ⇒ 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.
111 112 113 114 115 |
# File 'lib/puppet/pops/model/factory.rb', line 111 def build_CreateTypeExpression(o, name, super_name = nil) o.name = name o.super_name = super_name o end |
#build_EppExpression(o, parameters_specified, body) ⇒ 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.
952 953 954 955 956 957 |
# File 'lib/puppet/pops/model/factory.rb', line 952 def build_EppExpression(o, parameters_specified, body) o.parameters_specified = parameters_specified b = f_build_body(body) o.body = b.current if b o end |
#build_Factory(o) ⇒ 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.
If building a factory, simply unwrap the model oject contained in the factory.
960 961 962 |
# File 'lib/puppet/pops/model/factory.rb', line 960 def build_Factory(o) o.current end |
#build_FalseClass(o) ⇒ 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.
928 929 930 931 932 |
# File 'lib/puppet/pops/model/factory.rb', line 928 def build_FalseClass(o) x = LiteralBoolean.new x.value = o x end |
#build_Fixnum(o) ⇒ 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.
934 935 936 937 938 |
# File 'lib/puppet/pops/model/factory.rb', line 934 def build_Fixnum(o) x = LiteralInteger.new x.value = o; x end |
#build_Float(o) ⇒ 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.
940 941 942 943 944 |
# File 'lib/puppet/pops/model/factory.rb', line 940 def build_Float(o) x = LiteralFloat.new x.value = o; x end |
#build_Hash(o) ⇒ 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.
Create a LiteralHash instruction from a hash, where keys and values are built The hash entries are added in sorted order based on key.to_s
988 989 990 991 992 |
# File 'lib/puppet/pops/model/factory.rb', line 988 def build_Hash(o) x = LiteralHash.new (o.sort_by {|k,v| k.to_s}).each {|k,v| x.addEntries(build(KeyedEntry.new, k, v)) } x end |
#build_HeredocExpression(o, name, expr) ⇒ 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.
129 130 131 132 133 |
# File 'lib/puppet/pops/model/factory.rb', line 129 def build_HeredocExpression(o, name, expr) o.syntax = name o.text_expr = build(expr) o end |
#build_HostClassDefinition(o, name, parameters, parent_class_name, body) ⇒ HostClassDefinition
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.
Returns configured from the parameters.
141 142 143 144 145 |
# File 'lib/puppet/pops/model/factory.rb', line 141 def build_HostClassDefinition(o, name, parameters, parent_class_name, body) build_NamedDefinition(o, name, parameters, body) o.parent_class = parent_class_name if parent_class_name o end |
#build_IfExpression(o, t, ift, els) ⇒ 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.
186 187 188 189 190 191 |
# File 'lib/puppet/pops/model/factory.rb', line 186 def build_IfExpression(o, t, ift, els) o.test = build(t) o.then_expr = build(ift) o.else_expr= build(els) o end |
#build_KeyedEntry(o, k, v) ⇒ 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.
159 160 161 162 163 |
# File 'lib/puppet/pops/model/factory.rb', line 159 def build_KeyedEntry(o, k, v) o.key = to_ops(k) o.value = to_ops(v) o end |
#build_LambdaExpression(o, parameters, body) ⇒ 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.
218 219 220 221 222 223 |
# File 'lib/puppet/pops/model/factory.rb', line 218 def build_LambdaExpression(o, parameters, body) o.parameters = parameters.map {|p| build(p) } b = f_build_body(body) o.body = to_ops(b) if b o end |
#build_LiteralFloat(o, val) ⇒ 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.
175 176 177 178 |
# File 'lib/puppet/pops/model/factory.rb', line 175 def build_LiteralFloat(o, val) o.value = val o end |
#build_LiteralHash(o, *keyed_entries) ⇒ 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.
165 166 167 168 |
# File 'lib/puppet/pops/model/factory.rb', line 165 def build_LiteralHash(o, *keyed_entries) o.entries = keyed_entries.map {|entry| build(entry) } o end |
#build_LiteralInteger(o, val, radix) ⇒ 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.
180 181 182 183 184 |
# File 'lib/puppet/pops/model/factory.rb', line 180 def build_LiteralInteger(o, val, radix) o.value = val o.radix = radix o end |
#build_LiteralList(o, *values) ⇒ 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.
170 171 172 173 |
# File 'lib/puppet/pops/model/factory.rb', line 170 def build_LiteralList(o, *values) o.values = values.map {|v| build(v) } o end |
#build_MatchExpression(o, op, a, b) ⇒ 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.
193 194 195 196 |
# File 'lib/puppet/pops/model/factory.rb', line 193 def build_MatchExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end |
#build_NamedDefinition(o, name, parameters, body) ⇒ 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.
225 226 227 228 229 230 231 |
# File 'lib/puppet/pops/model/factory.rb', line 225 def build_NamedDefinition(o, name, parameters, body) o.parameters = parameters.map {|p| build(p) } b = f_build_body(body) o.body = b.current if b o.name = name o end |
#build_NilClass(o) ⇒ 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.
917 918 919 920 |
# File 'lib/puppet/pops/model/factory.rb', line 917 def build_NilClass(o) x = Nop.new x end |
#build_NodeDefinition(o, hosts, parent, body) ⇒ 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.
246 247 248 249 250 251 252 |
# File 'lib/puppet/pops/model/factory.rb', line 246 def build_NodeDefinition(o, hosts, parent, body) o.host_matches = hosts.map {|h| build(h) } o.parent = build(parent) if parent # no nop here b = f_build_body(body) o.body = b.current if b o end |
#build_Parameter(o, name, expr) ⇒ 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.
262 263 264 265 266 |
# File 'lib/puppet/pops/model/factory.rb', line 262 def build_Parameter(o, name, expr) o.name = name o.value = build(expr) if expr # don't build a nil/nop o end |
#build_Program(o, body, definitions, locator) ⇒ 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.
357 358 359 360 361 362 363 364 365 366 |
# File 'lib/puppet/pops/model/factory.rb', line 357 def build_Program(o, body, definitions, locator) o.body = to_ops(body) # non containment o.definitions = definitions o.source_ref = locator.file o.source_text = locator.string o.line_offsets = locator.line_index o.locator = locator o end |
#build_QualifiedName(o, name) ⇒ 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.
368 369 370 371 |
# File 'lib/puppet/pops/model/factory.rb', line 368 def build_QualifiedName(o, name) o.value = name.to_s o end |
#build_QualifiedReference(o, name) ⇒ 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.
268 269 270 271 |
# File 'lib/puppet/pops/model/factory.rb', line 268 def build_QualifiedReference(o, name) o.value = name.to_s.downcase o end |
#build_QueryExpression(o, expr) ⇒ 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.
331 332 333 334 335 |
# File 'lib/puppet/pops/model/factory.rb', line 331 def build_QueryExpression(o, expr) ops = to_ops(expr) o.expr = ops unless Factory.nop? ops o end |
#build_Regexp(o) ⇒ 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.
946 947 948 949 950 |
# File 'lib/puppet/pops/model/factory.rb', line 946 def build_Regexp(o) x = LiteralRegularExpression.new x.value = o; x end |
#build_RelationshipExpression(o, op, a, b) ⇒ 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.
273 274 275 276 |
# File 'lib/puppet/pops/model/factory.rb', line 273 def build_RelationshipExpression(o, op, a, b) o.operator = op build_BinaryExpression(o, a, b) end |
#build_RenderStringExpression(o, string) ⇒ 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.
284 285 286 287 |
# File 'lib/puppet/pops/model/factory.rb', line 284 def build_RenderStringExpression(o, string) o.value = string; o end |
#build_ReservedWord(o, name, future) ⇒ 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.
153 154 155 156 157 |
# File 'lib/puppet/pops/model/factory.rb', line 153 def build_ReservedWord(o, name, future) o.word = name o.future = future o end |
#build_ResourceBody(o, title_expression, attribute_operations) ⇒ 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.
289 290 291 292 293 |
# File 'lib/puppet/pops/model/factory.rb', line 289 def build_ResourceBody(o, title_expression, attribute_operations) o.title = build(title_expression) o.operations = attribute_operations.map {|ao| build(ao) } o end |
#build_ResourceDefaultsExpression(o, type_ref, attribute_operations) ⇒ 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.
295 296 297 298 299 |
# File 'lib/puppet/pops/model/factory.rb', line 295 def build_ResourceDefaultsExpression(o, type_ref, attribute_operations) o.type_ref = build(type_ref) o.operations = attribute_operations.map {|ao| build(ao) } o end |
#build_ResourceExpression(o, type_name, bodies) ⇒ 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.
278 279 280 281 282 |
# File 'lib/puppet/pops/model/factory.rb', line 278 def build_ResourceExpression(o, type_name, bodies) o.type_name = build(type_name) o.bodies = bodies.map {|b| build(b) } o end |
#build_ResourceOverrideExpression(o, resources, attribute_operations) ⇒ 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.
147 148 149 150 151 |
# File 'lib/puppet/pops/model/factory.rb', line 147 def build_ResourceOverrideExpression(o, resources, attribute_operations) o.resources = build(resources) o.operations = attribute_operations.map {|ao| build(ao) } o end |
#build_SelectorEntry(o, matching, value) ⇒ 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.
325 326 327 328 329 |
# File 'lib/puppet/pops/model/factory.rb', line 325 def build_SelectorEntry(o, matching, value) o.matching_expr = build(matching) o.value_expr = build(value) o end |
#build_SelectorExpression(o, left, *selectors) ⇒ 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.
301 302 303 304 305 |
# File 'lib/puppet/pops/model/factory.rb', line 301 def build_SelectorExpression(o, left, *selectors) o.left_expr = to_ops(left) o.selectors = selectors.map {|s| build(s) } o end |
#build_SiteDefinition(o, body) ⇒ 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.
256 257 258 259 260 |
# File 'lib/puppet/pops/model/factory.rb', line 256 def build_SiteDefinition(o, body) b = f_build_body(body) o.body = b.current if b o end |
#build_String(o) ⇒ 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.
Building model equivalences of Ruby objects Allows passing regular ruby objects to the factory to produce instructions that when evaluated produce the same thing.
911 912 913 914 915 |
# File 'lib/puppet/pops/model/factory.rb', line 911 def build_String(o) x = LiteralString.new x.value = o; x end |
#build_SubLocatedExpression(o, token, expression) ⇒ 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.
Builds a SubLocatedExpression - this wraps the expression in a sublocation configured from the given token A SubLocated holds its own locator that is used for subexpressions holding positions relative to what it describes.
312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/puppet/pops/model/factory.rb', line 312 def build_SubLocatedExpression(o, token, expression) o.expr = build(expression) o.offset = token.offset o.length = token.length locator = token.locator o.locator = locator o.leading_line_count = locator.leading_line_count o.leading_line_offset = locator.leading_line_offset # Index is held in sublocator's parent locator - needed to be able to reconstruct o.line_offsets = locator.locator.line_index o end |
#build_Symbol(o) ⇒ 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.
Creates a String literal, unless the symbol is one of the special :undef, or :default which instead creates a LiterlUndef, or a LiteralDefault. Supports :undef because nil creates a no-op instruction.
967 968 969 970 971 972 973 974 975 976 |
# File 'lib/puppet/pops/model/factory.rb', line 967 def build_Symbol(o) case o when :undef LiteralUndef.new when :default LiteralDefault.new else build_String(o.to_s) end end |
#build_TokenValue(o) ⇒ 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.
373 374 375 |
# File 'lib/puppet/pops/model/factory.rb', line 373 def build_TokenValue(o) raise "Factory can not deal with a Lexer Token. Got token: #{o}. Probably caused by wrong index in grammar val[n]." end |
#build_TrueClass(o) ⇒ 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.
922 923 924 925 926 |
# File 'lib/puppet/pops/model/factory.rb', line 922 def build_TrueClass(o) x = LiteralBoolean.new x.value = o x end |
#build_TypeAlias(o, name, type_expr) ⇒ 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.
337 338 339 340 341 |
# File 'lib/puppet/pops/model/factory.rb', line 337 def build_TypeAlias(o, name, type_expr) o.type_expr = build(type_expr) o.name = name o end |
#build_TypeDefinition(o, name, parent, body) ⇒ 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.
343 344 345 346 347 348 349 |
# File 'lib/puppet/pops/model/factory.rb', line 343 def build_TypeDefinition(o, name, parent, body) b = f_build_body(body) o.body = b.current if b o.parent = parent o.name = name o end |
#build_UnaryExpression(o, expr) ⇒ 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.
351 352 353 354 355 |
# File 'lib/puppet/pops/model/factory.rb', line 351 def build_UnaryExpression(o, expr) ops = to_ops(expr) o.expr = ops unless Factory.nop? ops o end |
#captures_rest ⇒ 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.
Mark parameter as capturing the rest of arguments
626 627 628 |
# File 'lib/puppet/pops/model/factory.rb', line 626 def captures_rest() current.captures_rest = true end |
#default(r) ⇒ 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.
For CaseExpression, setting the default for an already build CaseExpression
468 469 470 471 |
# File 'lib/puppet/pops/model/factory.rb', line 468 def default r current.addOptions(Factory.WHEN(:default, r).current) self end |
#dot(r) ⇒ 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.
425 |
# File 'lib/puppet/pops/model/factory.rb', line 425 def dot r; f_build_binary(NamedAccessExpression, current, r); end |
#f_arithmetic(op, r) ⇒ 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.
394 395 396 |
# File 'lib/puppet/pops/model/factory.rb', line 394 def f_arithmetic(op, r) f_build_binary_op(ArithmeticExpression, op, current, r) end |
#f_build_binary(klazz, left, right) ⇒ 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.
386 387 388 |
# File 'lib/puppet/pops/model/factory.rb', line 386 def f_build_binary(klazz, left, right) Factory.new(build(klazz, left, right)) end |
#f_build_binary_op(klazz, op, left, right) ⇒ 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.
382 383 384 |
# File 'lib/puppet/pops/model/factory.rb', line 382 def f_build_binary_op(klazz, op, left, right) Factory.new(build(klazz, op, left, right)) end |
#f_build_body(nothing) ⇒ Object #f_build_body(array) ⇒ Object #f_build_body(expr) ⇒ Object #f_build_body(obj) ⇒ 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.
Builds body :) from different kinds of input
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/puppet/pops/model/factory.rb', line 207 def f_build_body(body) case body when NilClass nil when Array Factory.new(BlockExpression, *body) else build(body) end end |
#f_build_unary(klazz, expr) ⇒ 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.
Factory helpers
378 379 380 |
# File 'lib/puppet/pops/model/factory.rb', line 378 def f_build_unary(klazz, expr) Factory.new(build(klazz, expr)) end |
#f_build_vararg(klazz, left, *arg) ⇒ 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.
390 391 392 |
# File 'lib/puppet/pops/model/factory.rb', line 390 def f_build_vararg(klazz, left, *arg) Factory.new(build(klazz, left, *arg)) end |
#f_comparison(op, r) ⇒ 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.
398 399 400 |
# File 'lib/puppet/pops/model/factory.rb', line 398 def f_comparison(op, r) f_build_binary_op(ComparisonExpression, op, current, r) end |
#f_match(op, r) ⇒ 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.
402 403 404 |
# File 'lib/puppet/pops/model/factory.rb', line 402 def f_match(op, r) f_build_binary_op(MatchExpression, op, current, r) end |
#in(r) ⇒ 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.
Operator helpers
407 |
# File 'lib/puppet/pops/model/factory.rb', line 407 def in(r) f_build_binary(InExpression, current, r); end |
#interpolate ⇒ 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.
Polymorphic interpolate
41 42 43 |
# File 'lib/puppet/pops/model/factory.rb', line 41 def interpolate() @@interpolation_visitor.visit_this_0(self, current) end |
#interpolate_AccessExpression(o) ⇒ 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.
rewrite left expression to variable if it is name, number, and recurse if it is an access expression this is for interpolation support in new lexer ($NAME, $NAME[}, $NUMBER, $NUMBER[] - all other expressions requires variables to be preceded with $
1049 1050 1051 1052 1053 1054 |
# File 'lib/puppet/pops/model/factory.rb', line 1049 def interpolate_AccessExpression(o) if is_interop_rewriteable?(o.left_expr) o.left_expr = to_ops(self.class.new(o.left_expr).interpolate) end o end |
#interpolate_CallMethodExpression(o) ⇒ 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.
Rewrite method calls on the form $… to $Puppet::Pops::Model::Factory.$x$x.each
1064 1065 1066 1067 1068 1069 |
# File 'lib/puppet/pops/model/factory.rb', line 1064 def interpolate_CallMethodExpression(o) if is_interop_rewriteable?(o.functor_expr) o.functor_expr = to_ops(self.class.new(o.functor_expr).interpolate) end o end |
#interpolate_Factory(o) ⇒ 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.
1028 1029 1030 |
# File 'lib/puppet/pops/model/factory.rb', line 1028 def interpolate_Factory(o) interpolate(o.current) end |
#interpolate_LiteralInteger(o) ⇒ 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.
1032 1033 1034 1035 |
# File 'lib/puppet/pops/model/factory.rb', line 1032 def interpolate_LiteralInteger(o) # convert number to a variable self.class.new(o).var end |
#interpolate_NamedAccessExpression(o) ⇒ 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.
1056 1057 1058 1059 1060 1061 |
# File 'lib/puppet/pops/model/factory.rb', line 1056 def interpolate_NamedAccessExpression(o) if is_interop_rewriteable?(o.left_expr) o.left_expr = to_ops(self.class.new(o.left_expr).interpolate) end o end |
#interpolate_Object(o) ⇒ 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.
1037 1038 1039 |
# File 'lib/puppet/pops/model/factory.rb', line 1037 def interpolate_Object(o) o end |
#interpolate_QualifiedName(o) ⇒ 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.
1041 1042 1043 |
# File 'lib/puppet/pops/model/factory.rb', line 1041 def interpolate_QualifiedName(o) self.class.new(o).var end |
#is_interop_rewriteable?(o) ⇒ 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.
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
# File 'lib/puppet/pops/model/factory.rb', line 1071 def is_interop_rewriteable?(o) case o when AccessExpression, QualifiedName, NamedAccessExpression, CallMethodExpression true when LiteralInteger # Only decimal integers can represent variables, else it is a number o.radix == 10 else false end end |
#lambda=(lambda) ⇒ 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.
473 474 475 476 |
# File 'lib/puppet/pops/model/factory.rb', line 473 def lambda=(lambda) current.lambda = lambda.current self end |
#length ⇒ 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.
519 520 521 |
# File 'lib/puppet/pops/model/factory.rb', line 519 def length @current.length end |
#loc ⇒ Puppet::Pops::Adapters::SourcePosAdapter
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.
Returns with location information.
533 534 535 |
# File 'lib/puppet/pops/model/factory.rb', line 533 def loc() Adapters::SourcePosAdapter.adapt(current) end |
#minus ⇒ 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.
415 |
# File 'lib/puppet/pops/model/factory.rb', line 415 def minus(); f_build_unary(UnaryMinusExpression, self); end |
#minus_set(r) ⇒ 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.
Assignment -=
489 490 491 |
# File 'lib/puppet/pops/model/factory.rb', line 489 def minus_set(r) f_build_binary_op(AssignmentExpression, :'-=', current, r) end |
#mne(r) ⇒ 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.
455 |
# File 'lib/puppet/pops/model/factory.rb', line 455 def mne r; f_match(:'!~', r); end |
#name_is_statement(name) ⇒ 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.
Returns true if the given name is a “statement keyword” (require, include, contain, error, notice, info, debug
840 841 842 |
# File 'lib/puppet/pops/model/factory.rb', line 840 def name_is_statement(name) STATEMENT_CALLS[name] end |
#ne(r) ⇒ 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.
451 |
# File 'lib/puppet/pops/model/factory.rb', line 451 def ne r; f_comparison(:'!=', r); end |
#not ⇒ 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.
413 |
# File 'lib/puppet/pops/model/factory.rb', line 413 def not(); f_build_unary(NotExpression, self); end |
#offset ⇒ 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.
515 516 517 |
# File 'lib/puppet/pops/model/factory.rb', line 515 def offset @current.offset end |
#or(r) ⇒ 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.
409 |
# File 'lib/puppet/pops/model/factory.rb', line 409 def or(r) f_build_binary(OrExpression, current, r); end |
#paren ⇒ 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.
457 |
# File 'lib/puppet/pops/model/factory.rb', line 457 def paren(); f_build_unary(ParenthesizedExpression, current); end |
#plus_set(r) ⇒ 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.
Assignment +=
484 485 486 |
# File 'lib/puppet/pops/model/factory.rb', line 484 def plus_set(r) f_build_binary_op(AssignmentExpression, :'+=', current, r) end |
#record_position(start_locatable, end_locatable) ⇒ 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.
Records the position (start -> end) and computes the resulting length.
525 526 527 528 529 530 |
# File 'lib/puppet/pops/model/factory.rb', line 525 def record_position(start_locatable, end_locatable) # record information directly in the Positioned object start_offset = start_locatable.offset @current.set_loc(start_offset, end_locatable ? end_locatable.offset - start_offset + end_locatable.length : start_locatable.length) self end |
#relop(op, r) ⇒ 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.
459 460 461 |
# File 'lib/puppet/pops/model/factory.rb', line 459 def relop op, r f_build_binary_op(RelationshipExpression, op.to_sym, current, r) end |
#respond_to?(meth, include_all = false) ⇒ 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.
507 508 509 |
# File 'lib/puppet/pops/model/factory.rb', line 507 def respond_to?(meth, include_all=false) current.respond_to?(meth, include_all) || super end |
#select(*args) ⇒ 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.
463 464 465 |
# File 'lib/puppet/pops/model/factory.rb', line 463 def select *args Factory.new(build(SelectorExpression, current, *args)) end |
#set(r) ⇒ 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.
Assignment =
479 480 481 |
# File 'lib/puppet/pops/model/factory.rb', line 479 def set(r) f_build_binary_op(AssignmentExpression, :'=', current, r) end |
#text ⇒ 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.
419 |
# File 'lib/puppet/pops/model/factory.rb', line 419 def text(); f_build_unary(TextExpression, self); end |
#to_ops(o, *args) ⇒ 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.
Checks if the object is already a model object, or build it
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'lib/puppet/pops/model/factory.rb', line 1085 def to_ops(o, *args) case o when PopsObject o when Factory o.current else build(o, *args) end end |
#to_s ⇒ 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.
1110 1111 1112 |
# File 'lib/puppet/pops/model/factory.rb', line 1110 def to_s ModelTreeDumper.new.dump(self) end |
#type_expr(o) ⇒ 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.
Set Expression that should evaluate to the parameter’s type
631 632 633 |
# File 'lib/puppet/pops/model/factory.rb', line 631 def type_expr(o) current.type_expr = to_ops(o) end |
#unfold ⇒ 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.
417 |
# File 'lib/puppet/pops/model/factory.rb', line 417 def unfold(); f_build_unary(UnfoldExpression, self); end |
#var ⇒ 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.
421 |
# File 'lib/puppet/pops/model/factory.rb', line 421 def var(); f_build_unary(VariableExpression, self); end |