From e541e7c027810af8fdd6903132518daa67aa35dd Mon Sep 17 00:00:00 2001 From: Hailee Kenney Date: Wed, 23 Mar 2016 20:02:12 -0700 Subject: [PATCH] (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. --- .../strings/yard/handlers/host_class_handler.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb b/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb index 982c664..0f7343b 100644 --- a/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb +++ b/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb @@ -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}"