(PDOC-75) Work with both versions of 'interpret_any'

Prior to this commit, strings would fail with puppet 4.4.0 and
newer. This was because strings was making use of a method that was
marked API private and thus subject to change. The method was changed
in 4.4.0 release of puppet to take two variables, meaning that strings
much adjust how it calls the method based on the version of puppet
it's running with.
This commit is contained in:
Hailee Kenney 2016-03-23 20:02:12 -07:00
parent 678ba735e8
commit e541e7c027
1 changed files with 7 additions and 1 deletions

View File

@ -16,7 +16,13 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::HostClassHandler < PuppetX::
param_type_info[pop_param.name] = Puppet::Pops::Types::TypeFactory.any()
else
begin
param_type_info[pop_param.name] = tp.interpret_any(pop_param.type_expr)
# This is a bit of a hack because we were using a method that was previously
# API private. See PDOC-75 for more details
if Puppet::Pops::Types::TypeParser.instance_method(:interpret_any).arity == 2
param_type_info[pop_param.name] = tp.interpret_any(pop_param.type_expr, nil)
else
param_type_info[pop_param.name] = tp.interpret_any(pop_param.type_exp)
end
rescue Puppet::ParseError => e
# If the type could not be interpreted insert a prominent warning
param_type_info[pop_param.name] = "Type Error: #{e.message}"