-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rubocop fixes #240
Merged
Merged
Rubocop fixes #240
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d6561ce
Fix rubocop Style/SpaceInsideBrackets
alexjfisher fc9f4a3
Fix rubocop Style/SpaceAfterComma
alexjfisher 12acd17
Fix rubocop Style/EmptyLinesAroundBlockBody
alexjfisher 8c7d31d
Rubocop: Indentation fixes
alexjfisher 0b0c1b7
Fix rubocop Style/ElseAlignment
alexjfisher ea5b7ec
Fix rubocop Lint/BlockAlignment
alexjfisher 5a357ff
Fix rubocop Style/LineEndConcatenation
alexjfisher ea4e94d
Fix rubocop Style/AndOr
alexjfisher 8f304b1
Fix rubocop Style/ExtraSpacing
alexjfisher e53ec47
Fix rubocop Style/FormatString
alexjfisher 9e07a18
Fix rubocop Style/PerlBackrefs
alexjfisher 6593116
Fix rubocop Style/CollectionMethods
alexjfisher f45de7b
Fix rubocop Style/GuardClause
alexjfisher 28263ee
Rubocop fix Lint/UselessAssignment
alexjfisher 520f032
Fix rubocop Style/ConditionalAssignment
alexjfisher 420e37f
Rubocop fix Lint/AssignmentInCondition
alexjfisher fbd0a39
Fix rubocop Style/IfUnlessModifier
alexjfisher 2538e10
Fix rubocop Style/EmptyLinesAroundBlockBody
alexjfisher 6bbdc78
Fix rubocop Style/EmptyElse
alexjfisher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ def self.pearlist(hash) | |
|
||
begin | ||
list = execute(command).split("\n") | ||
list = list.collect do |set| | ||
if match = %r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) | ||
list = list.map do |set| | ||
if match = %r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) # rubocop:disable Lint/AssignmentInCondition | ||
channel = match[1].downcase | ||
end | ||
|
||
|
@@ -31,76 +31,69 @@ def self.pearlist(hash) | |
pearhash = pearsplit(set, channel) | ||
pearhash[:provider] = :pear | ||
pearhash | ||
else | ||
nil | ||
end | ||
else | ||
if pearhash = pearsplit(set, channel) | ||
if pearhash = pearsplit(set, channel) # rubocop:disable Lint/AssignmentInCondition | ||
pearhash[:provider] = :pear | ||
pearhash | ||
else | ||
nil | ||
end | ||
end | ||
end.reject { |p| p.nil? } | ||
|
||
rescue Puppet::ExecutionFailure => detail | ||
raise Puppet::Error, 'Could not list pears: %s' % detail | ||
raise Puppet::Error, format('Could not list pears: %s', detail) | ||
end | ||
|
||
if hash[:justme] | ||
return list.shift | ||
else | ||
return list | ||
end | ||
return list.shift if hash[:justme] | ||
list | ||
end | ||
|
||
def self.pearsplit(desc, channel) | ||
desc.strip! | ||
|
||
case desc | ||
when %r{^$} then return nil | ||
when %r{^INSTALLED}i then return nil | ||
when %r{no packages installed}i then return nil | ||
when %r{^=} then return nil | ||
when %r{^PACKAGE}i then return nil | ||
when %r{^(\S+)\s+(\S+)\s+(\S+)\s*$} then | ||
name = $1 | ||
version = $2 | ||
state = $3 | ||
return { | ||
name: "#{channel}/#{name}", | ||
ensure: state == 'stable' ? version : state | ||
} | ||
when %r{^$} then return nil | ||
when %r{^INSTALLED}i then return nil | ||
when %r{no packages installed}i then return nil | ||
when %r{^=} then return nil | ||
when %r{^PACKAGE}i then return nil | ||
when %r{^(\S+)\s+(\S+)\s+(\S+)\s*$} then | ||
name = Regexp.last_match(1) | ||
version = Regexp.last_match(2) | ||
state = Regexp.last_match(3) | ||
return { | ||
name: "#{channel}/#{name}", | ||
ensure: state == 'stable' ? version : state | ||
} | ||
else | ||
Puppet.debug "Could not match '%s'" % desc | ||
Puppet.debug format("Could not match '%s'", desc) | ||
nil | ||
end | ||
end | ||
|
||
def self.instances | ||
pearlist(local: true).collect do |hash| | ||
pearlist(local: true).map do |hash| | ||
new(hash) | ||
end | ||
end | ||
|
||
def install(useversion = true) | ||
command = ['-D', 'auto_discover=1', 'upgrade'] | ||
if @resource[:install_options] | ||
command << @resource[:install_options] | ||
else | ||
command << '--alldeps' | ||
end | ||
|
||
if source = @resource[:source] | ||
command << source | ||
else | ||
if ([email protected](:ensure).is_a? Symbol) and useversion | ||
command << "#{@resource[:name]}-#{@resource.should(:ensure)}" | ||
else | ||
command << @resource[:name] | ||
end | ||
end | ||
command << if @resource[:install_options] | ||
@resource[:install_options] | ||
else | ||
'--alldeps' | ||
end | ||
|
||
command << if @resource[:source] | ||
@resource[:source] | ||
else | ||
if ([email protected](:ensure).is_a? Symbol) && useversion | ||
"#{@resource[:name]}-#{@resource.should(:ensure)}" | ||
else | ||
@resource[:name] | ||
end | ||
end | ||
|
||
pearcmd(*command) | ||
end | ||
|
@@ -109,12 +102,10 @@ def latest | |
# This always gets the latest version available. | ||
version = '' | ||
command = [command(:pearcmd), 'remote-info', @resource[:name]] | ||
list = execute(command).split("\n") | ||
list = list.collect do |set| | ||
if set =~ %r{^Latest} | ||
version = set.split[1] | ||
end | ||
execute(command).each_line do |set| | ||
version = set.split[1] if set =~ %r{^Latest} | ||
end | ||
|
||
version | ||
end | ||
|
||
|
@@ -124,14 +115,10 @@ def query | |
|
||
def uninstall | ||
output = pearcmd 'uninstall', @resource[:name] | ||
if output =~ %r{^uninstall ok} | ||
else | ||
raise Puppet::Error, output | ||
end | ||
raise Puppet::Error, output unless output =~ %r{^uninstall ok} | ||
end | ||
|
||
def update | ||
install(false) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,46 +8,37 @@ | |
has_feature :upgradeable | ||
|
||
case Facter.value(:operatingsystem) | ||
when 'Solaris' | ||
commands peclcmd: '/opt/coolstack/php5/bin/pecl' | ||
else | ||
commands peclcmd: 'pecl' | ||
when 'Solaris' | ||
commands peclcmd: '/opt/coolstack/php5/bin/pecl' | ||
else | ||
commands peclcmd: 'pecl' | ||
end | ||
|
||
def self.pecllist(hash) | ||
command = [command(:peclcmd), 'list'] | ||
|
||
begin | ||
list = execute(command).split("\n").collect do |set| | ||
list = execute(command).split("\n").map do |set| | ||
if hash[:justme] | ||
if %r{^#{hash[:justme]}$}i.match(set) | ||
if peclhash = peclsplit(set) | ||
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition | ||
peclhash[:provider] = :peclcmd | ||
peclhash | ||
else | ||
nil | ||
end | ||
else | ||
nil | ||
end | ||
else | ||
if peclhash = peclsplit(set) | ||
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition | ||
peclhash[:provider] = :peclcmd | ||
peclhash | ||
else | ||
nil | ||
end | ||
end | ||
end.reject { |p| p.nil? } | ||
rescue Puppet::ExecutionFailure => detail | ||
raise Puppet::Error, 'Could not list pecls: %s' % detail | ||
raise Puppet::Error, format('Could not list pecls: %s', detail) | ||
end | ||
|
||
if hash[:justme] | ||
return list.shift | ||
else | ||
return list | ||
end | ||
return list.shift if hash[:justme] | ||
list | ||
end | ||
|
||
def self.peclsplit(desc) | ||
|
@@ -58,23 +49,23 @@ def self.peclsplit(desc) | |
when %r{No packages installed from channel}i then return nil | ||
when %r{^=} then return nil | ||
when %r{^PACKAGE} then return nil | ||
when %r{\[1m} then return nil # Newer versions of PEAR use colorized output | ||
when %r{\[1m} then return nil # Newer versions of PEAR use colorized output | ||
when %r{^(\S+)\s+(\S+)\s+\S+} then | ||
name = $1 | ||
version = $2 | ||
name = Regexp.last_match(1) | ||
version = Regexp.last_match(2) | ||
|
||
return { | ||
name: "pecl-#{name.downcase}", | ||
ensure: version | ||
} | ||
else | ||
Puppet.warning 'Could not match %s' % desc | ||
Puppet.warning format('Could not match %s', desc) | ||
nil | ||
end | ||
end | ||
|
||
def self.instances | ||
pecllist(local: true).collect do |hash| | ||
pecllist(local: true).map do |hash| | ||
new(hash) | ||
end | ||
end | ||
|
@@ -86,20 +77,20 @@ def peclname | |
def install(useversion = true) | ||
command = ['upgrade'] | ||
|
||
if source = @resource[:source] | ||
command << source | ||
if @resource[:source] | ||
command << @resource[:source] | ||
else | ||
if ([email protected](:ensure).is_a? Symbol) and useversion | ||
if ([email protected](:ensure).is_a? Symbol) && useversion | ||
command << '-f' | ||
command << "#{peclname}-#{@resource.should(:ensure)}" | ||
else | ||
command << peclname | ||
end | ||
end | ||
|
||
if pipe = @resource[:pipe] | ||
command << '<<<' | ||
command << @resource[:pipe] | ||
if pipe == @resource[:pipe] | ||
command << '<<<' | ||
command << @resource[:pipe] | ||
end | ||
|
||
peclcmd(*command) | ||
|
@@ -108,10 +99,8 @@ def install(useversion = true) | |
def latest | ||
version = '' | ||
command = [command(:peclcmd), 'remote-info', peclname] | ||
list = execute(command).each_line do |set| | ||
if set =~ %r{^Latest} | ||
version = set.split[1] | ||
end | ||
execute(command).each_line do |set| | ||
version = set.split[1] if set =~ %r{^Latest} | ||
end | ||
|
||
version | ||
|
@@ -123,10 +112,7 @@ def query | |
|
||
def uninstall | ||
output = peclcmd 'uninstall', peclname | ||
if output =~ %r{^uninstall ok} | ||
else | ||
raise Puppet::Error, output | ||
end | ||
raise Puppet::Error, output unless output =~ %r{^uninstall ok} | ||
end | ||
|
||
def update | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bastelfreak Oops. This was clearly not right.