Skip to content

Commit

Permalink
Merge pull request #241 from alexjfisher/even_more_rubocop
Browse files Browse the repository at this point in the history
Fix all remaining rubocop violations
  • Loading branch information
bastelfreak authored Sep 29, 2016
2 parents c4d817d + 7d6ff09 commit 59e7525
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
3 changes: 1 addition & 2 deletions lib/puppet/parser/functions/to_hash_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ module Puppet::Parser::Functions

raise(Puppet::ParseError, 'to_hash_settings(): Requires hash to work with') unless hash.is_a?(Hash)

return hash.reduce({}) do |acc, kv|
return hash.each_with_object({}) do |kv, acc|
acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] }
acc
end
end
end
34 changes: 13 additions & 21 deletions lib/puppet/provider/package/pear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ def self.pearlist(hash)
begin
list = execute(command).split("\n")
list = list.map do |set|
if match = %r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) # rubocop:disable Lint/AssignmentInCondition
channel = match[1].downcase
%r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) { |m| channel = m[1].downcase }

if hash[:justme] && set =~ %r{^#{hash[:justme]}}
pearhash = pearsplit(set, channel)
pearhash[:provider] = :pear
pearhash
elsif (pearhash = pearsplit(set, channel))
pearhash[:provider] = :pear
pearhash
end

if hash[:justme]
if set =~ %r{^#{hash[:justme]}}
pearhash = pearsplit(set, channel)
pearhash[:provider] = :pear
pearhash
end
else
if pearhash = pearsplit(set, channel) # rubocop:disable Lint/AssignmentInCondition
pearhash[:provider] = :pear
pearhash
end
end
end.reject { |p| p.nil? }
end.compact

rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, format('Could not list pears: %s', detail)
Expand Down Expand Up @@ -87,12 +81,10 @@ def install(useversion = true)

command << if @resource[:source]
@resource[:source]
elsif (!@resource.should(:ensure).is_a? Symbol) && useversion
"#{@resource[:name]}-#{@resource.should(:ensure)}"
else
if (!@resource.should(:ensure).is_a? Symbol) && useversion
"#{@resource[:name]}-#{@resource.should(:ensure)}"
else
@resource[:name]
end
@resource[:name]
end

pearcmd(*command)
Expand Down
30 changes: 11 additions & 19 deletions lib/puppet/provider/package/pecl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ def self.pecllist(hash)

begin
list = execute(command).split("\n").map do |set|
if hash[:justme]
if %r{^#{hash[:justme]}$}i.match(set)
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition
peclhash[:provider] = :peclcmd
peclhash
end
end
else
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition
peclhash[:provider] = :peclcmd
peclhash
end
if hash[:justme] && %r{^#{hash[:justme]}$}i =~ set && (peclhash = peclsplit(set))
peclhash[:provider] = :peclcmd
peclhash
elsif (peclhash = peclsplit(set))
peclhash[:provider] = :peclcmd
peclhash
end
end.reject { |p| p.nil? }
end.compact
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, format('Could not list pecls: %s', detail)
end
Expand Down Expand Up @@ -79,13 +73,11 @@ def install(useversion = true)

if @resource[:source]
command << @resource[:source]
elsif (!@resource.should(:ensure).is_a? Symbol) && useversion
command << '-f'
command << "#{peclname}-#{@resource.should(:ensure)}"
else
if (!@resource.should(:ensure).is_a? Symbol) && useversion
command << '-f'
command << "#{peclname}-#{@resource.should(:ensure)}"
else
command << peclname
end
command << peclname
end

if @resource[:pipe]
Expand Down

0 comments on commit 59e7525

Please sign in to comment.