diff options
Diffstat (limited to 'lib/chef/provider')
22 files changed, 72 insertions, 72 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 4f17da0288..82f5ca2ba5 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -143,7 +143,7 @@ class Chef args = [] args << "-o #{remote}" unless remote == "origin" args << "--depth #{@new_resource.depth}" if @new_resource.depth - args << "--no-single-branch" if @new_resource.depth and git_minor_version >= Gem::Version.new("1.7.10") + args << "--no-single-branch" if @new_resource.depth && git_minor_version >= Gem::Version.new("1.7.10") Chef::Log.info "#{@new_resource} cloning repo #{@new_resource.repository} to #{@new_resource.destination}" diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index e73869d829..4cfb257bb9 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -168,7 +168,7 @@ class Chef end def can_generate_config? - ! @config_template.nil? and ! @config_path.nil? + ! @config_template.nil? && ! @config_path.nil? end def resource_for_config(path) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index 83b5dd8c00..5fce97e5b3 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -74,8 +74,8 @@ class Chef requirements.assert(:delete) do |a| a.assertion do if @current_resource.to - @current_resource.link_type == @new_resource.link_type and - (@current_resource.link_type == :symbolic or @current_resource.to != "") + @current_resource.link_type == @new_resource.link_type && + (@current_resource.link_type == :symbolic || @current_resource.to != "") else true end diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index c815c9ccb8..07da6ac361 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -133,7 +133,7 @@ class Chef end def remount_fs - if @current_resource.mounted and @new_resource.supports[:remount] + if @current_resource.mounted && @new_resource.supports[:remount] shell_out!(remount_command) @new_resource.updated_by_last_action(true) Chef::Log.debug("#{@new_resource} is remounted at #{@new_resource.mount_point}") @@ -258,9 +258,9 @@ class Chef end def mount_options_unchanged? - @current_resource.fstype == @new_resource.fstype and - @current_resource.options == @new_resource.options and - @current_resource.dump == @new_resource.dump and + @current_resource.fstype == @new_resource.fstype && + @current_resource.options == @new_resource.options && + @current_resource.dump == @new_resource.dump && @current_resource.pass == @new_resource.pass end diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb index 3e37cbc9a5..6ac67e0560 100644 --- a/lib/chef/provider/osx_profile.rb +++ b/lib/chef/provider/osx_profile.rb @@ -68,15 +68,15 @@ class Chef requirements.assert(:remove) do |a| if @new_profile_identifier a.assertion { - !@new_profile_identifier.nil? and - !@new_profile_identifier.end_with?(".mobileconfig") and + !@new_profile_identifier.nil? && + !@new_profile_identifier.end_with?(".mobileconfig") && /^\w+(?:\.\w+)+$/.match(@new_profile_identifier) } a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier" else new_profile_name = @new_resource.profile_name a.assertion { - !new_profile_name.end_with?(".mobileconfig") and + !new_profile_name.end_with?(".mobileconfig") && /^\w+(?:\.\w+)+$/.match(new_profile_name) } a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier " @@ -239,7 +239,7 @@ class Chef def profile_installed? # Profile Identifier and UUID must match a currently installed profile - if @current_resource.profile.nil? or @current_resource.profile.empty? + if @current_resource.profile.nil? || @current_resource.profile.empty? false else if @new_resource.action.include?(:remove) diff --git a/lib/chef/provider/package/homebrew.rb b/lib/chef/provider/package/homebrew.rb index c032881e70..853a354b28 100644 --- a/lib/chef/provider/package/homebrew.rb +++ b/lib/chef/provider/package/homebrew.rb @@ -53,7 +53,7 @@ class Chef def upgrade_package(name, version) current_version = current_resource.version - if current_version.nil? or current_version.empty? + if current_version.nil? || current_version.empty? install_package(name, version) elsif current_version != version brew("upgrade", new_resource.options, name) diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb index dc83e4aa08..85053d47f2 100644 --- a/lib/chef/provider/package/ips.rb +++ b/lib/chef/provider/package/ips.rb @@ -69,7 +69,7 @@ class Chef package_name = "#{name}@#{version}" normal_command = "pkg#{expand_options(@new_resource.options)} install -q #{package_name}" command = - if @new_resource.respond_to?(:accept_license) and @new_resource.accept_license + if @new_resource.respond_to?(:accept_license) && @new_resource.accept_license normal_command.gsub("-q", "-q --accept") else normal_command diff --git a/lib/chef/provider/package/macports.rb b/lib/chef/provider/package/macports.rb index b110207d8a..7bbc68aba8 100644 --- a/lib/chef/provider/package/macports.rb +++ b/lib/chef/provider/package/macports.rb @@ -15,7 +15,7 @@ class Chef @candidate_version = macports_candidate_version - if !@new_resource.version and !@candidate_version + if !@new_resource.version && !@candidate_version raise Chef::Exceptions::Package, "Could not get a candidate version for this package -- #{@new_resource.name} does not seem to be a valid package!" end @@ -48,20 +48,20 @@ class Chef def install_package(name, version) unless @current_resource.version == version command = "port#{expand_options(@new_resource.options)} install #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end end def purge_package(name, version) command = "port#{expand_options(@new_resource.options)} uninstall #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end def remove_package(name, version) command = "port#{expand_options(@new_resource.options)} deactivate #{name}" - command << " @#{version}" if version and !version.empty? + command << " @#{version}" if version && !version.empty? shell_out_with_timeout!(command) end @@ -71,7 +71,7 @@ class Chef # happens otherwise... current_version = @current_resource.version - if current_version.nil? or current_version.empty? + if current_version.nil? || current_version.empty? # Macports doesn't like when you upgrade a package # that hasn't been installed. install_package(name, version) diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index 60abbed7c8..39eff19bd0 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -115,7 +115,7 @@ class Chef # Compatibility note: Rubygems 1.x uses Gem::Format, 2.0 moved this # code into Gem::Package. def spec_from_file(file) - if defined?(Gem::Format) and Gem::Package.respond_to?(:open) + if defined?(Gem::Format) && Gem::Package.respond_to?(:open) Gem::Format.from_file_by_path(file).spec else Gem::Package.new(file).spec diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 858b430abe..73507ec5ab 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -73,17 +73,17 @@ class Chef # verify def isalnum(x) - isalpha(x) or isdigit(x) + isalpha(x) || isdigit(x) end def isalpha(x) v = x.ord - (v >= 65 and v <= 90) or (v >= 97 and v <= 122) + (v >= 65 && v <= 90) || (v >= 97 && v <= 122) end def isdigit(x) v = x.ord - v >= 48 and v <= 57 + v >= 48 && v <= 57 end # based on the reference spec in lib/rpmvercmp.c in rpm 4.9.0 @@ -128,17 +128,17 @@ class Chef y_pos_max = y.length - 1 y_comp = nil - while x_pos <= x_pos_max and y_pos <= y_pos_max + while x_pos <= x_pos_max && y_pos <= y_pos_max # first we skip over anything non alphanumeric - while (x_pos <= x_pos_max) and (isalnum(x[x_pos]) == false) + while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false) x_pos += 1 # +1 over pos_max if end of string end - while (y_pos <= y_pos_max) and (isalnum(y[y_pos]) == false) + while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false) y_pos += 1 end # if we hit the end of either we are done matching segments - if (x_pos == x_pos_max + 1) or (y_pos == y_pos_max + 1) + if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1) break end @@ -154,14 +154,14 @@ class Chef x_seg_pos += 1 # gather up our digits - while (x_seg_pos <= x_pos_max) and isdigit(x[x_seg_pos]) + while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos]) x_seg_pos += 1 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] - while (y_seg_pos <= y_pos_max) and isdigit(y[y_seg_pos]) + while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos]) y_seg_pos += 1 end y_comp = y[y_pos, y_seg_pos - y_pos] @@ -169,12 +169,12 @@ class Chef # we are comparing strings x_seg_is_num = false - while (x_seg_pos <= x_pos_max) and isalpha(x[x_seg_pos]) + while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos]) x_seg_pos += 1 end x_comp = x[x_pos, x_seg_pos - x_pos] - while (y_seg_pos <= y_pos_max) and isalpha(y[y_seg_pos]) + while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos]) y_seg_pos += 1 end y_comp = y[y_pos, y_seg_pos - y_pos] @@ -213,7 +213,7 @@ class Chef # segments matched completely but the segment separators were different - # rpm reference code treats these as equal. - if (x_pos == x_pos_max + 1) and (y_pos == y_pos_max + 1) + if (x_pos == x_pos_max + 1) && (y_pos == y_pos_max + 1) return 0 end @@ -290,11 +290,11 @@ class Chef x = self # compare epoch - if (x.e.nil? == false and x.e > 0) and y.e.nil? + if (x.e.nil? == false && x.e > 0) && y.e.nil? return 1 - elsif x.e.nil? and (y.e.nil? == false and y.e > 0) + elsif x.e.nil? && (y.e.nil? == false && y.e > 0) return -1 - elsif x.e.nil? == false and y.e.nil? == false + elsif x.e.nil? == false && y.e.nil? == false if x.e < y.e return -1 elsif x.e > y.e @@ -303,25 +303,25 @@ class Chef end # compare version - if partial and (x.v.nil? or y.v.nil?) + if partial && (x.v.nil? || y.v.nil?) return 0 - elsif x.v.nil? == false and y.v.nil? + elsif x.v.nil? == false && y.v.nil? return 1 - elsif x.v.nil? and y.v.nil? == false + elsif x.v.nil? && y.v.nil? == false return -1 - elsif x.v.nil? == false and y.v.nil? == false + elsif x.v.nil? == false && y.v.nil? == false cmp = RPMUtils.rpmvercmp(x.v, y.v) return cmp if cmp != 0 end # compare release - if partial and (x.r.nil? or y.r.nil?) + if partial && (x.r.nil? || y.r.nil?) return 0 - elsif x.r.nil? == false and y.r.nil? + elsif x.r.nil? == false && y.r.nil? return 1 - elsif x.r.nil? and y.r.nil? == false + elsif x.r.nil? && y.r.nil? == false return -1 - elsif x.r.nil? == false and y.r.nil? == false + elsif x.r.nil? == false && y.r.nil? == false cmp = RPMUtils.rpmvercmp(x.r, y.r) return cmp end @@ -372,11 +372,11 @@ class Chef return 0 if x.nevra == y.nevra # compare name - if x.n.nil? == false and y.n.nil? + if x.n.nil? == false && y.n.nil? return 1 - elsif x.n.nil? and y.n.nil? == false + elsif x.n.nil? && y.n.nil? == false return -1 - elsif x.n.nil? == false and y.n.nil? == false + elsif x.n.nil? == false && y.n.nil? == false if x.n < y.n return -1 elsif x.n > y.n @@ -392,11 +392,11 @@ class Chef end # compare arch - if x.a.nil? == false and y.a.nil? + if x.a.nil? == false && y.a.nil? return 1 - elsif x.a.nil? and y.a.nil? == false + elsif x.a.nil? && y.a.nil? == false return -1 - elsif x.a.nil? == false and y.a.nil? == false + elsif x.a.nil? == false && y.a.nil? == false if x.a < y.a return -1 elsif x.a > y.a @@ -482,10 +482,10 @@ class Chef return true elsif sense > 0 and (x.flag == :< || x.flag == :<=) || (y.flag == :>= || y.flag == :>) return true - elsif sense == 0 and ( - ((x.flag == :== or x.flag == :<= or x.flag == :>=) and (y.flag == :== or y.flag == :<= or y.flag == :>=)) or - (x.flag == :< and y.flag == :<) or - (x.flag == :> and y.flag == :>) + elsif sense == 0 && ( + ((x.flag == :== || x.flag == :<= || x.flag == :>=) && (y.flag == :== || y.flag == :<= || y.flag == :>=)) || + (x.flag == :< && y.flag == :<) || + (x.flag == :> && y.flag == :>) ) return true end @@ -1340,7 +1340,7 @@ class Chef old_candidate = @yum.candidate_version(package_name) new_installed = @yum.installed_version(new_package_name, new_arch) new_candidate = @yum.candidate_version(new_package_name, new_arch) - if (old_installed.nil? and old_candidate.nil?) and (new_installed or new_candidate) + if (old_installed.nil? && old_candidate.nil?) && (new_installed || new_candidate) Chef::Log.debug("Parsed out arch #{new_arch}, new package name is #{new_package_name}") return new_package_name, new_arch end @@ -1378,7 +1378,7 @@ class Chef if packages.empty? # Don't bother if we are just ensuring a package is removed - we don't need Provides data actions = Array(@new_resource.action) - unless actions.size == 1 and (actions[0] == :remove || actions[0] == :purge) + unless actions.size == 1 && (actions[0] == :remove || actions[0] == :purge) Chef::Log.debug("#{@new_resource} couldn't match #{@new_resource.package_name} in " + "installed Provides, loading available Provides - this may take a moment") @yum.reload_provides diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb index 7aa059f4cb..8d7de5c370 100644 --- a/lib/chef/provider/remote_file/cache_control_data.rb +++ b/lib/chef/provider/remote_file/cache_control_data.rb @@ -96,7 +96,7 @@ class Chef end def validate!(current_copy_checksum) - if current_copy_checksum.nil? or checksum != current_copy_checksum + if current_copy_checksum.nil? || checksum != current_copy_checksum reset! false else diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb index 448acdb018..b49e84fa69 100644 --- a/lib/chef/provider/remote_file/ftp.rb +++ b/lib/chef/provider/remote_file/ftp.rb @@ -112,7 +112,7 @@ class Chef def validate_typecode! # Only support ascii and binary types - if typecode and /\A[ai]\z/ !~ typecode + if typecode && /\A[ai]\z/ !~ typecode raise ArgumentError, "invalid typecode: #{typecode.inspect}" end end diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 6fa574e777..6a9738c02b 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -45,10 +45,10 @@ class Chef def conditional_get_headers cache_control_headers = {} - if last_modified = cache_control_data.mtime and want_mtime_cache_control? + if (last_modified = cache_control_data.mtime) && want_mtime_cache_control? cache_control_headers["if-modified-since"] = last_modified end - if etag = cache_control_data.etag and want_etag_cache_control? + if (etag = cache_control_data.etag) && want_etag_cache_control? cache_control_headers["if-none-match"] = etag end Chef::Log.debug("Cache control headers: #{cache_control_headers.inspect}") diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb index 0234673474..73c5e07715 100644 --- a/lib/chef/provider/service/aixinit.rb +++ b/lib/chef/provider/service/aixinit.rb @@ -44,7 +44,7 @@ class Chef else priority_ok = @current_resource.priority == @new_resource.priority end - if @current_resource.enabled and priority_ok + if @current_resource.enabled && priority_ok Chef::Log.debug("#{@new_resource} already enabled - nothing to do") else converge_by("enable service #{@new_resource}") do diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb index c0545e9fb3..2fd32e37aa 100644 --- a/lib/chef/provider/service/arch.rb +++ b/lib/chef/provider/service/arch.rb @@ -70,7 +70,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init new_daemons = [] entries = daemons - if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}") + if entries.include?(new_resource.service_name) || entries.include?("@#{new_resource.service_name}") # exists and already enabled (or already enabled as a background service) # new_daemons += entries else @@ -100,7 +100,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init # exists and disabled # new_daemons += entries else - if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}") + if entries.include?(new_resource.service_name) || entries.include?("@#{new_resource.service_name}") # exists but enabled (or enabled as a back-ground service) # FIXME: Does arch support !@foobar ? entries.each do |daemon| diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb index 6550c85b2a..67b71953f7 100644 --- a/lib/chef/provider/service/debian.rb +++ b/lib/chef/provider/service/debian.rb @@ -124,7 +124,7 @@ class Chef else priority_ok = @current_resource.priority == new_resource.priority end - if current_resource.enabled and priority_ok + if current_resource.enabled && priority_ok Chef::Log.debug("#{new_resource} already enabled - nothing to do") else converge_by("enable service #{new_resource}") do diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 56064bc03a..8fb6d1f9af 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -38,7 +38,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init exists = ::File.exists? file readable = ::File.readable? file Chef::Log.debug "#{@new_resource} exists: #{exists}, readable: #{readable}" - exists and readable + exists && readable end ) Chef::Log.debug "#{@new_resource} enabled: #{@current_resource.enabled}" diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index e6e57e4695..648cd9748b 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -181,7 +181,7 @@ class Chef end def set_service_status - return if @plist == nil or @service_label.to_s.empty? + return if @plist == nil || @service_label.to_s.empty? cmd = "launchctl list #{@service_label}" res = shell_out_as_user(cmd) diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index a76622ee8f..08f8e108d5 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -76,7 +76,7 @@ class Chef if ::File.exists?("/sbin/chkconfig") chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1]) - unless run_levels.nil? or run_levels.empty? + unless run_levels.nil? || run_levels.empty? all_levels_match = true chkconfig.stdout.split(/\s+/)[1..-1].each do |level| index = level.split(":").first @@ -100,11 +100,11 @@ class Chef # @api private def levels - (run_levels.nil? or run_levels.empty?) ? "" : "--level #{run_levels.join('')} " + (run_levels.nil? || run_levels.empty?) ? "" : "--level #{run_levels.join('')} " end def enable_service() - unless run_levels.nil? or run_levels.empty? + unless run_levels.nil? || run_levels.empty? disable_levels = current_run_levels - run_levels shell_out! "/sbin/chkconfig --level #{disable_levels.join('')} #{new_resource.service_name} off" unless disable_levels.empty? end diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index d76779a74b..fe4768b2e8 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -76,8 +76,8 @@ class Chef end requirements.assert(:all_actions) do |a| - a.assertion { @new_resource.status_command or supports[:status] or - (!ps_cmd.nil? and !ps_cmd.empty?) } + a.assertion { @new_resource.status_command || supports[:status] || + (!ps_cmd.nil? && !ps_cmd.empty?) } a.failure_message Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this node's 'command.ps' attribute" end requirements.assert(:all_actions) do |a| diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb index 42798a5f62..3f168b8da3 100644 --- a/lib/chef/provider/user/aix.rb +++ b/lib/chef/provider/user/aix.rb @@ -79,7 +79,7 @@ class Chef # Aix specific handling to update users home directory. def manage_home # -m option does not work on aix, so move dir. - if updating_home? and managing_home_dir? + if updating_home? && managing_home_dir? universal_options.delete("-m") if ::File.directory?(@current_resource.home) Chef::Log.debug("Changing users home directory from #{@current_resource.home} to #{new_resource.home}") diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index e2f5b5897a..3fef8d3642 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -150,7 +150,7 @@ class Chef # ::File.expand_path("///tmp") == ::File.expand_path("/tmp") => false # ::File.expand_path("\\tmp") => "C:/tmp" return true if @current_resource.home.nil? && new_resource.home - new_resource.home and Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath + new_resource.home && Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath end def managing_home_dir? |