diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/provider/package | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/provider/package')
-rw-r--r-- | lib/chef/provider/package/aix.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/package/chocolatey.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/package/dpkg.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/package/easy_install.rb | 16 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/base.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/pkg.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/pkgng.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/freebsd/port.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/macports.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/package/openbsd.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/package/pacman.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/package/paludis.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/portage.rb | 9 | ||||
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 30 | ||||
-rw-r--r-- | lib/chef/provider/package/smartos.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/windows.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/windows/msi.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/package/yum.rb | 53 | ||||
-rw-r--r-- | lib/chef/provider/package/zypper.rb | 4 |
19 files changed, 92 insertions, 94 deletions
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb index 732ca00b71..a1709c4af7 100644 --- a/lib/chef/provider/package/aix.rb +++ b/lib/chef/provider/package/aix.rb @@ -53,7 +53,7 @@ class Chef if @package_source_found Chef::Log.debug("#{@new_resource} checking pkg status") ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}") - ret.stdout.each_line do | line | + ret.stdout.each_line do |line| case line when /#{@new_resource.package_name}:/ fields = line.split(":") @@ -66,7 +66,7 @@ class Chef Chef::Log.debug("#{@new_resource} checking install state") ret = shell_out_with_timeout("lslpp -lcq #{@current_resource.package_name}") - ret.stdout.each_line do | line | + ret.stdout.each_line do |line| case line when /#{@current_resource.package_name}/ fields = line.split(":") @@ -85,7 +85,7 @@ class Chef def candidate_version return @candidate_version if @candidate_version ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}") - ret.stdout.each_line do | line | + ret.stdout.each_line do |line| case line when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/ fields = line.split(":") diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb index 0d320a3aad..14613b0218 100644 --- a/lib/chef/provider/package/chocolatey.rb +++ b/lib/chef/provider/package/chocolatey.rb @@ -63,7 +63,7 @@ EOS # and not a package specific alternate source like other providers # so we want to assert candidates exist for the alternate source requirements.assert(:upgrade, :install) do |a| - a.assertion { candidates_exist_for_all_uninstalled? } + a.assertion { candidates_exist_for_all_uninstalled? } a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}") a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured") end @@ -84,8 +84,8 @@ EOS def install_package(names, versions) name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) } - name_nil_versions = name_versions_to_install.select { |n,v| v.nil? } - name_has_versions = name_versions_to_install.reject { |n,v| v.nil? } + name_nil_versions = name_versions_to_install.select { |n, v| v.nil? } + name_has_versions = name_versions_to_install.reject { |n, v| v.nil? } # choco does not support installing multiple packages with version pins name_has_versions.each do |name, version| @@ -106,8 +106,8 @@ EOS def upgrade_package(names, versions) name_versions_to_install = desired_name_versions.select { |n, v| lowercase_names(names).include?(n) } - name_nil_versions = name_versions_to_install.select { |n,v| v.nil? } - name_has_versions = name_versions_to_install.reject { |n,v| v.nil? } + name_nil_versions = name_versions_to_install.select { |n, v| v.nil? } + name_has_versions = name_versions_to_install.reject { |n, v| v.nil? } # choco does not support installing multiple packages with version pins name_has_versions.each do |name, version| @@ -220,7 +220,7 @@ EOS # @param args [String] variable number of string arguments # @return [String] nicely concatenated string or empty string def args_to_string(*args) - args.reject {|i| i.nil? || i == "" }.join(" ") + args.reject { |i| i.nil? || i == "" }.join(" ") end # Available packages in chocolatey as a Hash of names mapped to versions diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb index f57b779ffa..a5a80e14d6 100644 --- a/lib/chef/provider/package/dpkg.rb +++ b/lib/chef/provider/package/dpkg.rb @@ -145,14 +145,14 @@ class Chef # # @return [Boolean] True if all sources exist def source_files_exist? - resolved_source_array.all? {|s| s && ::File.exist?(s) } + resolved_source_array.all? { |s| s && ::File.exist?(s) } end # Helper to return all the nanes of the missing sources for error messages. # # @return [Array<String>] Array of missing sources def missing_sources - resolved_source_array.select {|s| s.nil? || !::File.exist?(s) } + resolved_source_array.select { |s| s.nil? || !::File.exist?(s) } end def current_package_name_array @@ -187,14 +187,14 @@ class Chef def name_candidate_version @name_candidate_version ||= begin - Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[1].strip : nil] }] + Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[1].strip : nil] }] end end def name_package_name @name_package_name ||= begin - Hash[name_pkginfo.map {|k, v| [k, v ? v.split("\t")[0] : nil] }] + Hash[name_pkginfo.map { |k, v| [k, v ? v.split("\t")[0] : nil] }] end end diff --git a/lib/chef/provider/package/easy_install.rb b/lib/chef/provider/package/easy_install.rb index e4752cf3e7..a876258d04 100644 --- a/lib/chef/provider/package/easy_install.rb +++ b/lib/chef/provider/package/easy_install.rb @@ -32,10 +32,10 @@ class Chef begin # first check to see if we can import it - output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns=>[0,1]).stderr + output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns => [0, 1]).stderr if output.include? "ImportError" # then check to see if its on the path - output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout + output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout if output.downcase.include? "#{name.downcase}" check = true end @@ -75,9 +75,9 @@ class Chef output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout package_version = output.strip rescue - output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout + output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout - output_array = output.gsub(/[\[\]]/,"").split(/\s*,\s*/) + output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/) package_path = "" output_array.each do |entry| @@ -103,12 +103,12 @@ class Chef end def candidate_version - return @candidate_version if @candidate_version + return @candidate_version if @candidate_version # do a dry run to get the latest version - result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns=>[0,1]) - @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3] - @candidate_version + result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns => [0, 1]) + @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3] + @candidate_version end def install_package(name, version) diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb index 81c27845ba..7104a71f70 100644 --- a/lib/chef/provider/package/freebsd/base.rb +++ b/lib/chef/provider/package/freebsd/base.rb @@ -57,8 +57,8 @@ class Chef def makefile_variable_value(variable, dir = nil) options = dir ? { :cwd => dir } : {} - make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0,1])) - make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline. + make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0, 1])) + make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline. end end diff --git a/lib/chef/provider/package/freebsd/pkg.rb b/lib/chef/provider/package/freebsd/pkg.rb index 339693a3d5..b42bd62c61 100644 --- a/lib/chef/provider/package/freebsd/pkg.rb +++ b/lib/chef/provider/package/freebsd/pkg.rb @@ -41,7 +41,7 @@ class Chef Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}") when /^\// - shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL"=>nil}).status + shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL" => nil }).status Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}") else @@ -72,7 +72,7 @@ class Chef end def current_installed_version - pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0,1]) + pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0, 1]) pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1] end diff --git a/lib/chef/provider/package/freebsd/pkgng.rb b/lib/chef/provider/package/freebsd/pkgng.rb index e3fa0ad571..de7bea6387 100644 --- a/lib/chef/provider/package/freebsd/pkgng.rb +++ b/lib/chef/provider/package/freebsd/pkgng.rb @@ -44,7 +44,7 @@ class Chef end def current_installed_version - pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70]) + pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70]) pkg_info.stdout[/^Version +: (.+)$/, 1] end diff --git a/lib/chef/provider/package/freebsd/port.rb b/lib/chef/provider/package/freebsd/port.rb index 39b7b00988..3eb3c5ab01 100644 --- a/lib/chef/provider/package/freebsd/port.rb +++ b/lib/chef/provider/package/freebsd/port.rb @@ -35,9 +35,9 @@ class Chef def current_installed_version pkg_info = if @new_resource.supports_pkgng? - shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70]) + shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70]) else - shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0,1]) + shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0, 1]) end pkg_info.stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1] end diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb index c7ea71ac8c..b110207d8a 100644 --- a/lib/chef/provider/package/macports.rb +++ b/lib/chef/provider/package/macports.rb @@ -81,6 +81,7 @@ class Chef end private + def get_response_from_command(command) output = nil status = shell_out_with_timeout(command) diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb index 3e209bcf99..2120b9aa48 100644 --- a/lib/chef/provider/package/openbsd.rb +++ b/lib/chef/provider/package/openbsd.rb @@ -72,7 +72,7 @@ class Chef if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add name = parts[1] end - shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => {"PKG_PATH" => pkg_path}).status + shell_out_with_timeout!("pkg_add -r #{name}#{version_string(version)}", :env => { "PKG_PATH" => pkg_path }).status Chef::Log.debug("#{new_resource.package_name} installed") end end @@ -92,7 +92,7 @@ class Chef else name = new_resource.package_name end - pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0,1]) + pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0, 1]) result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1] Chef::Log.debug("installed_version of '#{new_resource.package_name}' is '#{result}'") result @@ -101,7 +101,7 @@ class Chef def candidate_version @candidate_version ||= begin results = [] - shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0,1]).stdout.each_line do |line| + shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string(new_resource.version)}\"", :env => nil, :returns => [0, 1]).stdout.each_line do |line| if parts = new_resource.package_name.match(/^(.+?)--(.+)/) results << line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1] else diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb index ad7db25f49..22fa9c2307 100644 --- a/lib/chef/provider/package/pacman.rb +++ b/lib/chef/provider/package/pacman.rb @@ -52,14 +52,14 @@ class Chef def candidate_version return @candidate_version if @candidate_version - repos = ["extra","core","community"] + repos = ["extra", "core", "community"] if(::File.exists?("/etc/pacman.conf")) pacman = ::File.read("/etc/pacman.conf") repos = pacman.scan(/\[(.+)\]/).flatten end - package_repos = repos.map {|r| Regexp.escape(r) }.join("|") + package_repos = repos.map { |r| Regexp.escape(r) }.join("|") status = shell_out_with_timeout("pacman -Sl") status.stdout.each_line do |line| @@ -80,7 +80,6 @@ class Chef end @candidate_version - end def install_package(name, version) diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb index 51437025e1..e1b2ea1cf4 100644 --- a/lib/chef/provider/package/paludis.rb +++ b/lib/chef/provider/package/paludis.rb @@ -59,7 +59,7 @@ class Chef else pkg = "#{@new_resource.package_name}" end - shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"",:timeout => @new_resource.timeout) + shell_out!("cave -L warning resolve -x#{expand_options(@new_resource.options)} \"#{pkg}\"", :timeout => @new_resource.timeout) end def upgrade_package(name, version) diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb index 4d99d75ca2..688509889c 100644 --- a/lib/chef/provider/package/portage.rb +++ b/lib/chef/provider/package/portage.rb @@ -35,11 +35,11 @@ class Chef @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) - category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1,2] + category, pkg = %r{^#{PACKAGE_NAME_PATTERN}$}.match(@new_resource.package_name)[1, 2] globsafe_category = category ? Chef::Util::PathHelper.escape_glob(category) : nil globsafe_pkg = Chef::Util::PathHelper.escape_glob(pkg) - possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map {|d| d.sub(%r{/var/db/pkg/}, "") } + possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") } versions = possibilities.map do |entry| if(entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)}) [$&, $1] @@ -47,8 +47,8 @@ class Chef end.compact if versions.size > 1 - atoms = versions.map {|v| v.first }.sort - categories = atoms.map {|v| v.split("/")[0] }.uniq + atoms = versions.map { |v| v.first }.sort + categories = atoms.map { |v| v.split("/")[0] }.uniq if !category && categories.size > 1 raise Chef::Exceptions::Package, "Multiple packages found for #{@new_resource.package_name}: #{atoms.join(" ")}. Specify a category." end @@ -103,7 +103,6 @@ class Chef end @candidate_version - end def install_package(name, version) diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index b176114a15..7a2db6b32b 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -47,7 +47,7 @@ class Chef # alternate value and overwrite it with the defaults. Gem.configuration - DEFAULT_UNINSTALLER_OPTS = {:ignore => true, :executables => true} + DEFAULT_UNINSTALLER_OPTS = { :ignore => true, :executables => true } ## # The paths where rubygems should search for installed gems. @@ -133,7 +133,7 @@ class Chef def candidate_version_from_file(gem_dependency, source) spec = spec_from_file(source) if spec.satisfies_requirement?(gem_dependency) - logger.debug {"#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}"} + logger.debug { "#{@new_resource} found candidate gem version #{spec.version} from local gem package #{source}" } spec.version else # This is probably going to end badly... @@ -189,7 +189,7 @@ class Chef # === Options # :sources rubygems servers to use # Other options are passed to Gem::DependencyInstaller.new - def install(gem_dependency, options={}) + def install(gem_dependency, options = {}) with_gem_sources(*options.delete(:sources)) do with_correct_verbosity do dependency_installer(options).install(gem_dependency) @@ -203,7 +203,7 @@ class Chef # Otherwise, all versions are uninstalled. # === Options # Options are passed to Gem::Uninstaller.new - def uninstall(gem_name, gem_version=nil, opts={}) + def uninstall(gem_name, gem_version = nil, opts = {}) gem_version ? opts[:version] = gem_version : opts[:all] = true with_correct_verbosity do uninstaller(gem_name, opts).uninstall @@ -218,11 +218,11 @@ class Chef yield end - def dependency_installer(opts={}) + def dependency_installer(opts = {}) Gem::DependencyInstaller.new(opts) end - def uninstaller(gem_name, opts={}) + def uninstaller(gem_name, opts = {}) Gem::Uninstaller.new(gem_name, DEFAULT_UNINSTALLER_OPTS.merge(opts)) end @@ -358,7 +358,7 @@ class Chef include Chef::Mixin::GetSourceFromPackage - def initialize(new_resource, run_context=nil) + def initialize(new_resource, run_context = nil) super @cleanup_gem_env = true if new_resource.gem_binary @@ -398,7 +398,7 @@ class Chef Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}") # Omnibus installs to a static path because of linking on unix, find it. true - elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin" + elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin" Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}") # windows, with the drive letter removed true @@ -436,7 +436,7 @@ class Chef # is the current version if !matching_installed_versions.empty? gemspec = matching_installed_versions.last - logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}"} + logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" } gemspec # If no version matching the requirements exists, the latest installed # version is the current version. @@ -445,7 +445,7 @@ class Chef logger.debug { "#{@new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" } gemspec else - logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}"} + logger.debug { "#{@new_resource} no installed version found for #{gem_dependency}" } nil end end @@ -519,7 +519,7 @@ class Chef elsif @new_resource.gem_binary.nil? @gem_env.install(@new_resource.source) else - install_via_gem_command(name,version) + install_via_gem_command(name, version) end true end @@ -538,9 +538,9 @@ class Chef src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org" end if !version.nil? && version.length > 0 - shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil) + shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env => nil) else - shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil) + shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env => nil) end end @@ -564,9 +564,9 @@ class Chef def uninstall_via_gem_command(name, version) if version - shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil) + shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env => nil) else - shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env=>nil) + shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env => nil) end end diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb index 5ef8ae2cbe..3f09bef212 100644 --- a/lib/chef/provider/package/smartos.rb +++ b/lib/chef/provider/package/smartos.rb @@ -43,7 +43,7 @@ class Chef def check_package_state(name) Chef::Log.debug("#{@new_resource} checking package #{name}") version = nil - info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0,1]) + info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0, 1]) if info.stdout version = info.stdout[/^#{@new_resource.package_name}-(.+)/, 1] @@ -58,7 +58,7 @@ class Chef return @candidate_version if @candidate_version name = nil version = nil - pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0,1]) + pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0, 1]) pkg.stdout.each_line do |line| case line when /^#{new_resource.package_name}/ diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb index c5aed43c9b..dc22de7ad5 100644 --- a/lib/chef/provider/package/windows.rb +++ b/lib/chef/provider/package/windows.rb @@ -79,7 +79,7 @@ class Chef if new_resource.installer_type new_resource.installer_type elsif source_location.nil? - inferred_registry_type + inferred_registry_type else basename = ::File.basename(source_location) file_extension = basename.split(".").last.downcase @@ -220,7 +220,7 @@ class Chef r.backup(false) if new_resource.remote_file_attributes - new_resource.remote_file_attributes.each do |(k,v)| + new_resource.remote_file_attributes.each do |(k, v)| r.send(k.to_sym, v) end end diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb index 62c3be1e25..ac771688e7 100644 --- a/lib/chef/provider/package/windows/msi.rb +++ b/lib/chef/provider/package/windows/msi.rb @@ -67,22 +67,22 @@ class Chef def install_package # We could use MsiConfigureProduct here, but we'll start off with msiexec Chef::Log.debug("#{new_resource} installing MSI package '#{new_resource.source}'") - shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns}) + shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns }) end def remove_package # We could use MsiConfigureProduct here, but we'll start off with msiexec if !new_resource.source.nil? && ::File.exist?(new_resource.source) Chef::Log.debug("#{new_resource} removing MSI package '#{new_resource.source}'") - shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", {:timeout => new_resource.timeout, :returns => new_resource.returns}) + shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", { :timeout => new_resource.timeout, :returns => new_resource.returns }) else uninstall_version = new_resource.version || installed_version uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) } .map { |version| version.uninstall_string }.uniq.each do |uninstall_string| - Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'") - uninstall_string += expand_options(new_resource.options) - uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/ - shell_out!(uninstall_string, {:timeout => new_resource.timeout, :returns => new_resource.returns}) + Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'") + uninstall_string += expand_options(new_resource.options) + uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/ + shell_out!(uninstall_string, { :timeout => new_resource.timeout, :returns => new_resource.returns }) end end end diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index a0629842f2..aeecf3869e 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -63,7 +63,7 @@ class Chef end end - version = evr[lead,tail] + version = evr[lead, tail] if version.empty? version = nil end @@ -159,12 +159,12 @@ class Chef end # copy the segment but not the unmatched character that x_seg_pos will # refer to - x_comp = x[x_pos,x_seg_pos - x_pos] + x_comp = x[x_pos, x_seg_pos - x_pos] while (y_seg_pos <= y_pos_max) and isdigit(y[y_seg_pos]) y_seg_pos += 1 end - y_comp = y[y_pos,y_seg_pos - y_pos] + y_comp = y[y_pos, y_seg_pos - y_pos] else # we are comparing strings x_seg_is_num = false @@ -172,12 +172,12 @@ class Chef while (x_seg_pos <= x_pos_max) and isalpha(x[x_seg_pos]) x_seg_pos += 1 end - x_comp = x[x_pos,x_seg_pos - x_pos] + x_comp = x[x_pos, x_seg_pos - x_pos] while (y_seg_pos <= y_pos_max) and isalpha(y[y_seg_pos]) y_seg_pos += 1 end - y_comp = y[y_pos,y_seg_pos - y_pos] + y_comp = y[y_pos, y_seg_pos - y_pos] end # if y_seg_pos didn't advance in the above loop it means the segments are @@ -240,7 +240,7 @@ class Chef @r = args[2] else raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " + - "version, release'" + "version, release'" end end attr_reader :e, :v, :r @@ -286,7 +286,7 @@ class Chef # 2:1.2-1 == 2:1.2 # 2:1.2-1 == 2: # - def compare_versions(y, partial=false) + def compare_versions(y, partial = false) x = self # compare epoch @@ -344,12 +344,12 @@ class Chef e = args[1].to_i v = args[2] r = args[3] - @version = RPMVersion.new(e,v,r) + @version = RPMVersion.new(e, v, r) @a = args[4] @provides = args[5] else raise ArgumentError, "Expecting either 'name, epoch-version-release, arch, provides' " + - "or 'name, epoch, version, release, arch, provides'" + "or 'name, epoch, version, release, arch, provides'" end # We always have one, ourselves! @@ -429,11 +429,11 @@ class Chef e = args[1].to_i v = args[2] r = args[3] - @version = RPMVersion.new(e,v,r) + @version = RPMVersion.new(e, v, r) @flag = args[4] || :== else raise ArgumentError, "Expecting either 'name, epoch-version-release, flag' or " + - "'name, epoch, version, release, flag'" + "'name, epoch, version, release, flag'" end end attr_reader :name, :version, :flag @@ -690,15 +690,15 @@ class Chef when :installed reset_installed # fast - opts=" --installed" + opts = " --installed" when :all reset # medium - opts=" --options --installed-provides" + opts = " --options --installed-provides" when :provides reset # slow! - opts=" --options --all-provides" + opts = " --options --all-provides" else raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}" end @@ -870,7 +870,7 @@ class Chef end # Check if a package-version.arch is available to install - def version_available?(package_name, desired_version, arch=nil) + def version_available?(package_name, desired_version, arch = nil) version(package_name, arch, true, false) do |v| return true if desired_version == v end @@ -879,7 +879,7 @@ class Chef end # Return the source repository for a package-version.arch - def package_repository(package_name, desired_version, arch=nil) + def package_repository(package_name, desired_version, arch = nil) package(package_name, arch, true, false) do |pkg| return pkg.repoid if desired_version == pkg.version.to_s end @@ -888,13 +888,13 @@ class Chef end # Return the latest available version for a package.arch - def available_version(package_name, arch=nil) + def available_version(package_name, arch = nil) version(package_name, arch, true, false) end alias :candidate_version :available_version # Return the currently installed version for a package.arch - def installed_version(package_name, arch=nil) + def installed_version(package_name, arch = nil) version(package_name, arch, false, true) end @@ -922,7 +922,7 @@ class Chef private - def version(package_name, arch=nil, is_available=false, is_installed=false) + def version(package_name, arch = nil, is_available = false, is_installed = false) package(package_name, arch, is_available, is_installed) do |pkg| if block_given? yield pkg.version.to_s @@ -939,7 +939,7 @@ class Chef end end - def package(package_name, arch=nil, is_available=false, is_installed=false) + def package(package_name, arch = nil, is_available = false, is_installed = false) refresh packages = @rpmdb[package_name] if packages @@ -1049,7 +1049,7 @@ class Chef def yum_command(command) command = "#{yum_binary} #{command}" Chef::Log.debug("#{@new_resource}: yum command: \"#{command}\"") - status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]}) + status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] }) # This is fun: rpm can encounter errors in the %post/%postun scripts which aren't # considered fatal - meaning the rpm is still successfully installed. These issue @@ -1066,7 +1066,7 @@ class Chef if l =~ %r{^error: %(post|postun)\(.*\) scriptlet failed, exit status \d+$} Chef::Log.warn("#{@new_resource} caught non-fatal scriptlet issue: \"#{l}\". Can't trust yum exit status " + "so running install again to verify.") - status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]}) + status = shell_out_with_timeout(command, { :timeout => Chef::Config[:yum_timeout] }) break end end @@ -1126,7 +1126,6 @@ class Chef end end - @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) @@ -1225,7 +1224,7 @@ class Chef else # we bail like yum when the package is older raise Chef::Exceptions::Package, "Installed package #{n}-#{current_version_array[idx]} is newer " + - "than candidate package #{n}-#{v}" + "than candidate package #{n}-#{v}" end end end @@ -1258,7 +1257,7 @@ class Chef yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}") else raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " + - "and release? (version-release, e.g. 1.84-10.fc6)" + "and release? (version-release, e.g. 1.84-10.fc6)" end end @@ -1359,7 +1358,7 @@ class Chef # matching them up with an actual package so the standard resource handling can apply. # # There is currently no support for filename matching. - def parse_dependency(name,version) + def parse_dependency(name, version) # Transform the package_name into a requirement # If we are passed a version or a version constraint we have to assume it's a requirement first. If it can't be @@ -1412,7 +1411,7 @@ class Chef new_package_version = nil end - [new_package_name,new_package_version] + [new_package_name, new_package_version] end end diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb index 5d42772a48..2441b46013 100644 --- a/lib/chef/provider/package/zypper.rb +++ b/lib/chef/provider/package/zypper.rb @@ -42,10 +42,10 @@ class Chef candidate_version = $1 Chef::Log.debug("#{new_resource} version #{$1}") when /^Installed: Yes$/ - is_installed=true + is_installed = true Chef::Log.debug("#{new_resource} is installed") when /^Status: out-of-date \(version (.+) installed\)$/ - current_version=$1 + current_version = $1 Chef::Log.debug("#{new_resource} out of date version #{$1}") end end |