Skip to content

Commit

Permalink
make suggested changes to comments and augopen
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Marod committed May 12, 2015
1 parent bda708f commit 363ced4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/puppet/provider/pam/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ 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
end

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
Expand Down

0 comments on commit 363ced4

Please sign in to comment.