module Puppet::Pops::Evaluator::ExternalSyntaxSupport
Public Instance Methods
assert_external_syntax(_, result, syntax, reference_expr)
click to toggle source
# File lib/puppet/pops/evaluator/external_syntax_support.rb 7 def assert_external_syntax(_, result, syntax, reference_expr) 8 # ignore 'unspecified syntax' 9 return if syntax.nil? || syntax == '' 10 11 checker = checker_for_syntax(nil, syntax) 12 # ignore syntax with no matching checker 13 return unless checker 14 15 # Call checker and give it the location information from the expression 16 # (as opposed to where the heredoc tag is (somewhere on the line above)). 17 acceptor = Puppet::Pops::Validation::Acceptor.new() 18 checker.check(result, syntax, acceptor, reference_expr) 19 20 if acceptor.error_count > 0 21 checker_message = "Invalid produced text having syntax: '#{syntax}'." 22 Puppet::Pops::IssueReporter.assert_and_report(acceptor, :message => checker_message) 23 raise ArgumentError, _("Internal Error: Configuration of runtime error handling wrong: should have raised exception") 24 end 25 end
checker_for_syntax(_, syntax)
click to toggle source
Finds the most significant checker for the given syntax (most significant is to the right). Returns nil if there is no registered checker.
# File lib/puppet/pops/evaluator/external_syntax_support.rb 30 def checker_for_syntax(_, syntax) 31 checkers_hash = Puppet.lookup(:plugins)[Puppet::Plugins::SyntaxCheckers::SYNTAX_CHECKERS_KEY] 32 checkers_hash[lookup_keys_for_syntax(syntax).find {|x| checkers_hash[x] }] 33 end
lookup_keys_for_syntax(syntax)
click to toggle source
Returns an array of possible syntax names
# File lib/puppet/pops/evaluator/external_syntax_support.rb 36 def lookup_keys_for_syntax(syntax) 37 segments = syntax.split(/\+/) 38 result = [] 39 loop do 40 result << segments.join("+") 41 segments.shift 42 break if segments.empty? 43 end 44 result 45 end