when.patch

Patch to change `:' to '`;' in case' statements - Jos Backus, 01/05/2009 05:04 am

Download (75.7 kB)

b/bin/filebucket
185 185

  
186 186
mode = ARGV.shift
187 187
case mode
188
when "get":
188
when "get"
189 189
    md5 = ARGV.shift
190 190
    out = client.getfile(md5)
191 191
    print out
192
when "backup":
192
when "backup"
193 193
    ARGV.each do |file|
194 194
        unless FileTest.exists?(file)
195 195
            $stderr.puts "%s: no such file" % file
......
202 202
        md5 = client.backup(file)
203 203
        puts "%s: %s" % [file, md5]
204 204
    end
205
when "restore":
205
when "restore"
206 206
    file = ARGV.shift
207 207
    md5 = ARGV.shift
208 208
    client.restore(file, md5)
b/bin/puppetrun
323 323
            end
324 324
            
325 325
            case result
326
            when "success": exit(0)
327
            when "running":
326
            when "success"; exit(0)
327
            when "running"
328 328
                $stderr.puts "Host %s is already running" % host
329 329
                exit(3)
330 330
            else
b/ext/puppetstoredconfigclean.rb
57 57
args = {:adapter => adapter, :log_level => pm_conf[:rails_loglevel]}
58 58

  
59 59
case adapter
60
  when "sqlite3":
60
  when "sqlite3"
61 61
    args[:dbfile] = pm_conf[:dblocation]
62
  when "mysql", "postgresql":
62
  when "mysql", "postgresql"
63 63
    args[:host]     = pm_conf[:dbserver] unless pm_conf[:dbserver].to_s.empty?
64 64
    args[:username] = pm_conf[:dbuser] unless pm_conf[:dbuser].to_s.empty?
65 65
    args[:password] = pm_conf[:dbpassword] unless pm_conf[:dbpassword].to_s.empty?
b/lib/puppet.rb
82 82
	# configuration parameter access and stuff
83 83
	def self.[](param)
84 84
        case param
85
        when :debug:
85
        when :debug
86 86
            if Puppet::Util::Log.level == :debug
87 87
                return true
88 88
            else
b/lib/puppet/file_serving/configuration/parser.rb
20 20
                @count += 1
21 21

  
22 22
                case line
23
                when /^\s*#/: next # skip comments
24
                when /^\s*$/: next # skip blank lines
25
                when /\[([-\w]+)\]/:
23
                when /^\s*#/; next # skip comments
24
                when /^\s*$/; next # skip blank lines
25
                when /\[([-\w]+)\]/
26 26
                    mount = newmount($1)
27
                when /^\s*(\w+)\s+(.+)$/:
27
                when /^\s*(\w+)\s+(.+)$/
28 28
                    var = $1
29 29
                    value = $2
30 30
                    raise(ArgumentError, "Fileserver configuration file does not use '=' as a separator") if value =~ /^=/
31 31
                    case var
32
                    when "path":
32
                    when "path"
33 33
                        path(mount, value)
34
                    when "allow":
34
                    when "allow"
35 35
                        allow(mount, value)
36
                    when "deny":
36
                    when "deny"
37 37
                        deny(mount, value)
38 38
                    else
39 39
                        raise ArgumentError.new("Invalid argument '%s'" % var,
b/lib/puppet/file_serving/metadata.rb
29 29
        }
30 30

  
31 31
        case ftype
32
        when "file", "directory": desc << checksum
33
        when "link": desc << @destination
32
        when "file", "directory"; desc << checksum
33
        when "link"; desc << @destination
34 34
        else
35 35
            raise ArgumentError, "Cannot manage files of type %s" % ftype
36 36
        end
......
59 59
        @mode = stat.mode & 007777
60 60

  
61 61
        case stat.ftype
62
        when "file":
62
        when "file"
63 63
            @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s
64
        when "directory": # Always just timestamp the directory.
64
        when "directory" # Always just timestamp the directory.
65 65
            @checksum_type = "ctime"
66 66
            @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s
67
        when "link":
67
        when "link"
68 68
            @destination = File.readlink(real_path)
69 69
        else
70 70
            raise ArgumentError, "Cannot manage files of type %s" % stat.ftype
b/lib/puppet/indirector/facts/facter.rb
33 33
    def self.timeout
34 34
        timeout = Puppet[:configtimeout]
35 35
        case timeout
36
        when String:
36
        when String
37 37
            if timeout =~ /^\d+$/
38 38
                timeout = Integer(timeout)
39 39
            else
40 40
                raise ArgumentError, "Configuration timeout must be an integer"
41 41
            end
42
        when Integer: # nothing
42
        when Integer # nothing
43 43
        else
44 44
            raise ArgumentError, "Configuration timeout must be an integer"
45 45
        end
b/lib/puppet/network/authconfig.rb
99 99
                    count = 1
100 100
                    f.each { |line|
101 101
                        case line
102
                        when /^\s*#/: next # skip comments
103
                        when /^\s*$/: next # skip blank lines
104
                        when /\[([\w.]+)\]/: # "namespace" or "namespace.method"
102
                        when /^\s*#/; next # skip comments
103
                        when /^\s*$/; next # skip blank lines
104
                        when /\[([\w.]+)\]/ # "namespace" or "namespace.method"
105 105
                            name = $1
106 106
                            if newrights.include?(name)
107 107
                                raise FileServerError, "%s is already set at %s" %
......
109 109
                            end
110 110
                            newrights.newright(name)
111 111
                            right = newrights[name]
112
                        when /^\s*(\w+)\s+(.+)$/:
112
                        when /^\s*(\w+)\s+(.+)$/
113 113
                            var = $1
114 114
                            value = $2
115 115
                            case var
116
                            when "allow":
116
                            when "allow"
117 117
                                value.split(/\s*,\s*/).each { |val|
118 118
                                    begin
119 119
                                        right.info "allowing %s access" % val
......
123 123
                                            [detail.to_s, count, @config]
124 124
                                    end
125 125
                                }
126
                            when "deny":
126
                            when "deny"
127 127
                                value.split(/\s*,\s*/).each { |val|
128 128
                                    begin
129 129
                                        right.info "denying %s access" % val
b/lib/puppet/network/authstore.rb
174 174
            # Mapping a type of statement into a return value.
175 175
            def result
176 176
                case @type
177
                when :allow: true
177
                when :allow; true
178 178
                else
179 179
                    false
180 180
                end
......
243 243
            # statement it is.  The output of this is used for later matching.
244 244
            def parse(value)
245 245
                case value
246
                when /^(\d+\.){1,3}\*$/: # an ip address with a '*' at the end
246
                when /^(\d+\.){1,3}\*$/ # an ip address with a '*' at the end
247 247
                    @name = :ip
248 248
                    match = $1
249 249
                    match.sub!(".", '')
250 250
                    ary = value.split(".")
251 251

  
252 252
                    mask = case ary.index(match)
253
                    when 0: 8
254
                    when 1: 16
255
                    when 2: 24
253
                    when 0; 8
254
                    when 1; 16
255
                    when 2; 24
256 256
                    else
257 257
                        raise AuthStoreError, "Invalid IP pattern %s" % value
258 258
                    end
......
269 269
                    rescue ArgumentError => detail
270 270
                        raise AuthStoreError, "Invalid IP address pattern %s" % value
271 271
                    end
272
                when /^([a-zA-Z][-\w]*\.)+[-\w]+$/: # a full hostname
272
                when /^([a-zA-Z][-\w]*\.)+[-\w]+$/ # a full hostname
273 273
                    @name = :domain
274 274
                    @pattern = munge_name(value)
275
                when /^\*(\.([a-zA-Z][-\w]*)){1,}$/: # *.domain.com
275
                when /^\*(\.([a-zA-Z][-\w]*)){1,}$/ # *.domain.com
276 276
                    @name = :domain
277 277
                    @pattern = munge_name(value)
278 278
                    @pattern.pop # take off the '*'
b/lib/puppet/network/client/master.rb
149 149

  
150 150
        begin
151 151
            case Puppet[:catalog_format]
152
            when "marshal": objects = Marshal.load(marshalled_objects)
153
            when "yaml": objects = YAML.load(marshalled_objects)
152
            when "marshal"; objects = Marshal.load(marshalled_objects)
153
            when "yaml"; objects = YAML.load(marshalled_objects)
154 154
            else
155 155
                raise "Invalid catalog format '%s'" % Puppet[:catalog_format]
156 156
            end
......
410 410
    def self.timeout
411 411
        timeout = Puppet[:configtimeout]
412 412
        case timeout
413
        when String:
413
        when String
414 414
            if timeout =~ /^\d+$/
415 415
                timeout = Integer(timeout)
416 416
            else
417 417
                raise ArgumentError, "Configuration timeout must be an integer"
418 418
            end
419
        when Integer: # nothing
419
        when Integer # nothing
420 420
        else
421 421
            raise ArgumentError, "Configuration timeout must be an integer"
422 422
        end
b/lib/puppet/network/handler/fileserver.rb
279 279
                    count = 1
280 280
                    f.each { |line|
281 281
                        case line
282
                        when /^\s*#/: next # skip comments
283
                        when /^\s*$/: next # skip blank lines
284
                        when /\[([-\w]+)\]/:
282
                        when /^\s*#/; next # skip comments
283
                        when /^\s*$/; next # skip blank lines
284
                        when /\[([-\w]+)\]/
285 285
                            name = $1
286 286
                            if newmounts.include?(name)
287 287
                                raise FileServerError, "%s is already mounted at %s" %
......
289 289
                            end
290 290
                            mount = Mount.new(name)
291 291
                            newmounts[name] = mount
292
                        when /^\s*(\w+)\s+(.+)$/:
292
                        when /^\s*(\w+)\s+(.+)$/
293 293
                            var = $1
294 294
                            value = $2
295 295
                            case var
296
                            when "path":
296
                            when "path"
297 297
                                if mount.name == MODULES
298 298
                                    Puppet.warning "The '#{mount.name}' module can not have a path. Ignoring attempt to set it"
299 299
                                else
......
305 305
                                        newmounts.delete(mount.name)
306 306
                                    end
307 307
                                end
308
                            when "allow":
308
                            when "allow"
309 309
                                value.split(/\s*,\s*/).each { |val|
310 310
                                    begin
311 311
                                        mount.info "allowing %s access" % val
......
315 315
                                            count, @configuration.file)
316 316
                                    end
317 317
                                }
318
                            when "deny":
318
                            when "deny"
319 319
                                value.split(/\s*,\s*/).each { |val|
320 320
                                    begin
321 321
                                        mount.info "denying %s access" % val
b/lib/puppet/network/handler/master.rb
65 65
            catalog = Puppet::Resource::Catalog.find(client)
66 66

  
67 67
            case format
68
            when "yaml":
68
            when "yaml"
69 69
                return CGI.escape(catalog.extract.to_yaml(:UseBlock => true))
70
            when "marshal":
70
            when "marshal"
71 71
                return CGI.escape(Marshal.dump(catalog.extract))
72 72
            else
73 73
                raise "Invalid markup format '%s'" % format
b/lib/puppet/network/handler/resource.rb
29 29
            unless local?
30 30
                begin
31 31
                    case format
32
                    when "yaml":
32
                    when "yaml"
33 33
                        bucket = YAML::load(Base64.decode64(bucket))
34 34
                    else
35 35
                        raise Puppet::Error, "Unsupported format '%s'" % format
......
99 99

  
100 100
            unless @local
101 101
                case format
102
                when "yaml":
102
                when "yaml"
103 103
                    trans = Base64.encode64(YAML::dump(trans))
104 104
                else
105 105
                    raise XMLRPC::FaultException.new(
......
143 143

  
144 144
            unless @local
145 145
                case format
146
                when "yaml":
146
                when "yaml"
147 147
                    begin
148 148
                    bucket = Base64.encode64(YAML::dump(bucket))
149 149
                    rescue => detail
b/lib/puppet/network/http.rb
1 1
module Puppet::Network::HTTP
2 2
    def self.server_class_by_type(kind)
3 3
        case kind.to_sym
4
        when :webrick:
4
        when :webrick
5 5
            require 'puppet/network/http/webrick'
6 6
            return Puppet::Network::HTTP::WEBrick
7
        when :mongrel:
7
        when :mongrel
8 8
            raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel?
9 9
            require 'puppet/network/http/mongrel'
10 10
            return Puppet::Network::HTTP::Mongrel 
b/lib/puppet/parser/ast/collexpr.rb
28 28
        # case statements as doing an eval here.
29 29
        code = proc do |resource|
30 30
            case @oper
31
            when "and": code1.call(resource) and code2.call(resource)
32
            when "or": code1.call(resource) or code2.call(resource)
33
            when "==":
31
            when "and"; code1.call(resource) and code2.call(resource)
32
            when "or"; code1.call(resource) or code2.call(resource)
33
            when "=="
34 34
                if resource[str1].is_a?(Array) && form != :exported
35 35
                    resource[str1].include?(str2)
36 36
                else
37 37
                    resource[str1] == str2
38 38
                end
39
            when "!=": resource[str1] != str2
39
            when "!="; resource[str1] != str2
40 40
            end
41 41
        end
42 42

  
......
46 46
        end
47 47

  
48 48
        case @oper
49
        when "and", "or":
49
        when "and", "or"
50 50
            if form == :exported
51 51
                raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition"
52 52
            end
53 53
            oper = @oper.upcase
54
        when "==": oper = "="
54
        when "=="; oper = "="
55 55
        else
56 56
            oper = @oper
57 57
        end
b/lib/puppet/parser/ast/function.rb
19 19

  
20 20
            # Now check that it's been used correctly
21 21
            case @ftype
22
            when :rvalue:
22
            when :rvalue
23 23
                unless Puppet::Parser::Functions.rvalue?(@name)
24 24
                    raise Puppet::ParseError, "Function '%s' does not return a value" %
25 25
                        @name
26 26
                end
27
            when :statement:
27
            when :statement
28 28
                if Puppet::Parser::Functions.rvalue?(@name)
29 29
                    raise Puppet::ParseError,
30 30
                        "Function '%s' must be the value of a statement" %
b/lib/puppet/parser/functions.rb
113 113

  
114 114
        if @functions.include? name
115 115
            case @functions[name][:type]
116
            when :statement: return false
117
            when :rvalue: return true
116
            when :statement; return false
117
            when :rvalue; return true
118 118
            end
119 119
        else
120 120
            return false
b/lib/puppet/parser/functions/defined.rb
8 8
        result = false
9 9
        vals.each do |val|
10 10
            case val
11
            when String:
11
            when String
12 12
                # For some reason, it doesn't want me to return from here.
13 13
                if Puppet::Type.type(val) or finddefine(val) or findclass(val)
14 14
                    result = true
15 15
                    break
16 16
                end
17
            when Puppet::Parser::Resource::Reference:
17
            when Puppet::Parser::Resource::Reference
18 18
                if findresource(val.to_s)
19 19
                    result = true
20 20
                    break
b/lib/puppet/parser/resource/reference.rb
33 33
    def definedtype
34 34
        unless defined? @definedtype
35 35
            case self.type
36
            when "Class": # look for host classes
36
            when "Class" # look for host classes
37 37
                if self.title == :main
38 38
                    tmp = @scope.findclass("")
39 39
                else
......
41 41
                        fail Puppet::ParseError, "Could not find class '%s'" % self.title
42 42
                    end
43 43
                end
44
            when "Node": # look for node definitions
44
            when "Node" # look for node definitions
45 45
                unless tmp = @scope.parser.nodes[self.title]
46 46
                    fail Puppet::ParseError, "Could not find node '%s'" % self.title
47 47
                end
b/lib/puppet/property.rb
165 165

  
166 166
        if self.class.name == :ensure
167 167
            event = case self.should
168
            when :present: (@resource.class.name.to_s + "_created").intern
169
            when :absent: (@resource.class.name.to_s + "_removed").intern
168
            when :present; (@resource.class.name.to_s + "_created").intern
169
            when :absent; (@resource.class.name.to_s + "_removed").intern
170 170
            else
171 171
                (@resource.class.name.to_s + "_changed").intern
172 172
            end
b/lib/puppet/provider/augeas/augeas.rb
83 83
        result = aug.get(path) || ''
84 84
        unless result.nil?
85 85
            case comparator
86
                when "!=":
86
                when "!="
87 87
                    return_value = true if !(result == arg)
88
                when "=~":
88
                when "=~"
89 89
                    regex = Regexp.new(arg)
90 90
                    loc = result=~ regex
91 91
                    return_value = true if ! loc.nil?
......
113 113
        # Now do the work
114 114
        if (!result.nil?)
115 115
            case verb
116
                when "size":
116
                when "size"
117 117
                    fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length != 2
118 118
                    comparator = cmd_array.shift()
119 119
                    arg = cmd_array.shift().to_i
120 120
                    return_value = true if (result.size.send(comparator, arg))
121
                when "include":
121
                when "include"
122 122
                    arg = cmd_array.join(" ")
123 123
                    return_value = true if result.include?(arg)
124
                when "==":
124
                when "=="
125 125
                    begin
126 126
                        arg = cmd_array.join(" ")
127 127
                        new_array = eval arg
......
145 145
            begin
146 146
                data = nil
147 147
                case command
148
                    when "get" then return_value = process_get(cmd_array)
149
                    when "match" then return_value = process_match(cmd_array)
148
                    when "get"; return_value = process_get(cmd_array)
149
                    when "match"; return_value = process_match(cmd_array)
150 150
                end
151 151
            rescue Exception => e
152 152
                fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}")
......
168 168
            debug("sending command '#{command}' with params #{cmd_array.inspect}")
169 169
            begin
170 170
                case command
171
                    when "set": aug.set(cmd_array[0], cmd_array[1])
172
                    when "rm", "remove": aug.rm(cmd_array[0])
173
                    when "clear": aug.clear(cmd_array[0])
174
                    when "insert", "ins": aug.insert(cmd_array[0])
171
                    when "set"; aug.set(cmd_array[0], cmd_array[1])
172
                    when "rm", "remove"; aug.rm(cmd_array[0])
173
                    when "clear"; aug.clear(cmd_array[0])
174
                    when "insert", "ins"; aug.insert(cmd_array[0])
175 175
                    else fail("Command '#{command}' is not supported")
176 176
                end
177 177
            rescue Exception => e
b/lib/puppet/provider/cron/crontab.rb
1 1
require 'puppet/provider/parsedfile'
2 2

  
3 3
tab = case Facter.value(:operatingsystem)
4
    when "Solaris": :suntab
4
    when "Solaris"; :suntab
5 5
    else
6 6
        :crontab
7 7
    end
......
141 141
        envs = nil
142 142
        result = records.each { |record|
143 143
            case record[:record_type]
144
            when :comment:
144
            when :comment
145 145
                if record[:name]
146 146
                    name = record[:name]
147 147
                    record[:skip] = true
......
149 149
                    # Start collecting env values
150 150
                    envs = []
151 151
                end
152
            when :environment:
152
            when :environment
153 153
                # If we're collecting env values (meaning we're in a named cronjob),
154 154
                # store the line and skip the record.
155 155
                if envs
156 156
                    envs << record[:line]
157 157
                    record[:skip] = true
158 158
                end
159
            when :blank:
159
            when :blank
160 160
                # nothing
161 161
            else
162 162
                if name
b/lib/puppet/provider/host/parsed.rb
2 2

  
3 3
hosts = nil
4 4
case Facter.value(:operatingsystem)
5
when "Solaris": hosts = "/etc/inet/hosts"
5
when "Solaris"; hosts = "/etc/inet/hosts"
6 6
else
7 7
    hosts = "/etc/hosts"
8 8
end
b/lib/puppet/provider/mount/parsed.rb
3 3

  
4 4
fstab = nil
5 5
case Facter.value(:operatingsystem)
6
when "Solaris": fstab = "/etc/vfstab"
6
when "Solaris"; fstab = "/etc/vfstab"
7 7
else
8 8
    fstab = "/etc/fstab"
9 9
end
......
20 20

  
21 21
    @platform = Facter["operatingsystem"].value
22 22
    case @platform
23
    when "Solaris":
23
    when "Solaris"
24 24
        @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot,
25 25
               :options]
26 26
    else
b/lib/puppet/provider/nameservice.rb
154 154

  
155 155
        group = method = nil
156 156
        case @resource.class.name
157
        when :user: group = :passwd; method = :uid
158
        when :group: group = :group; method = :gid
157
        when :user; group = :passwd; method = :uid
158
        when :group; group = :group; method = :gid
159 159
        else
160 160
            raise Puppet::DevError, "Invalid resource name %s" % resource
161 161
        end
b/lib/puppet/provider/nameservice/directoryservice.rb
148 148
            next unless (@@ds_to_ns_attribute_map.keys.include?(ds_attribute) and type_properties.include? @@ds_to_ns_attribute_map[ds_attribute])
149 149
            ds_value = dscl_plist[key]
150 150
            case @@ds_to_ns_attribute_map[ds_attribute]
151
                when :members: 
151
                when :members
152 152
                    ds_value = ds_value # only members uses arrays so far
153
                when :gid, :uid:
153
                when :gid, :uid
154 154
                    # OS X stores objects like uid/gid as strings.
155 155
                    # Try casting to an integer for these cases to be
156 156
                    # consistent with the other providers and the group type
......
449 449
        return @property_value_cache_hash
450 450
    end
451 451
end
452
end
452
end
b/lib/puppet/provider/nameservice/netinfo.rb
40 40

  
41 41
    def self.finish
42 42
        case self.name
43
        when :uid:
43
        when :uid
44 44
            noautogen
45
        when :gid:
45
        when :gid
46 46
            noautogen
47 47
        end
48 48
    end
b/lib/puppet/provider/package/gem.rb
83 83
            end
84 84

  
85 85
            case uri.scheme
86
            when nil: 
86
            when nil
87 87
                # no URI scheme => interpret the source as a local file
88 88
                command << source
89 89
            when /file/i
b/lib/puppet/provider/package/sun.rb
41 41
            # piece of information
42 42
            process.each { |line|
43 43
                case line
44
                when /^$/:
44
                when /^$/
45 45
                    hash[:provider] = :sun
46 46

  
47 47
                    packages << new(hash)
48 48
                    hash = {}
49
                when /\s*(\w+):\s+(.+)/:
49
                when /\s*(\w+):\s+(.+)/
50 50
                    name = $1
51 51
                    value = $2
52 52
                    if names.include?(name)
......
54 54
                            hash[names[name]] = value
55 55
                        end
56 56
                    end
57
                when /\s+\d+.+/:
57
                when /\s+\d+.+/
58 58
                    # nothing; we're ignoring the FILES info
59 59
                end
60 60
            }
......
96 96
                # piece of information
97 97
                process.each { |line|
98 98
                    case line
99
                    when /^$/:  # ignore
100
                    when /\s*([A-Z]+):\s+(.+)/:
99
                    when /^$/  # ignore
100
                    when /\s*([A-Z]+):\s+(.+)/
101 101
                        name = $1
102 102
                        value = $2
103 103
                        if names.include?(name)
......
105 105
                                hash[names[name]] = value
106 106
                            end
107 107
                        end
108
                    when /\s+\d+.+/:
108
                    when /\s+\d+.+/
109 109
                        # nothing; we're ignoring the FILES info
110 110
                    end
111 111
                }
b/lib/puppet/provider/port/parsed.rb
2 2

  
3 3
#services = nil
4 4
#case Facter.value(:operatingsystem)
5
#when "Solaris": services = "/etc/inet/services"
5
#when "Solaris"; services = "/etc/inet/services"
6 6
#else
7 7
#    services = "/etc/services"
8 8
#end
b/lib/puppet/provider/service/init.rb
15 15
    end
16 16

  
17 17
    case Facter["operatingsystem"].value
18
    when "FreeBSD":
18
    when "FreeBSD"
19 19
        @defpath = ["/etc/rc.d", "/usr/local/etc/rc.d"]
20
    when "HP-UX":
20
    when "HP-UX"
21 21
        @defpath = "/sbin/init.d"
22 22
    else
23 23
        @defpath = "/etc/init.d"
......
57 57
    # Mark that our init script supports 'status' commands.
58 58
    def hasstatus=(value)
59 59
        case value
60
        when true, "true": @parameters[:hasstatus] = true
61
        when false, "false": @parameters[:hasstatus] = false
60
        when true, "true"; @parameters[:hasstatus] = true
61
        when false, "false"; @parameters[:hasstatus] = false
62 62
        else
63 63
            raise Puppet::Error, "Invalid 'hasstatus' value %s" %
64 64
                value.inspect
b/lib/puppet/provider/service/smf.rb
20 20

  
21 21
    def enabled?
22 22
        case self.status
23
        when :running:
23
        when :running
24 24
            return :true
25 25
        else
26 26
            return :false
......
62 62
                next
63 63
            end
64 64
            case var
65
            when "state":
65
            when "state"
66 66
                case value
67
                when "online":
67
                when "online"
68 68
                    #self.warning "matched running %s" % line.inspect
69 69
                    return :running
70 70
                when "offline", "disabled", "uninitialized"
71 71
                    #self.warning "matched stopped %s" % line.inspect
72 72
                    return :stopped
73
                when "legacy_run":
73
                when "legacy_run"
74 74
                    raise Puppet::Error,
75 75
                        "Cannot manage legacy services through SMF"
76 76
                else
b/lib/puppet/provider/sshkey/parsed.rb
2 2

  
3 3
known = nil
4 4
case Facter.value(:operatingsystem)
5
when "Darwin": known = "/etc/ssh_known_hosts"
5
when "Darwin"; known = "/etc/ssh_known_hosts"
6 6
else
7 7
    known = "/etc/ssh/ssh_known_hosts"
8 8
end
b/lib/puppet/provider/user/directoryservice.rb
71 71
    # of the groups and add us to them.
72 72
    def groups=(groups)
73 73
        # case groups
74
        # when Fixnum:
74
        # when Fixnum
75 75
        #     groups = [groups.to_s]
76 76
        # when String
77 77
        #     groups = groups.split(/\s*,\s*/)
b/lib/puppet/provider/user/netinfo.rb
66 66
        warnonce "The NetInfo provider is deprecated; use directoryservice instead"
67 67
        
68 68
        case groups
69
        when Fixnum:
69
        when Fixnum
70 70
            groups = [groups.to_s]
71 71
        when String
72 72
            groups = groups.split(/\s*,\s*/)
b/lib/puppet/provider/zone/solaris.rb
112 112
        hash = {}
113 113
        output.split("\n").each do |line|
114 114
            case line
115
            when /^(\S+):\s*$/:
115
            when /^(\S+):\s*$/
116 116
                name = $1
117 117
                current = nil # reset it
118
            when /^(\S+):\s*(.+)$/:
118
            when /^(\S+):\s*(.+)$/
119 119
                hash[$1.intern] = $2
120
            when /^\s+(\S+):\s*(.+)$/:
120
            when /^\s+(\S+):\s*(.+)$/
121 121
                if name
122 122
                    unless hash.include? name
123 123
                        hash[name] = []
b/lib/puppet/provider/zpool/solaris.rb
19 19
        pool_array.reverse.each do |value|
20 20
            sym = nil
21 21
            case value
22
            when "spares": sym = :spare
23
            when "logs": sym = :log
24
            when "mirror", "raidz1", "raidz2":
22
            when "spares"; sym = :spare
23
            when "logs"; sym = :log
24
            when "mirror", "raidz1", "raidz2"
25 25
                sym = value == "mirror" ? :mirror : :raidz
26 26
                pool[:raid_parity] = "raidz2" if value == "raidz2"
27 27
            else
b/lib/puppet/rails.rb
41 41
        args = {:adapter => adapter, :log_level => Puppet[:rails_loglevel]}
42 42

  
43 43
        case adapter
44
        when "sqlite3":
44
        when "sqlite3"
45 45
            args[:dbfile] = Puppet[:dblocation]
46
        when "mysql", "postgresql":
46
        when "mysql", "postgresql"
47 47
            args[:host]     = Puppet[:dbserver] unless Puppet[:dbserver].empty?
48 48
            args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty?
49 49
            args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].empty?
b/lib/puppet/reference/providers.rb
61 61
                details = ".. [%s]\n" % count
62 62
                missing.each do |test, values|
63 63
                    case test
64
                    when :exists:
64
                    when :exists
65 65
                        details += "  - Missing files %s\n" % values.join(", ")
66
                    when :variable:
66
                    when :variable
67 67
                        values.each do |name, facts|
68 68
                            if Puppet.settings.valid?(name)
69 69
                                details += "  - Setting %s (currently %s) not in list %s\n" % [name, Puppet.settings.value(name).inspect, facts.join(", ")]
......
71 71
                                details += "  - Fact %s (currently %s) not in list %s\n" % [name, Facter.value(name).inspect, facts.join(", ")]
72 72
                            end
73 73
                        end
74
                    when :true:
74
                    when :true
75 75
                        details += "  - Got %s true tests that should have been false\n" % values
76
                    when :false:
76
                    when :false
77 77
                        details += "  - Got %s false tests that should have been true\n" % values
78
                    when :feature:
78
                    when :feature
79 79
                        details += "  - Missing features %s\n" % values.collect { |f| f.to_s }.join(",")
80 80
                    end
81 81
                end
b/lib/puppet/reports/tagmail.rb
75 75
        text.split("\n").each do |line|
76 76
            taglist = emails = nil
77 77
            case line.chomp
78
            when /^\s*#/: next
79
            when /^\s*$/: next
80
            when /^\s*(.+)\s*:\s*(.+)\s*$/:
78
            when /^\s*#/; next
79
            when /^\s*$/; next
80
            when /^\s*(.+)\s*:\s*(.+)\s*$/
81 81
                taglist = $1
82 82
                emails = $2.sub(/#.*$/,'')
83 83
            else
......
91 91
                    raise ArgumentError, "Invalid tag %s" % tag.inspect
92 92
                end
93 93
                case tag
94
                when /^\w+/: pos << tag
95
                when /^!\w+/: neg << tag.sub("!", '')
94
                when /^\w+/; pos << tag
95
                when /^!\w+/; neg << tag.sub("!", '')
96 96
                else
97 97
                    raise Puppet::Error, "Invalid tag '%s'" % tag
98 98
                end
b/lib/puppet/simple_graph.rb
65 65
        # The other vertex in the edge.
66 66
        def other_vertex(direction, edge)
67 67
            case direction
68
            when :in: edge.source
68
            when :in; edge.source
69 69
            else
70 70
                edge.target
71 71
            end
b/lib/puppet/sslcertificates.rb
53 53

  
54 54
        ex = []
55 55
        case hash[:type]
56
        when :ca:
56
        when :ca
57 57
            basic_constraint = "CA:TRUE"
58 58
            key_usage = %w{cRLSign keyCertSign}
59
        when :terminalsubca:
59
        when :terminalsubca
60 60
            basic_constraint = "CA:TRUE,pathlen:0"
61 61
            key_usage = %w{cRLSign keyCertSign}
62
        when :server:
62
        when :server
63 63
            basic_constraint = "CA:FALSE"
64 64
            dnsnames = Puppet[:certdnsnames]
65 65
            name = hash[:name].to_s.sub(%r{/CN=},'')
......
73 73
            end
74 74
            key_usage = %w{digitalSignature keyEncipherment}
75 75
            ext_key_usage = %w{serverAuth clientAuth emailProtection}
76
        when :ocsp:
76
        when :ocsp
77 77
            basic_constraint = "CA:FALSE"
78 78
            key_usage = %w{nonRepudiation digitalSignature}
79 79
            ext_key_usage = %w{serverAuth OCSPSigning}
80
        when :client:
80
        when :client
81 81
            basic_constraint = "CA:FALSE"
82 82
            key_usage = %w{nonRepudiation digitalSignature keyEncipherment}
83 83
            ext_key_usage = %w{clientAuth emailProtection}
b/lib/puppet/sslcertificates/certificate.rb
101 101
        
102 102
        if hash.include?(:type)
103 103
            case hash[:type] 
104
            when :ca, :client, :server: @type = hash[:type]
104
            when :ca, :client, :server; @type = hash[:type]
105 105
            else
106 106
                raise "Invalid Cert type %s" % hash[:type]
107 107
            end
b/lib/puppet/type.rb
79 79
        # of times (as in, hundreds of thousands in a given run).
80 80
        unless @attrclasses.include?(name)
81 81
            @attrclasses[name] = case self.attrtype(name)
82
            when :property: @validproperties[name]
83
            when :meta: @@metaparamhash[name]
84
            when :param: @paramhash[name]
82
            when :property; @validproperties[name]
83
            when :meta; @@metaparamhash[name]
84
            when :param; @paramhash[name]
85 85
            end
86 86
        end
87 87
        @attrclasses[name]
......
93 93
        @attrtypes ||= {}
94 94
        unless @attrtypes.include?(attr)
95 95
            @attrtypes[attr] = case
96
                when @validproperties.include?(attr): :property
97
                when @paramhash.include?(attr): :param
98
                when @@metaparamhash.include?(attr): :meta
96
                when @validproperties.include?(attr); :property
97
                when @paramhash.include?(attr); :param
98
                when @@metaparamhash.include?(attr); :meta
99 99
                end
100 100
        end
101 101

  
......
1089 1089
        newvalues(:true, :false)
1090 1090
        munge do |value|
1091 1091
            case value
1092
            when true, :true, "true": @resource.noop = true
1093
            when false, :false, "false": @resource.noop = false
1092
            when true, :true, "true"; @resource.noop = true
1093
            when false, :false, "false"; @resource.noop = false
1094 1094
            end
1095 1095
        end
1096 1096
    end
......
1780 1780

  
1781 1781
        @tags = list.collect do |t|
1782 1782
            case t
1783
            when String: t.intern
1784
            when Symbol: t
1783
            when String; t.intern
1784
            when Symbol; t
1785 1785
            else
1786 1786
                self.warning "Ignoring tag %s of type %s" % [tag.inspect, tag.class]
1787 1787
            end
b/lib/puppet/type/file.rb
81 81
                value = value.shift if value.is_a?(Array)
82 82

  
83 83
                case value
84
                when false, "false", :false:
84
                when false, "false", :false
85 85
                    false
86
                when true, "true", ".puppet-bak", :true:
86
                when true, "true", ".puppet-bak", :true
87 87
                    ".puppet-bak"
88 88
                when /^\./
89 89
                    value
90
                when String:
90
                when String
91 91
                    # We can't depend on looking this up right now,
92 92
                    # we have to do it after all of the objects
93 93
                    # have been instantiated.
......
100 100
                        @resource.bucket = value
101 101
                        value
102 102
                    end
103
                when Puppet::Network::Client.client(:Dipper):
103
                when Puppet::Network::Client.client(:Dipper)
104 104
                    @resource.bucket = value
105 105
                    value.name
106 106
                else
......
122 122
            munge do |value|
123 123
                newval = super(value)
124 124
                case newval
125
                when :true, :inf: true
126
                when :false: false
127
                when Integer, Fixnum, Bignum: value
128
                when /^\d+$/: Integer(value)
125
                when :true, :inf; true
126
                when :false; false
127
                when Integer, Fixnum, Bignum; value
128
                when /^\d+$/; Integer(value)
129 129
                else
130 130
                    raise ArgumentError, "Invalid recurse value %s" % value.inspect
131 131
                end
......
308 308
            # Look up our bucket, if there is one
309 309
            if bucket = self.bucket
310 310
                case bucket
311
                when String:
311
                when String
312 312
                    if catalog and obj = catalog.resource(:filebucket, bucket)
313 313
                        self.bucket = obj.bucket
314 314
                    elsif bucket == "puppet"
......
319 319
                    else
320 320
                        self.fail "Could not find filebucket '%s'" % bucket
321 321
                    end
322
                when Puppet::Network::Client.client(:Dipper): # things are hunky-dorey
322
                when Puppet::Network::Client.client(:Dipper) # things are hunky-dorey
323 323
                when Puppet::Type::Filebucket # things are hunky-dorey
324 324
                    self.bucket = bucket.bucket
325 325
                else
......
365 365
            end
366 366

  
367 367
            case File.stat(file).ftype
368
            when "directory":
368
            when "directory"
369 369
                if self[:recurse]
370 370
                    # we don't need to backup directories when recurse is on
371 371
                    return true
372 372
                else
373 373
                    backup = self.bucket || self[:backup]
374 374
                    case backup
375
                    when Puppet::Network::Client.client(:Dipper):
375
                    when Puppet::Network::Client.client(:Dipper)
376 376
                        notice "Recursively backing up to filebucket"
377 377
                        require 'find'
378 378
                        Find.find(self[:path]) do |f|
......
384 384
                        end
385 385

  
386 386
                        return true
387
                    when String:
387
                    when String
388 388
                        newfile = file + backup
389 389
                        # Just move it, since it's a directory.
390 390
                        if FileTest.exists?(newfile)
......
408 408
                        return false
409 409
                    end
410 410
                end
411
            when "file":
411
            when "file"
412 412
                backup = self.bucket || self[:backup]
413 413
                case backup
414
                when Puppet::Network::Client.client(:Dipper):
414
                when Puppet::Network::Client.client(:Dipper)
415 415
                    sum = backup.backup(file)
416 416
                    self.notice "Filebucketed to %s with sum %s" %
417 417
                        [backup.name, sum]
418 418
                    return true
419
                when String:
419
                when String
420 420
                    newfile = file + backup
421 421
                    if FileTest.exists?(newfile)
422 422
                        remove_backup(newfile)
......
440 440
                    self.err "Invalid backup type %s" % backup.inspect
441 441
                    return false
442 442
                end
443
            when "link": return true
443
            when "link"; return true
444 444
            else
445 445
                self.notice "Cannot backup files of type %s" % File.stat(file).ftype
446 446
                return false
......
666 666
            end
667 667

  
668 668
            case s.ftype
669
            when "directory":
669
            when "directory"
670 670
                if self[:force] == :true
671 671
                    debug "Removing existing directory for replacement with %s" % should
672 672
                    FileUtils.rmtree(self[:path])
673 673
                else
674 674
                    notice "Not removing directory; use 'force' to override"
675 675
                end
676
            when "link", "file":
676
            when "link", "file"
677 677
                debug "Removing existing %s for replacement with %s" %
678 678
                    [s.ftype, should]
679 679
                File.unlink(self[:path])
b/lib/puppet/type/host.rb
34 34
                case is
35 35
                when String
36 36
                    is = is.split(/\s*,\s*/)
37
                when Symbol:
37
                when Symbol
38 38
                    is = [is]
39 39
                when Array
40 40
                    # nothing
b/lib/puppet/type/macauthorization.rb
12 12
    
13 13
    def munge_boolean(value)
14 14
        case value
15
        when true, "true", :true:
15
        when true, "true", :true
16 16
            :true
17 17
        when false, "false", :false
18 18
            :false
b/lib/puppet/type/mount.rb
188 188
            newvalues(:true, :false)
189 189
            defaultto do
190 190
                case Facter.value(:operatingsystem)
191
                when "FreeBSD": false
191
                when "FreeBSD"; false
192 192
                else
193 193
                    true
194 194
                end
b/lib/puppet/type/notify.rb
10 10
            desc "The message to be sent to the log."
11 11
            def sync
12 12
                case @resource["withpath"]
13
                when :true:
13
                when :true
14 14
                    send(@resource[:loglevel], self.should)
15 15
                else  
16 16
                    Puppet.send(@resource[:loglevel], self.should)
b/lib/puppet/type/package.rb
131 131
                        end
132 132

  
133 133
                        case is
134
                        when @latest:
134
                        when @latest
135 135
                            return true
136
                        when :present:
136
                        when :present
137 137
                            # This will only happen on retarded packaging systems
138 138
                            # that can't query versions.
139 139
                            return true
b/lib/puppet/type/resources.rb
56 56
                500
57 57
            when :false, false
58 58
                false
59
            when Integer: value
59
            when Integer; value
60 60
            else
61 61
                raise ArgumentError, "Invalid value %s" % value.inspect
62 62
            end
b/lib/puppet/type/tidy.rb
87 87
        munge do |age|
88 88
            unit = multi = nil
89 89
            case age
90
            when /^([0-9]+)(\w)\w*$/:
90
            when /^([0-9]+)(\w)\w*$/
91 91
                multi = Integer($1)
92 92
                unit = $2.downcase.intern
93
            when /^([0-9]+)$/:
93
            when /^([0-9]+)$/
94 94
                multi = Integer($1)
95 95
                unit = :d
96 96
            else
......
135 135
        
136 136
        munge do |size|
137 137
            case size
138
            when /^([0-9]+)(\w)\w*$/:
138
            when /^([0-9]+)(\w)\w*$/
139 139
                multi = Integer($1)
140 140
                unit = $2.downcase.intern
141
            when /^([0-9]+)$/:
141
            when /^([0-9]+)$/
142 142
                multi = Integer($1)
143 143
                unit = :k
144 144
            else
......
169 169
        munge do |value|
170 170
            newval = super(value)
171 171
            case newval
172
            when :true, :inf: true
173
            when :false: false
174
            when Integer, Fixnum, Bignum: value
175
            when /^\d+$/: Integer(value)
172
            when :true, :inf; true
173
            when :false; false
174
            when Integer, Fixnum, Bignum; value
175
            when /^\d+$/; Integer(value)
176 176
            else
177 177
                raise ArgumentError, "Invalid recurse value %s" % value.inspect
178 178
            end
b/lib/puppet/type/user.rb
222 222
                }
223 223
                groups.each { |group|
224 224
                    case group
225
                    when Integer:
225
                    when Integer
226 226
                        if resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) and r.should(:gid) == group }
227 227
                            autos << resource
228 228
                        end
b/lib/puppet/type/zone.rb
400 400
        hash.each do |param, value|
401 401
            next if param == :name
402 402
            case self.class.attrtype(param)
403
            when :property:
403
            when :property
404 404
                # Only try to provide values for the properties we're managing
405 405
                if prop = self.property(param)
406 406
                    prophash[prop] = value
b/lib/puppet/util/fileparsing.rb
332 332
        end
333 333

  
334 334
        case record.type
335
        when :text: return details[:line]
335
        when :text; return details[:line]
336 336
        else
337 337
            if record.respond_to?(:to_line)
338 338
                return record.to_line(details)
b/lib/puppet/util/filetype.rb
299 299
                # Now we should have nothing but records, wrapped in braces
300 300

  
301 301
                case line
302
                when /^\s+\{/: hash = {}
303
                when /^\s+\}/: records << hash
302
                when /^\s+\{/; hash = {}
303
                when /^\s+\}/; records << hash
304 304
                when /\s+"(\w+)" = \( (.+) \)/
305 305
                    field = $1
306 306
                    values = $2
b/lib/puppet/util/ldap/connection.rb
62 62
    def start
63 63
        begin
64 64
            case ssl
65
            when :tls:
65
            when :tls
66 66
                @connection = LDAP::SSLConn.new(host, port, true)
67
            when true:
67
            when true
68 68
                @connection = LDAP::SSLConn.new(host, port)
69 69
            else
70 70
                @connection = LDAP::Conn.new(host, port)
b/lib/puppet/util/log.rb
275 275
        
276 276
        def colorize(level, str)
277 277
            case Puppet[:color]
278
            when false: str
279
            when true, :ansi, "ansi": console_color(level, str)
280
            when :html, "html": html_color(level, str)
278
            when false; str
279
            when true, :ansi, "ansi"; console_color(level, str)
280
            when :html, "html"; html_color(level, str)
281 281
            end
282 282
        end
283 283
        
b/lib/puppet/util/posix.rb
52 52
        # Apparently the group/passwd methods need to get reset; if we skip
53 53
        # this call, then new users aren't found.
54 54
        case type
55
        when :passwd: Etc.send(:endpwent)
56
        when :group: Etc.send(:endgrent)
55
        when :passwd; Etc.send(:endpwent)
56
        when :group; Etc.send(:endgrent)
57 57
        end
58 58
        return nil
59 59
    end
......
61 61
    # Determine what the field name is for users and groups.
62 62
    def idfield(space)
63 63
        case Puppet::Util.symbolize(space)
64
        when :gr, :group: return :gid
65
        when :pw, :user, :passwd: return :uid
64
        when :gr, :group; return :gid
65
        when :pw, :user, :passwd; return :uid
66 66
        else
67 67
            raise ArgumentError.new("Can only handle users and groups")
68 68
        end
......
71 71
    # Determine what the method is to get users and groups by id
72 72
    def methodbyid(space)
73 73
        case Puppet::Util.symbolize(space)
74
        when :gr, :group: return :getgrgid
75
        when :pw, :user, :passwd: return :getpwuid
74
        when :gr, :group; return :getgrgid
75
        when :pw, :user, :passwd; return :getpwuid
76 76
        else
77 77
            raise ArgumentError.new("Can only handle users and groups")
78 78
        end
......
81 81
    # Determine what the method is to get users and groups by name
82 82
    def methodbyname(space)
83 83
        case Puppet::Util.symbolize(space)
84
        when :gr, :group: return :getgrnam
85
        when :pw, :user, :passwd: return :getpwnam
84
        when :gr, :group; return :getgrnam
85
        when :pw, :user, :passwd; return :getpwnam
86 86
        else
87 87
            raise ArgumentError.new("Can only handle users and groups")
88 88
        end
... This diff was truncated because it exceeds the maximum size that can be displayed.