From 363ced4b15d870eac5c5bf9fa0a5f8ca8d1bd929 Mon Sep 17 00:00:00 2001 From: Michael Marod Date: Tue, 12 May 2015 16:12:24 +0000 Subject: [PATCH] make suggested changes to comments and augopen --- lib/puppet/provider/pam/augeas.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/puppet/provider/pam/augeas.rb b/lib/puppet/provider/pam/augeas.rb index 380324d..117f500 100644 --- a/lib/puppet/provider/pam/augeas.rb +++ b/lib/puppet/provider/pam/augeas.rb @@ -52,6 +52,9 @@ def self.position_path (position, type) expr = PAM_POSITION_ALIASES[key][identifier] expr = key ? expr % [type, value] : expr % [type] else + # if the identifier is not in the mapping + # we assume that its an xpath and so + # join everything after the placement expr = position.split(/ /)[1..-1].join(" ") end return expr, placement @@ -59,16 +62,15 @@ def self.position_path (position, type) def in_position? unless resource[:position].nil? - aug = nil path, before = self.class.position_path(resource[:position], resource[:type]) - augopen do |aug| - if before == 'before' - mpath = "#{resource_path}[following-sibling::#{path}]" - else - mpath = "#{resource_path}[preceding-sibling::#{path}]" - end + if before == 'before' + mpath = "#{resource_path}[following-sibling::#{path}]" + else + mpath = "#{resource_path}[preceding-sibling::#{path}]" + end + augopen do |aug| !aug.match(mpath).empty? end end