Class: Puppet::Parser::ParserFactory
- Defined in:
- lib/puppet/parser/parser_factory.rb
Overview
The ParserFactory makes selection of parser possible. Currently, it is possible to switch between two different parsers:
-
classic_parser, the parser in 3.1
-
eparser, the Expression Based Parser
Class Method Summary collapse
-
.classic_parser(environment) ⇒ Object
Creates an instance of the classic parser.
-
.eparser(environment) ⇒ Object
Creates an instance of the expression based parser ‘eparser’.
-
.evaluating_parser(file_watcher) ⇒ Object
Returns an instance of an EvaluatingParser.
-
.parser(environment) ⇒ Object
Produces a parser instance for the given environment.
Class Method Details
.classic_parser(environment) ⇒ Object
Creates an instance of the classic parser.
26 27 28 29 30 |
# File 'lib/puppet/parser/parser_factory.rb', line 26 def self.classic_parser(environment) require 'puppet/parser' Puppet::Parser::Parser.new(environment) end |
.eparser(environment) ⇒ Object
Creates an instance of the expression based parser ‘eparser’
45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet/parser/parser_factory.rb', line 45 def self.eparser(environment) # Since RGen is optional, test that it is installed @@asserted ||= false assert_rgen_installed() unless @@asserted @@asserted = true require 'puppet/parser' require 'puppet/parser/e_parser_adapter' EParserAdapter.new(Puppet::Parser::Parser.new(environment)) end |
.evaluating_parser(file_watcher) ⇒ Object
Returns an instance of an EvaluatingParser
33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/parser/parser_factory.rb', line 33 def self.evaluating_parser(file_watcher) # Since RGen is optional, test that it is installed @@asserted ||= false assert_rgen_installed() unless @@asserted @@asserted = true require 'puppet/parser/e4_parser_adapter' require 'puppet/pops/parser/code_merger' E4ParserAdapter.new(file_watcher) end |
.parser(environment) ⇒ Object
Produces a parser instance for the given environment
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet/parser/parser_factory.rb', line 11 def self.parser(environment) case Puppet[:parser] when 'future' if Puppet[:evaluator] == 'future' evaluating_parser(environment) else eparser(environment) end else classic_parser(environment) end end |