nwops / puppet-retrospec

The only tool you need to generate puppet code, tests, modules, facts, types, providers, data and everything else.
https://www.retrospec-puppet.com/
GNU Affero General Public License v3.0
137 stars 27 forks source link

refactor code to use new future parser #34

Closed logicminds closed 8 years ago

logicminds commented 9 years ago

We should be able to take advantage of the new future parser and more intelligently build out the test code without having to use conditional logic to figure things out.

For example we can use code like below to get at the model tree

require 'puppet/pops'
parser = Puppet::Pops::Parser::EvaluatingParser.new
result = parser.parse_file(file_name)
ast = result.current
class_def = ast.body
parameters = class_def.parameters
param.eAllContents.entries
data_type = Puppet::Pops::Types::TypeCalculator.infer(
ast.eAllContents
program.body.bodies[0].title.eContainer.eContainer.type_name.value
econtainerFeature
type = p1.type_expr.value