Skip to content

Commit

Permalink
Merge 581efc3 into 2ec7aa0
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Mar 26, 2021
2 parents 2ec7aa0 + 581efc3 commit b264937
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/puppet/provider/augeasprovider/default.rb
Expand Up @@ -412,7 +412,7 @@ def self.default_file(&block)
# @raise [Puppet::Error] if no block has been set when getting
# @api public
def self.lens(resource = nil, &block)
if block_given?
if block
@lens_block = block
else
raise(Puppet::Error, 'Lens is not provided') unless @lens_block
Expand Down Expand Up @@ -445,7 +445,7 @@ def self.path_label(aug, path)
def self.whichquote(value, resource = nil, oldvalue = nil)
oldquote = readquote oldvalue

quote = if resource && resource.parameters.include?(:quoted)
quote = if resource && resource.parameters.include?(:quoted) # rubocop:disable Cop/Style/SafeNavigation
resource[:quoted]
else
:auto
Expand All @@ -454,7 +454,7 @@ def self.whichquote(value, resource = nil, oldvalue = nil)
if quote == :auto
quote = if oldquote
oldquote
elsif value =~ %r{[|&;()<>\s]}
elsif value.match?(%r{[|&;()<>\s]})
:double
else
:none
Expand Down Expand Up @@ -488,7 +488,7 @@ def self.quoteit(value, resource = nil, oldvalue = nil)
# @return [Symbol] the type of quoting used (:double, :single or nil)
# @api public
def self.readquote(value)
if value =~ %r{^(["'])(.*)(?:\1)$}
if value.match?(%r{^(["'])(.*)(?:\1)$})
case Regexp.last_match(1)
when '"' then :double
when "'" then :single
Expand Down Expand Up @@ -522,7 +522,7 @@ def self.readquote(value)
# @see #target
# @api public
def self.resource_path(resource = nil, &block)
if block_given?
if block
@resource_path_block = block
elsif @resource_path_block
@resource_path_block.call(resource)
Expand Down Expand Up @@ -576,7 +576,7 @@ def self.target(resource = nil)
# @return [String] the unquoted value
# @api public
def self.unquoteit(value)
if value =~ %r{^(["'])(.*)(?:\1)$}
if value.match?(%r{^(["'])(.*)(?:\1)$})
Regexp.last_match(2)
else
value
Expand Down Expand Up @@ -691,7 +691,7 @@ def self.augopen_internal(resource = nil, autosave = false, yield_resource = fal
raise(Puppet::Error, "Augeas didn't load #{file} with #{lens}#{from}: #{message}")
end

if block_given?
if block
setvars(aug, resource)
if yield_resource
block.call(aug, resource, *yield_params)
Expand All @@ -705,7 +705,7 @@ def self.augopen_internal(resource = nil, autosave = false, yield_resource = fal
autosave = false
raise
ensure
if aug && block_given? && !supported?(:post_resource_eval)
if aug && block && !supported?(:post_resource_eval)
augsave!(aug) if autosave
augclose!(aug)
end
Expand Down
1 change: 1 addition & 0 deletions spec/lib/augeas_spec.rb
@@ -1,4 +1,5 @@
module AugeasSpec end

class AugeasSpec::Error < StandardError
end

Expand Down

0 comments on commit b264937

Please sign in to comment.