diff options
| author | James Turnbull <james@lovedthanlost.net> | 2009-02-26 11:43:39 +1100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-02-26 11:43:39 +1100 |
| commit | 5f73eb553fd083b558fb9553b0c07b6019d0ccee (patch) | |
| tree | 123ef2a9c7b8aa4e1cd52e6b98d0b3c53d626de6 | |
| parent | e40aea3c655e698d26c29370227b52c489e6db2b (diff) | |
| download | puppet-5f73eb553fd083b558fb9553b0c07b6019d0ccee.tar.gz puppet-5f73eb553fd083b558fb9553b0c07b6019d0ccee.tar.xz puppet-5f73eb553fd083b558fb9553b0c07b6019d0ccee.zip | |
Fixed #1849 - Ruby 1.9 portability: `when' doesn't like colons, replace with semicolons
76 files changed, 256 insertions, 254 deletions
@@ -1,4 +1,6 @@ 0.25.0 + Fixed #1849 - Ruby 1.9 portability: `when' doesn't like colons, replace with semicolons + Fixed #1910 - Updated logcheck regex Fixed #1879 - Added to tidy documentation diff --git a/ext/puppetstoredconfigclean.rb b/ext/puppetstoredconfigclean.rb index f286df2df..a96ec4faf 100644 --- a/ext/puppetstoredconfigclean.rb +++ b/ext/puppetstoredconfigclean.rb @@ -57,9 +57,9 @@ adapter = pm_conf[:dbadapter] args = {:adapter => adapter, :log_level => pm_conf[:rails_loglevel]} case adapter - when "sqlite3": + when "sqlite3" args[:dbfile] = pm_conf[:dblocation] - when "mysql", "postgresql": + when "mysql", "postgresql" args[:host] = pm_conf[:dbserver] unless pm_conf[:dbserver].to_s.empty? args[:username] = pm_conf[:dbuser] unless pm_conf[:dbuser].to_s.empty? args[:password] = pm_conf[:dbpassword] unless pm_conf[:dbpassword].to_s.empty? diff --git a/lib/puppet.rb b/lib/puppet.rb index 4e0266703..e9ba2f2be 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -74,7 +74,7 @@ module Puppet # configuration parameter access and stuff def self.[](param) case param - when :debug: + when :debug if Puppet::Util::Log.level == :debug return true else diff --git a/lib/puppet/application/puppetrun.rb b/lib/puppet/application/puppetrun.rb index 42f02c796..59ace826a 100644 --- a/lib/puppet/application/puppetrun.rb +++ b/lib/puppet/application/puppetrun.rb @@ -135,8 +135,8 @@ Puppet::Application.new(:puppetrun) do end case result - when "success": exit(0) - when "running": + when "success"; exit(0) + when "running" $stderr.puts "Host %s is already running" % host exit(3) else diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index b29082d5a..e6fdbee15 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -150,13 +150,13 @@ class Puppet::Configurer def self.timeout timeout = Puppet[:configtimeout] case timeout - when String: + when String if timeout =~ /^\d+$/ timeout = Integer(timeout) else raise ArgumentError, "Configuration timeout must be an integer" end - when Integer: # nothing + when Integer # nothing else raise ArgumentError, "Configuration timeout must be an integer" end diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 8a2eb0b82..9653c3a58 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -8,13 +8,13 @@ class Puppet::Configurer::Downloader def self.timeout timeout = Puppet[:configtimeout] case timeout - when String: + when String if timeout =~ /^\d+$/ timeout = Integer(timeout) else raise ArgumentError, "Configuration timeout must be an integer" end - when Integer: # nothing + when Integer # nothing else raise ArgumentError, "Configuration timeout must be an integer" end diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index f36bef639..c86e00a62 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -20,20 +20,20 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile @count += 1 case line - when /^\s*#/: next # skip comments - when /^\s*$/: next # skip blank lines - when /\[([-\w]+)\]/: + when /^\s*#/; next # skip comments + when /^\s*$/; next # skip blank lines + when /\[([-\w]+)\]/ mount = newmount($1) - when /^\s*(\w+)\s+(.+)$/: + when /^\s*(\w+)\s+(.+)$/ var = $1 value = $2 raise(ArgumentError, "Fileserver configuration file does not use '=' as a separator") if value =~ /^=/ case var - when "path": + when "path" path(mount, value) - when "allow": + when "allow" allow(mount, value) - when "deny": + when "deny" deny(mount, value) else raise ArgumentError.new("Invalid argument '%s'" % var, diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 1fc2b40ab..335dad497 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -29,8 +29,8 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base } case ftype - when "file", "directory": desc << checksum - when "link": desc << @destination + when "file", "directory"; desc << checksum + when "link"; desc << @destination else raise ArgumentError, "Cannot manage files of type %s" % ftype end @@ -59,12 +59,12 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base @mode = stat.mode & 007777 case stat.ftype - when "file": + when "file" @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s - when "directory": # Always just timestamp the directory. + when "directory" # Always just timestamp the directory. @checksum_type = "ctime" @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s - when "link": + when "link" @destination = File.readlink(real_path) else raise ArgumentError, "Cannot manage files of type %s" % stat.ftype diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index e664e17c7..9df71fcac 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -39,13 +39,13 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code def self.timeout timeout = Puppet[:configtimeout] case timeout - when String: + when String if timeout =~ /^\d+$/ timeout = Integer(timeout) else raise ArgumentError, "Configuration timeout must be an integer" end - when Integer: # nothing + when Integer # nothing else raise ArgumentError, "Configuration timeout must be an integer" end diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb index 8e3773719..dc67723c4 100644 --- a/lib/puppet/network/authconfig.rb +++ b/lib/puppet/network/authconfig.rb @@ -99,9 +99,9 @@ module Puppet count = 1 f.each { |line| case line - when /^\s*#/: next # skip comments - when /^\s*$/: next # skip blank lines - when /\[([\w.]+)\]/: # "namespace" or "namespace.method" + when /^\s*#/; next # skip comments + when /^\s*$/; next # skip blank lines + when /\[([\w.]+)\]/ # "namespace" or "namespace.method" name = $1 if newrights.include?(name) raise FileServerError, "%s is already set at %s" % @@ -109,11 +109,11 @@ module Puppet end newrights.newright(name) right = newrights[name] - when /^\s*(\w+)\s+(.+)$/: + when /^\s*(\w+)\s+(.+)$/ var = $1 value = $2 case var - when "allow": + when "allow" value.split(/\s*,\s*/).each { |val| begin right.info "allowing %s access" % val @@ -123,7 +123,7 @@ module Puppet [detail.to_s, count, @config] end } - when "deny": + when "deny" value.split(/\s*,\s*/).each { |val| begin right.info "denying %s access" % val diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb index cb1fdc57d..7341f8a1e 100755 --- a/lib/puppet/network/authstore.rb +++ b/lib/puppet/network/authstore.rb @@ -174,7 +174,7 @@ module Puppet # Mapping a type of statement into a return value. def result case @type - when :allow: true + when :allow; true else false end @@ -243,16 +243,16 @@ module Puppet # statement it is. The output of this is used for later matching. def parse(value) case value - when /^(\d+\.){1,3}\*$/: # an ip address with a '*' at the end + when /^(\d+\.){1,3}\*$/ # an ip address with a '*' at the end @name = :ip match = $1 match.sub!(".", '') ary = value.split(".") mask = case ary.index(match) - when 0: 8 - when 1: 16 - when 2: 24 + when 0; 8 + when 1; 16 + when 2; 24 else raise AuthStoreError, "Invalid IP pattern %s" % value end @@ -269,10 +269,10 @@ module Puppet rescue ArgumentError => detail raise AuthStoreError, "Invalid IP address pattern %s" % value end - when /^([a-zA-Z][-\w]*\.)+[-\w]+$/: # a full hostname + when /^([a-zA-Z][-\w]*\.)+[-\w]+$/ # a full hostname @name = :domain @pattern = munge_name(value) - when /^\*(\.([a-zA-Z][-\w]*)){1,}$/: # *.domain.com + when /^\*(\.([a-zA-Z][-\w]*)){1,}$/ # *.domain.com @name = :domain @pattern = munge_name(value) @pattern.pop # take off the '*' diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index b39396091..86b0b5bb6 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -278,9 +278,9 @@ class Puppet::Network::Handler count = 1 f.each { |line| case line - when /^\s*#/: next # skip comments - when /^\s*$/: next # skip blank lines - when /\[([-\w]+)\]/: + when /^\s*#/; next # skip comments + when /^\s*$/; next # skip blank lines + when /\[([-\w]+)\]/ name = $1 if newmounts.include?(name) raise FileServerError, "%s is already mounted at %s" % @@ -288,11 +288,11 @@ class Puppet::Network::Handler end mount = Mount.new(name) newmounts[name] = mount - when /^\s*(\w+)\s+(.+)$/: + when /^\s*(\w+)\s+(.+)$/ var = $1 value = $2 case var - when "path": + when "path" if mount.name == MODULES Puppet.warning "The '#{mount.name}' module can not have a path. Ignoring attempt to set it" else @@ -304,7 +304,7 @@ class Puppet::Network::Handler newmounts.delete(mount.name) end end - when "allow": + when "allow" value.split(/\s*,\s*/).each { |val| begin mount.info "allowing %s access" % val @@ -314,7 +314,7 @@ class Puppet::Network::Handler count, @configuration.file) end } - when "deny": + when "deny" value.split(/\s*,\s*/).each { |val| begin mount.info "denying %s access" % val diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index 7bde0af73..0d36c1e88 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -65,9 +65,9 @@ class Puppet::Network::Handler catalog = Puppet::Resource::Catalog.find(client) case format - when "yaml": + when "yaml" return CGI.escape(catalog.extract.to_yaml(:UseBlock => true)) - when "marshal": + when "marshal" return CGI.escape(Marshal.dump(catalog.extract)) else raise "Invalid markup format '%s'" % format diff --git a/lib/puppet/network/handler/resource.rb b/lib/puppet/network/handler/resource.rb index e7ecbbdf2..54391c3de 100755 --- a/lib/puppet/network/handler/resource.rb +++ b/lib/puppet/network/handler/resource.rb @@ -29,7 +29,7 @@ class Puppet::Network::Handler unless local? begin case format - when "yaml": + when "yaml" bucket = YAML::load(Base64.decode64(bucket)) else raise Puppet::Error, "Unsupported format '%s'" % format @@ -99,7 +99,7 @@ class Puppet::Network::Handler unless @local case format - when "yaml": + when "yaml" trans = Base64.encode64(YAML::dump(trans)) else raise XMLRPC::FaultException.new( @@ -143,7 +143,7 @@ class Puppet::Network::Handler unless @local case format - when "yaml": + when "yaml" begin bucket = Base64.encode64(YAML::dump(bucket)) rescue => detail diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb index 3b81d38b5..844af909f 100644 --- a/lib/puppet/network/http.rb +++ b/lib/puppet/network/http.rb @@ -1,10 +1,10 @@ module Puppet::Network::HTTP def self.server_class_by_type(kind) case kind.to_sym - when :webrick: + when :webrick require 'puppet/network/http/webrick' return Puppet::Network::HTTP::WEBrick - when :mongrel: + when :mongrel raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel? require 'puppet/network/http/mongrel' return Puppet::Network::HTTP::Mongrel diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index baed325cb..6ade58b7e 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -28,15 +28,15 @@ class CollExpr < AST::Branch # case statements as doing an eval here. code = proc do |resource| case @oper - when "and": code1.call(resource) and code2.call(resource) - when "or": code1.call(resource) or code2.call(resource) - when "==": + when "and"; code1.call(resource) and code2.call(resource) + when "or"; code1.call(resource) or code2.call(resource) + when "==" if resource[str1].is_a?(Array) && form != :exported resource[str1].include?(str2) else resource[str1] == str2 end - when "!=": resource[str1] != str2 + when "!="; resource[str1] != str2 end end @@ -46,12 +46,12 @@ class CollExpr < AST::Branch end case @oper - when "and", "or": + when "and", "or" if form == :exported raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition" end oper = @oper.upcase - when "==": oper = "=" + when "=="; oper = "=" else oper = @oper end diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb index fc3797f15..2f768ebdb 100644 --- a/lib/puppet/parser/ast/function.rb +++ b/lib/puppet/parser/ast/function.rb @@ -19,12 +19,12 @@ class Puppet::Parser::AST # Now check that it's been used correctly case @ftype - when :rvalue: + when :rvalue unless Puppet::Parser::Functions.rvalue?(@name) raise Puppet::ParseError, "Function '%s' does not return a value" % @name end - when :statement: + when :statement if Puppet::Parser::Functions.rvalue?(@name) raise Puppet::ParseError, "Function '%s' must be the value of a statement" % diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index b9e49131c..0434e9b48 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -113,8 +113,8 @@ module Functions if @functions.include? name case @functions[name][:type] - when :statement: return false - when :rvalue: return true + when :statement; return false + when :rvalue; return true end else return false diff --git a/lib/puppet/parser/functions/defined.rb b/lib/puppet/parser/functions/defined.rb index 4e369ae48..b25368ccc 100644 --- a/lib/puppet/parser/functions/defined.rb +++ b/lib/puppet/parser/functions/defined.rb @@ -8,13 +8,13 @@ Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :doc => "Dete result = false vals.each do |val| case val - when String: + when String # For some reason, it doesn't want me to return from here. if Puppet::Type.type(val) or finddefine(val) or findclass(val) result = true break end - when Puppet::Parser::Resource::Reference: + when Puppet::Parser::Resource::Reference if findresource(val.to_s) result = true break diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb index e552b51fe..a37f8400d 100644 --- a/lib/puppet/parser/resource/reference.rb +++ b/lib/puppet/parser/resource/reference.rb @@ -33,7 +33,7 @@ class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference def definedtype unless defined? @definedtype case self.type - when "Class": # look for host classes + when "Class" # look for host classes if self.title == :main tmp = @scope.findclass("") else @@ -41,7 +41,7 @@ class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference fail Puppet::ParseError, "Could not find class '%s'" % self.title end end - when "Node": # look for node definitions + when "Node" # look for node definitions unless tmp = @scope.parser.nodes[self.title] fail Puppet::ParseError, "Could not find node '%s'" % self.title end diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb index f8a17ac07..3bb1a4f0c 100644 --- a/lib/puppet/property.rb +++ b/lib/puppet/property.rb @@ -165,8 +165,8 @@ class Puppet::Property < Puppet::Parameter if self.class.name == :ensure event = case self.should - when :present: (@resource.class.name.to_s + "_created").intern - when :absent: (@resource.class.name.to_s + "_removed").intern + when :present; (@resource.class.name.to_s + "_created").intern + when :absent; (@resource.class.name.to_s + "_removed").intern else (@resource.class.name.to_s + "_changed").intern end diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 2457840d1..efa8c2a3c 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -99,9 +99,9 @@ Puppet::Type.type(:augeas).provide(:augeas) do result = aug.get(path) || '' unless result.nil? case comparator - when "!=": + when "!=" return_value = true if !(result == arg) - when "=~": + when "=~" regex = Regexp.new(arg) loc = result=~ regex return_value = true if ! loc.nil? @@ -129,15 +129,15 @@ Puppet::Type.type(:augeas).provide(:augeas) do # Now do the work if (!result.nil?) case verb - when "size": + when "size" fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length != 2 comparator = cmd_array.shift() arg = cmd_array.shift().to_i return_value = true if (result.size.send(comparator, arg)) - when "include": + when "include" arg = cmd_array.join(" ") return_value = true if result.include?(arg) - when "==": + when "==" begin arg = cmd_array.join(" ") new_array = eval arg @@ -161,8 +161,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do begin data = nil case command - when "get" then return_value = process_get(cmd_array) - when "match" then return_value = process_match(cmd_array) + when "get"; return_value = process_get(cmd_array) + when "match"; return_value = process_match(cmd_array) end rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}") @@ -182,15 +182,15 @@ Puppet::Type.type(:augeas).provide(:augeas) do cmd_array.shift() begin case command - when "set": + when "set" cmd_array[0]=File.join(context, cmd_array[0]) debug("sending command '#{command}' with params #{cmd_array.inspect}") aug.set(cmd_array[0], cmd_array[1]) - when "rm", "remove": + when "rm", "remove" cmd_array[0]=File.join(context, cmd_array[0]) debug("sending command '#{command}' with params #{cmd_array.inspect}") aug.rm(cmd_array[0]) - when "clear": + when "clear" cmd_array[0]=File.join(context, cmd_array[0]) debug("sending command '#{command}' with params #{cmd_array.inspect}") aug.clear(cmd_array[0]) @@ -204,8 +204,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do where = ext_array[0] path = File.join(context, ext_array[1]) case where - when "before": before = true - when "after": before = false + when "before"; before = true + when "after"; before = false else fail("Invalid value '#{where}' for where param") end debug("sending command '#{command}' with params #{[label, where, path].inspect()}") diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index 1cfa0f5fd..d0f139cab 100755 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -1,7 +1,7 @@ require 'puppet/provider/parsedfile' tab = case Facter.value(:operatingsystem) - when "Solaris": :suntab + when "Solaris"; suntab else :crontab end @@ -141,7 +141,7 @@ Puppet::Type.type(:cron).provide(:crontab, envs = nil result = records.each { |record| case record[:record_type] - when :comment: + when :comment if record[:name] name = record[:name] record[:skip] = true @@ -149,14 +149,14 @@ Puppet::Type.type(:cron).provide(:crontab, # Start collecting env values envs = [] end - when :environment: + when :environment # If we're collecting env values (meaning we're in a named cronjob), # store the line and skip the record. if envs envs << record[:line] record[:skip] = true end - when :blank: + when :blank # nothing else if name diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb index a4812babe..dfa60cc70 100644 --- a/lib/puppet/provider/host/parsed.rb +++ b/lib/puppet/provider/host/parsed.rb @@ -2,7 +2,7 @@ require 'puppet/provider/parsedfile' hosts = nil case Facter.value(:operatingsystem) -when "Solaris": hosts = "/etc/inet/hosts" +when "Solaris"; hosts = "/etc/inet/hosts" else hosts = "/etc/hosts" end diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index 9bc1cf5a5..c660807ce 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -3,7 +3,7 @@ require 'puppet/provider/mount' fstab = nil case Facter.value(:operatingsystem) -when "Solaris": fstab = "/etc/vfstab" +when "Solaris"; fstab = "/etc/vfstab" else fstab = "/etc/fstab" end @@ -20,7 +20,7 @@ Puppet::Type.type(:mount).provide(:parsed, @platform = Facter["operatingsystem"].value case @platform - when "Solaris": + when "Solaris" @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot, :options] else diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index c1e21af08..31572cc47 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -154,8 +154,8 @@ class Puppet::Provider::NameService < Puppet::Provider group = method = nil case @resource.class.name - when :user: group = :passwd; method = :uid - when :group: group = :group; method = :gid + when :user; group = :passwd; method = :uid + when :group; group = :group; method = :gid else raise Puppet::DevError, "Invalid resource name %s" % resource end diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index 71e6ff33e..07b01bbe0 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -192,9 +192,9 @@ class DirectoryService < Puppet::Provider::NameService next unless (@@ds_to_ns_attribute_map.keys.include?(ds_attribute) and type_properties.include? @@ds_to_ns_attribute_map[ds_attribute]) ds_value = input_hash[key] case @@ds_to_ns_attribute_map[ds_attribute] - when :members: + when :members ds_value = ds_value # only members uses arrays so far - when :gid, :uid: + when :gid, :uid # OS X stores objects like uid/gid as strings. # Try casting to an integer for these cases to be # consistent with the other providers and the group type diff --git a/lib/puppet/provider/nameservice/netinfo.rb b/lib/puppet/provider/nameservice/netinfo.rb index 70491da57..8de141068 100644 --- a/lib/puppet/provider/nameservice/netinfo.rb +++ b/lib/puppet/provider/nameservice/netinfo.rb @@ -40,9 +40,9 @@ class NetInfo < Puppet::Provider::NameService def self.finish case self.name - when :uid: + when :uid noautogen - when :gid: + when :gid noautogen end end diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 133243c86..2f1aebcb3 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d end case uri.scheme - when nil: + when nil # no URI scheme => interpret the source as a local file command << source when /file/i diff --git a/lib/puppet/provider/package/sun.rb b/lib/puppet/provider/package/sun.rb index 0d366388a..d916eb78c 100755 --- a/lib/puppet/provider/package/sun.rb +++ b/lib/puppet/provider/package/sun.rb @@ -41,12 +41,12 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d # piece of information process.each { |line| case line - when /^$/: + when /^$/ hash[:provider] = :sun packages << new(hash) hash = {} - when /\s*(\w+):\s+(.+)/: + when /\s*(\w+):\s+(.+)/ name = $1 value = $2 if names.include?(name) @@ -54,7 +54,7 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d hash[names[name]] = value end end - when /\s+\d+.+/: + when /\s+\d+.+/ # nothing; we're ignoring the FILES info end } @@ -96,8 +96,8 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d # piece of information process.each { |line| case line - when /^$/: # ignore - when /\s*([A-Z]+):\s+(.+)/: + when /^$/ # ignore + when /\s*([A-Z]+):\s+(.+)/ name = $1 value = $2 if names.include?(name) @@ -105,7 +105,7 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d hash[names[name]] = value end end - when /\s+\d+.+/: + when /\s+\d+.+/ # nothing; we're ignoring the FILES info end } diff --git a/lib/puppet/provider/port/parsed.rb b/lib/puppet/provider/port/parsed.rb index 68be0aa7c..624c267b9 100755 --- a/lib/puppet/provider/port/parsed.rb +++ b/lib/puppet/provider/port/parsed.rb @@ -2,7 +2,7 @@ require 'puppet/provider/parsedfile' #services = nil #case Facter.value(:operatingsystem) -#when "Solaris": services = "/etc/inet/services" +#when "Solaris"; services = "/etc/inet/services" #else # services = "/etc/services" #end diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index cbc7afdc4..f70b12c42 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -15,9 +15,9 @@ Puppet::Type.type(:service).provide :init, :parent => :base do end case Facter["operatingsystem"].value - when "FreeBSD": + when "FreeBSD" @defpath = ["/etc/rc.d", "/usr/local/etc/rc.d"] - when "HP-UX": + when "HP-UX" @defpath = "/sbin/init.d" else @defpath = "/etc/init.d" @@ -57,8 +57,8 @@ Puppet::Type.type(:service).provide :init, :parent => :base do # Mark that our init script supports 'status' commands. def hasstatus=(value) case value - when true, "true": @parameters[:hasstatus] = true - when false, "false": @parameters[:hasstatus] = false + when true, "true"; @parameters[:hasstatus] = true + when false, "false"; @parameters[:hasstatus] = false else raise Puppet::Error, "Invalid 'hasstatus' value %s" % value.inspect diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index 4010e7457..965c9a17c 100755 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -20,7 +20,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do def enabled? case self.status - when :running: + when :running return :true else return :false @@ -62,15 +62,15 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do next end case var - when "state": + when "state" case value - when "online": + when "online" #self.warning "matched running %s" % line.inspect return :running when "offline", "disabled", "uninitialized" #self.warning "matched stopped %s" % line.inspect return :stopped - when "legacy_run": + when "legacy_run" raise Puppet::Error, "Cannot manage legacy services through SMF" else diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb index 6f7d98f56..57cfb5b67 100755 --- a/lib/puppet/provider/sshkey/parsed.rb +++ b/lib/puppet/provider/sshkey/parsed.rb @@ -2,7 +2,7 @@ require 'puppet/provider/parsedfile' known = nil case Facter.value(:operatingsystem) -when "Darwin": known = "/etc/ssh_known_hosts" +when "Darwin"; known = "/etc/ssh_known_hosts" else known = "/etc/ssh/ssh_known_hosts" end diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index 4d6bf7d29..706840822 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -71,7 +71,7 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # of the groups and add us to them. def groups=(groups) # case groups - # when Fixnum: + # when Fixnum # groups = [groups.to_s] # when String # groups = groups.split(/\s*,\s*/) diff --git a/lib/puppet/provider/user/netinfo.rb b/lib/puppet/provider/user/netinfo.rb index 067017258..22fb95056 100644 --- a/lib/puppet/provider/user/netinfo.rb +++ b/lib/puppet/provider/user/netinfo.rb @@ -66,7 +66,7 @@ Puppet::Type.type(:user).provide :netinfo, :parent => Puppet::Provider::NameServ warnonce "The NetInfo provider is deprecated; use directoryservice instead" case groups - when Fixnum: + when Fixnum groups = [groups.to_s] when String groups = groups.split(/\s*,\s*/) diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb index a5a18198c..9d6e24338 100644 --- a/lib/puppet/provider/zone/solaris.rb +++ b/lib/puppet/provider/zone/solaris.rb @@ -112,12 +112,12 @@ Puppet::Type.type(:zone).provide(:solaris) do hash = {} output.split("\n").each do |line| case line - when /^(\S+):\s*$/: + when /^(\S+):\s*$/ name = $1 current = nil # reset it - when /^(\S+):\s*(.+)$/: + when /^(\S+):\s*(.+)$/ hash[$1.intern] = $2 - when /^\s+(\S+):\s*(.+)$/: + when /^\s+(\S+):\s*(.+)$/ if name unless hash.include? name hash[name] = [] diff --git a/lib/puppet/provider/zpool/solaris.rb b/lib/puppet/provider/zpool/solaris.rb index aaa79c15f..8fc01ba81 100644 --- a/lib/puppet/provider/zpool/solaris.rb +++ b/lib/puppet/provider/zpool/solaris.rb @@ -19,9 +19,9 @@ Puppet::Type.type(:zpool).provide(:solaris) do pool_array.reverse.each do |value| sym = nil case value - when "spares": sym = :spare - when "logs": sym = :log - when "mirror", "raidz1", "raidz2": + when "spares"; sym = :spare + when "logs"; sym = :log + when "mirror", "raidz1", "raidz2" sym = value == "mirror" ? :mirror : :raidz pool[:raid_parity] = "raidz2" if value == "raidz2" else diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index a021c773a..e006f8190 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -41,9 +41,9 @@ module Puppet::Rails args = {:adapter => adapter, :log_level => Puppet[:rails_loglevel]} case adapter - when "sqlite3": + when "sqlite3" args[:dbfile] = Puppet[:dblocation] - when "mysql", "postgresql": + when "mysql", "postgresql" args[:host] = Puppet[:dbserver] unless Puppet[:dbserver].empty? args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty? args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].empty? diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index 8fd2dbadc..f9f83a0fc 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -61,9 +61,9 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider details = ".. [%s]\n" % count missing.each do |test, values| case test - when :exists: + when :exists details += " - Missing files %s\n" % values.join(", ") - when :variable: + when :variable values.each do |name, facts| if Puppet.settings.valid?(name) details += " - Setting %s (currently %s) not in list %s\n" % [name, Puppet.settings.value(name).inspect, facts.join(", ")] @@ -71,11 +71,11 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider details += " - Fact %s (currently %s) not in list %s\n" % [name, Facter.value(name).inspect, facts.join(", ")] end end - when :true: + when :true details += " - Got %s true tests that should have been false\n" % values - when :false: + when :false details += " - Got %s false tests that should have been true\n" % values - when :feature: + when :feature details += " - Missing features %s\n" % values.collect { |f| f.to_s }.join(",") end end diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index 00571a8be..963cc0c19 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -75,9 +75,9 @@ Puppet::Reports.register_report(:tagmail) do text.split("\n").each do |line| taglist = emails = nil case line.chomp - when /^\s*#/: next - when /^\s*$/: next - when /^\s*(.+)\s*:\s*(.+)\s*$/: + when /^\s*#/; next + when /^\s*$/; next + when /^\s*(.+)\s*:\s*(.+)\s*$/ taglist = $1 emails = $2.sub(/#.*$/,'') else @@ -91,8 +91,8 @@ Puppet::Reports.register_report(:tagmail) do raise ArgumentError, "Invalid tag %s" % tag.inspect end case tag - when /^\w+/: pos << tag - when /^!\w+/: neg << tag.sub("!", '') + when /^\w+/; pos << tag + when /^!\w+/; neg << tag.sub("!", '') else raise Puppet::Error, "Invalid tag '%s'" % tag end diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index b9ea0f394..cfcf13131 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -64,7 +64,7 @@ class Puppet::SimpleGraph # The other vertex in the edge. def other_vertex(direction, edge) case direction - when :in: edge.source + when :in; edge.source else edge.target end diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb index 0c579d0ad..5155b3d5b 100755 --- a/lib/puppet/sslcertificates.rb +++ b/lib/puppet/sslcertificates.rb @@ -53,13 +53,13 @@ module Puppet::SSLCertificates ex = [] case hash[:type] - when :ca: + when :ca basic_constraint = "CA:TRUE" key_usage = %w{cRLSign keyCertSign} - when :terminalsubca: + when :terminalsubca basic_constraint = "CA:TRUE,pathlen:0" key_usage = %w{cRLSign keyCertSign} - when :server: + when :server basic_constraint = "CA:FALSE" dnsnames = Puppet[:certdnsnames] name = hash[:name].to_s.sub(%r{/CN=},'') @@ -73,11 +73,11 @@ module Puppet::SSLCertificates end key_usage = %w{digitalSignature keyEncipherment} ext_key_usage = %w{serverAuth clientAuth emailProtection} - when :ocsp: + when :ocsp basic_constraint = "CA:FALSE" key_usage = %w{nonRepudiation digitalSignature} ext_key_usage = %w{serverAuth OCSPSigning} - when :client: + when :client basic_constraint = "CA:FALSE" key_usage = %w{nonRepudiation digitalSignature keyEncipherment} ext_key_usage = %w{clientAuth emailProtection} diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb index a632cbd6c..f348cdcb8 100644 --- a/lib/puppet/sslcertificates/certificate.rb +++ b/lib/puppet/sslcertificates/certificate.rb @@ -101,7 +101,7 @@ class Puppet::SSLCertificates::Certificate if hash.include?(:type) case hash[:type] - when :ca, :client, :server: @type = hash[:type] + when :ca, :client, :server; @type = hash[:type] else raise "Invalid Cert type %s" % hash[:type] end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 706ea1386..0fa1697d1 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -79,9 +79,9 @@ class Type # of times (as in, hundreds of thousands in a given run). unless @attrclasses.include?(name) @attrclasses[name] = case self.attrtype(name) - when :property: @validproperties[name] - when :meta: @@metaparamhash[name] - when :param: @paramhash[name] + when :property; @validproperties[name] + when :meta; @@metaparamhash[name] + when :param; @paramhash[name] end end @attrclasses[name] @@ -93,9 +93,9 @@ class Type @attrtypes ||= {} unless @attrtypes.include?(attr) @attrtypes[attr] = case - when @validproperties.include?(attr): :property - when @paramhash.include?(attr): :param - when @@metaparamhash.include?(attr): :meta + when @validproperties.include?(attr); :property + when @paramhash.include?(attr); :param + when @@metaparamhash.include?(attr); :meta end end @@ -1085,8 +1085,8 @@ class Type newvalues(:true, :false) munge do |value| case value - when true, :true, "true": @resource.noop = true - when false, :false, "false": @resource.noop = false + when true, :true, "true"; @resource.noop = true + when false, :false, "false"; @resource.noop = false end end end @@ -1776,8 +1776,8 @@ class Type @tags = list.collect do |t| case t - when String: t.intern - when Symbol: t + when String; t.intern + when Symbol; t else self.warning "Ignoring tag %s of type %s" % [tag.inspect, tag.class] end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index b6ad4fe93..d96b5dd91 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -82,13 +82,13 @@ module Puppet value = value.shift if value.is_a?(Array) case value - when false, "false", :false: + when false, "false", :false false - when true, "true", ".puppet-bak", :true: + when true, "true", ".puppet-bak", :true ".puppet-bak" when /^\./ value - when String: + when String # We can't depend on looking this up right now, # we have to do it after all of the objects # have been instantiated. @@ -101,7 +101,7 @@ module Puppet @resource.bucket = value value end - when Puppet::Network::Client.client(:Dipper): + when Puppet::Network::Client.client(:Dipper) @resource.bucket = value value.name else @@ -123,10 +123,10 @@ module Puppet munge do |value| newval = super(value) case newval - when :true, :inf: true - when :false: false - when Integer, Fixnum, Bignum: value - when /^\d+$/: Integer(value) + when :true, :inf; true + when :false; false + when Integer, Fixnum, Bignum; value + when /^\d+$/; Integer(value) else raise ArgumentError, "Invalid recurse value %s" % value.inspect end @@ -309,7 +309,7 @@ module Puppet # Look up our bucket, if there is one if bucket = self.bucket case bucket - when String: + when String if catalog and obj = catalog.resource(:filebucket, bucket) self.bucket = obj.bucket elsif bucket == "puppet" @@ -320,7 +320,7 @@ module Puppet else self.fail "Could not find filebucket '%s'" % bucket end - when Puppet::Network::Client.client(:Dipper): # things are hunky-dorey + when Puppet::Network::Client.client(:Dipper) # things are hunky-dorey when Puppet::Type::Filebucket # things are hunky-dorey self.bucket = bucket.bucket else @@ -366,14 +366,14 @@ module Puppet end case File.stat(file).ftype - when "directory": + when "directory" if self[:recurse] # we don't need to backup directories when recurse is on return true else backup = self.bucket || self[:backup] case backup - when Puppet::Network::Client.client(:Dipper): + when Puppet::Network::Client.client(:Dipper) notice "Recursively backing up to filebucket" require 'find' Find.find(self[:path]) do |f| @@ -385,7 +385,7 @@ module Puppet end return true - when String: + when String newfile = file + backup # Just move it, since it's a directory. if FileTest.exists?(newfile) @@ -409,15 +409,15 @@ module Puppet return false end end - when "file": + when "file" backup = self.bucket || self[:backup] case backup - when Puppet::Network::Client.client(:Dipper): + when Puppet::Network::Client.client(:Dipper) sum = backup.backup(file) self.notice "Filebucketed to %s with sum %s" % [backup.name, sum] return true - when String: + when String newfile = file + backup if FileTest.exists?(newfile) remove_backup(newfile) @@ -441,7 +441,7 @@ module Puppet self.err "Invalid backup type %s" % backup.inspect return false end - when "link": return true + when "link"; return true else self.notice "Cannot backup files of type %s" % File.stat(file).ftype return false @@ -667,14 +667,14 @@ module Puppet end case s.ftype - when "directory": + when "directory" if self[:force] == :true debug "Removing existing directory for replacement with %s" % should FileUtils.rmtree(self[:path]) else notice "Not removing directory; use 'force' to override" end - when "link", "file": + when "link", "file" debug "Removing existing %s for replacement with %s" % [s.ftype, should] File.unlink(self[:path]) diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 53365bf40..763841fd8 100755 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -34,7 +34,7 @@ module Puppet case is when String is = is.split(/\s*,\s*/) - when Symbol: + when Symbol is = [is] when Array # nothing diff --git a/lib/puppet/type/macauthorization.rb b/lib/puppet/type/macauthorization.rb index 0265242dc..800d58d1c 100644 --- a/lib/puppet/type/macauthorization.rb +++ b/lib/puppet/type/macauthorization.rb @@ -12,7 +12,7 @@ Puppet::Type.newtype(:macauthorization) do def munge_boolean(value) case value - when true, "true", :true: + when true, "true", :true :true when false, "false", :false :false diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 4eb149488..bb488c275 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -188,7 +188,7 @@ module Puppet newvalues(:true, :false) defaultto do case Facter.value(:operatingsystem) - when "FreeBSD": false + when "FreeBSD"; false else true end diff --git a/lib/puppet/type/notify.rb b/lib/puppet/type/notify.rb index 548cf760c..15911d441 100644 --- a/lib/puppet/type/notify.rb +++ b/lib/puppet/type/notify.rb @@ -10,7 +10,7 @@ module Puppet desc "The message to be sent to the log." def sync case @resource["withpath"] - when :true: + when :true send(@resource[:loglevel], self.should) else Puppet.send(@resource[:loglevel], self.should) diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 9ed1bf1c8..655f9e06d 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -131,9 +131,9 @@ module Puppet end case is - when @latest: + when @latest return true - when :present: + when :present # This will only happen on retarded packaging systems # that can't query versions. return true diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index c0d892bb8..d316b4b13 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -56,7 +56,7 @@ Puppet::Type.newtype(:resources) do 500 when :false, false false - when Integer: value + when Integer; value else raise ArgumentError, "Invalid value %s" % value.inspect end diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 98d69bc3a..eebf333cd 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -99,10 +99,10 @@ Puppet::Type.newtype(:tidy) do munge do |age| unit = multi = nil case age - when /^([0-9]+)(\w)\w*$/: + when /^([0-9]+)(\w)\w*$/ multi = Integer($1) unit = $2.downcase.intern - when /^([0-9]+)$/: + when /^([0-9]+)$/ multi = Integer($1) unit = :d else @@ -147,10 +147,10 @@ Puppet::Type.newtype(:tidy) do munge do |size| case size - when /^([0-9]+)(\w)\w*$/: + when /^([0-9]+)(\w)\w*$/ multi = Integer($1) unit = $2.downcase.intern - when /^([0-9]+)$/: + when /^([0-9]+)$/ multi = Integer($1) unit = :k else @@ -181,10 +181,10 @@ Puppet::Type.newtype(:tidy) do munge do |value| newval = super(value) case newval - when :true, :inf: true - when :false: false - when Integer, Fixnum, Bignum: value - when /^\d+$/: Integer(value) + when :true, :inf; true + when :false; false + when Integer, Fixnum, Bignum; value + when /^\d+$/; Integer(value) else raise ArgumentError, "Invalid recurse value %s" % value.inspect end diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index 8efc2ef1c..bc7c243a1 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -228,7 +228,7 @@ module Puppet } groups.each { |group| case group - when Integer: + when Integer if resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) and r.should(:gid) == group } autos << resource end diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index 6e5d784b3..c286ececd 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -400,7 +400,7 @@ end hash.each do |param, value| next if param == :name case self.class.attrtype(param) - when :property: + when :property # Only try to provide values for the properties we're managing if prop = self.property(param) prophash[prop] = value diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 23d02ea60..dca0d51c0 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -332,7 +332,7 @@ module Puppet::Util::FileParsing end case record.type - when :text: return details[:line] + when :text; return details[:line] else if record.respond_to?(:to_line) return record.to_line(details) diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index 70fe303c5..19c53a2e6 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -62,9 +62,9 @@ class Puppet::Util::Ldap::Connection def start begin case ssl - when :tls: + when :tls @connection = LDAP::SSLConn.new(host, port, true) - when true: + when true @connection = LDAP::SSLConn.new(host, port) else @connection = LDAP::Conn.new(host, port) diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index a74432021..db6177be2 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -282,9 +282,9 @@ class Puppet::Util::Log def colorize(level, str) case Puppet[:color] - when false: str - when true, :ansi, "ansi": console_color(level, str) - when :html, "html": html_color(level, str) + when false; str + when true, :ansi, "ansi"; console_color(level, str) + when :html, "html"; html_color(level, str) end end diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 3f6c1f6e3..40a175eb3 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -52,8 +52,8 @@ module Puppet::Util::POSIX # Apparently the group/passwd methods need to get reset; if we skip # this call, then new users aren't found. case type - when :passwd: Etc.send(:endpwent) - when :group: Etc.send(:endgrent) + when :passwd; Etc.send(:endpwent) + when :group; Etc.send(:endgrent) end return nil end @@ -61,8 +61,8 @@ module Puppet::Util::POSIX # Determine what the field name is for users and groups. def idfield(space) case Puppet::Util.symbolize(space) - when :gr, :group: return :gid - when :pw, :user, :passwd: return :uid + when :gr, :group; return :gid + when :pw, :user, :passwd; return :uid else raise ArgumentError.new("Can only handle users and groups") end @@ -71,8 +71,8 @@ module Puppet::Util::POSIX # Determine what the method is to get users and groups by id def methodbyid(space) case Puppet::Util.symbolize(space) - when :gr, :group: return :getgrgid - when :pw, :user, :passwd: return :getpwuid + when :gr, :group; return :getgrgid + when :pw, :user, :passwd; return :getpwuid else raise ArgumentError.new("Can only handle users and groups") end @@ -81,8 +81,8 @@ module Puppet::Util::POSIX # Determine what the method is to get users and groups by name def methodbyname(space) case Puppet::Util.symbolize(space) - when :gr, :group: return :getgrnam - when :pw, :user, :passwd: return :getpwnam + when :gr, :group; return :getgrnam + when :pw, :user, :passwd; return :getpwnam else raise ArgumentError.new("Can only handle users and groups") end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 3ef75a845..c60f1713b 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -407,11 +407,11 @@ class Puppet::Util::Settings hash.delete(:type) else case hash[:default] - when true, false, "true", "false": + when true, false, "true", "false" klass = CBoolean - when /^\$\w+\//, /^\//: + when /^\$\w+\//, /^\// klass = CFile - when String, Integer, Float: # nothing + when String, Integer, Float # nothing klass = CElement else raise Puppet::Error, "Invalid value '%s' for %s" % [value.inspect, hash[:name]] @@ -829,9 +829,9 @@ Generated on #{Time.now}. def munge_value(value) # Handle different data types correctly return case value - when /^false$/i: false - when /^true$/i: true - when /^\d+$/i: Integer(value) + when /^false$/i; false + when /^true$/i; true + when /^\d+$/i; Integer(value) else value.gsub(/^["']|["']$/,'').sub(/\s+$/, '') end @@ -856,13 +856,13 @@ Generated on #{Time.now}. text.split(/\n/).each { |line| count += 1 case line - when /^\s*\[(\w+)\]$/: + when /^\s*\[(\w+)\]$/ section = $1.intern # Section names # Add a meta section result[section][:_meta] ||= {} - when /^\s*#/: next # Skip comments - when /^\s*$/: next # Skip blanks - when /^\s*(\w+)\s*=\s*(.*)$/: # settings + when /^\s*#/; next # Skip comments + when /^\s*$/; next # Skip blanks + when /^\s*(\w+)\s*=\s*(.*)$/ # settings var = $1.intern # We don't want to munge modes, because they're specified in octal, so we'll @@ -1150,8 +1150,8 @@ Generated on #{Time.now}. def munge(value) case value - when true, "true": return true - when false, "false": return false + when true, "true"; return true + when false, "false"; return false else raise ArgumentError, "Invalid value '%s' for %s" % [value.inspect, @name] diff --git a/spec/integration/indirector/direct_file_server.rb b/spec/integration/indirector/direct_file_server.rb index 7280cda98..9843c7e65 100755 --- a/spec/integration/indirector/direct_file_server.rb +++ b/spec/integration/indirector/direct_file_server.rb @@ -62,9 +62,9 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi it "should return instances capable of returning their content" do @terminus.search(@request).each do |instance| case instance.full_path - when /one/: instance.content.should == "one content" - when /two/: instance.content.should == "two content" - when @path: + when /one/; instance.content.should == "one content" + when /two/; instance.content.should == "two content" + when @path else raise "No valid key for %s" % instance.path.inspect end diff --git a/spec/unit/provider/mount/parsed.rb b/spec/unit/provider/mount/parsed.rb index 8a7b52531..d2c992f33 100755 --- a/spec/unit/provider/mount/parsed.rb +++ b/spec/unit/provider/mount/parsed.rb @@ -102,7 +102,7 @@ describe provider_class do # LAK:FIXME I can't mock Facter because this test happens at parse-time. it "should default to /etc/vfstab on Solaris and /etc/fstab everywhere else" do should = case Facter.value(:operatingsystem) - when "Solaris": "/etc/vfstab" + when "Solaris"; "/etc/vfstab" else "/etc/fstab" end diff --git a/spec/unit/type/file/selinux.rb b/spec/unit/type/file/selinux.rb index bf3315bf9..be58e636a 100644 --- a/spec/unit/type/file/selinux.rb +++ b/spec/unit/type/file/selinux.rb @@ -29,10 +29,10 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f @resource.expects(:stat).returns stat @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t:s0" expectedresult = case param - when :seluser then "user_u" - when :selrole then "role_r" - when :seltype then "type_t" - when :selrange then "s0" + when :seluser; "user_u" + when :selrole; "role_r" + when :seltype; "type_t" + when :selrange; "s0" end @sel.retrieve.should == expectedresult end @@ -42,10 +42,10 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f @resource.expects(:stat).returns stat @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t" expectedresult = case param - when :seluser then "user_u" - when :selrole then "role_r" - when :seltype then "type_t" - when :selrange then nil + when :seluser; "user_u" + when :selrole; "role_r" + when :seltype; "type_t" + when :selrange; nil end @sel.retrieve.should == expectedresult end @@ -59,10 +59,10 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f @sel.stubs(:debug) @sel.expects(:get_selinux_default_context).with("/my/file").returns "user_u:role_r:type_t:s0" expectedresult = case param - when :seluser then "user_u" - when :selrole then "role_r" - when :seltype then "type_t" - when :selrange then "s0" + when :seluser; "user_u" + when :selrole; "role_r" + when :seltype; "type_t" + when :selrange; "s0" end @sel.default.must == expectedresult end diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 42295785e..3c6083fa6 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -255,8 +255,8 @@ module PuppetTest def tmpdir unless defined? @tmpdir and @tmpdir @tmpdir = case Facter["operatingsystem"].value - when "Darwin": "/private/tmp" - when "SunOS": "/var/tmp" + when "Darwin"; "/private/tmp" + when "SunOS"; "/var/tmp" else "/tmp" end diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index adc3b09ff..f23c6483b 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -72,7 +72,7 @@ module PuppetTest::Support::Utils def run_events(type, trans, events, msg) case type - when :evaluate, :rollback: # things are hunky-dory + when :evaluate, :rollback # things are hunky-dory else raise Puppet::DevError, "Incorrect run_events type" end diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb index 9bd26ac07..5158f51ca 100755 --- a/test/network/handler/fileserver.rb +++ b/test/network/handler/fileserver.rb @@ -544,13 +544,13 @@ class TestFileServer < Test::Unit::TestCase host, ip = sub case type - when :deny: + when :deny assert_raise(Puppet::AuthorizationError, "Host %s, ip %s, allowed %s" % [host, ip, mount]) { list = server.list(mount, :manage, true, false, host, ip) } - when :allow: + when :allow assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) { list = server.list(mount, :manage, true, false, host, ip) diff --git a/test/rails/host.rb b/test/rails/host.rb index 79f0ae398..a7b17c3ae 100755 --- a/test/rails/host.rb +++ b/test/rails/host.rb @@ -88,10 +88,10 @@ class TestRailsHost < PuppetTest::TestCase end assert(resource[:restype] != "", "Did not get a type from the resource") case resource["restype"] - when "File": + when "File" assert_equal("user#{i}", resource.parameter("owner"), "got no owner for %s" % resource.ref) - when "Exec": + when "Exec" assert_equal("user#{i}", resource.parameter("user"), "got no user for %s" % resource.ref) else diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 05f8bc97f..ab5ba85d1 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -172,7 +172,7 @@ class TestTypeAttributes < Test::Unit::TestCase end case old - when :one: # param + when :one # param assert_equal(val, inst[new], "Incorrect alias value for %s in []" % new) else @@ -209,13 +209,13 @@ class TestTypeAttributes < Test::Unit::TestCase resource = type.new(:provider => prov.name, :name => "test%s" % i, :none => "a", :one => "b", :two => "c") case prov.name - when :nope: + when :nope yes = [:none] no = [:one, :two] - when :maybe: + when :maybe yes = [:none, :one] no = [:two] - when :yep: + when :yep yes = [:none, :one, :two] no = [] end diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index 044545be1..e4ee82a74 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -47,7 +47,7 @@ class TestGroupProvider < Test::Unit::TestCase end case Facter["operatingsystem"].value - when "Darwin": + when "Darwin" def missing?(group) output = %x{nidump -r /groups/#{group} / 2>/dev/null}.chomp diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb index 3b61c1abd..486078ed7 100755 --- a/test/ral/providers/package.rb +++ b/test/ral/providers/package.rb @@ -240,7 +240,7 @@ class TestPackageProvider < Test::Unit::TestCase def modpkg(pkg) case pkg[:provider] - when :sun: + when :sun pkg[:adminfile] = "/usr/local/pkg/admin_file" end end diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb index 25f1d605f..4df67807f 100755 --- a/test/ral/providers/provider.rb +++ b/test/ral/providers/provider.rb @@ -506,13 +506,13 @@ class TestProviderFeatures < Test::Unit::TestCase [nope, maybe, yep].each do |prov| assert(prov.respond_to?(:supports_parameter?), "%s does not respond to :supports_parameter?" % prov.name) case prov.name - when :nope: + when :nope supported = [:neither] un = [:some, :both] - when :maybe: + when :maybe supported = [:neither, :some] un = [:both] - when :yep: + when :yep supported = [:neither, :some, :both] un = [] end diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb index 1cb139b7d..3f68469c1 100755 --- a/test/ral/providers/user.rb +++ b/test/ral/providers/user.rb @@ -32,7 +32,7 @@ class TestUserProvider < Test::Unit::TestCase end case Facter["operatingsystem"].value - when "Darwin": + when "Darwin" def missing?(user) output = %x{nidump -r /users/#{user} / 2>/dev/null}.chomp @@ -119,12 +119,12 @@ class TestUserProvider < Test::Unit::TestCase def fakedata(name, param) case param - when :name: name - when :ensure: :present - when :comment: "Puppet's Testing User %s" % name # use a single quote a la #375 - when :gid: nonrootgroup.gid - when :shell: findshell() - when :home: "/home/%s" % name + when :name; name + when :ensure; :present + when :comment; "Puppet's Testing User %s" % name # use a single quote a la #375 + when :gid; nonrootgroup.gid + when :shell; findshell() + when :home; "/home/%s" % name else return nil end diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb index 6eceb273d..20ed773d6 100755 --- a/test/ral/type/cron.rb +++ b/test/ral/type/cron.rb @@ -194,7 +194,7 @@ class TestCron < Test::Unit::TestCase [:valid, :invalid].each { |type| hash[type].each { |value| case type - when :valid: + when :valid assert_nothing_raised { cron[param] = value } @@ -203,7 +203,7 @@ class TestCron < Test::Unit::TestCase assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly") end - when :invalid: + when :invalid assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % [value, param]) { cron[param] = value diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb index 1a7813b74..08fdab821 100755 --- a/test/ral/type/file.rb +++ b/test/ral/type/file.rb @@ -1108,9 +1108,9 @@ class TestFile < Test::Unit::TestCase # Now change something so that we replace the file case attr - when :source: + when :source File.open(source, "w") { |f| f.puts "some different text" } - when :content: file[:content] = "something completely different" + when :content; file[:content] = "something completely different" else raise "invalid attr %s" % attr end @@ -184,8 +184,8 @@ def run(files, flags = nil) files.each do |file| case File.stat(file).ftype - when "file": args << file - when "directory": args += ruby_files(file) + when "file"; args << file + when "directory"; args += ruby_files(file) else $stderr.puts "Skipping %s; can't handle %s" % [file, File.stat(file).ftype] diff --git a/test/util/settings.rb b/test/util/settings.rb index f34cbbc46..2ff9e66ec 100755 --- a/test/util/settings.rb +++ b/test/util/settings.rb @@ -379,7 +379,7 @@ yay = /a/path assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal") case Facter["operatingsystem"].value - when /BSD/, "Darwin": # nothing + when /BSD/, "Darwin" # nothing else assert_equal(group.gid, File.stat(path).gid, "GIDS are not equal") end @@ -418,7 +418,7 @@ yay = /a/path assert_equal(user.uid, File.stat(path).uid, "UIDS are not equal") case Facter["operatingsystem"].value - when /BSD/, "Darwin": # nothing + when /BSD/, "Darwin" # nothing else assert_equal(group.gid, File.stat(path).gid, "GIDS are not equal") end |
