0001-Issue-1849-Ruby-1.9-portability-when-doesn-t-lik.patch

Jos Backus, 02/26/2009 12:25 am

Download (80.4 kB)

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
74 74
	# configuration parameter access and stuff
75 75
	def self.[](param)
76 76
        case param
77
        when :debug:
77
        when :debug
78 78
            if Puppet::Util::Log.level == :debug
79 79
                return true
80 80
            else
b/lib/puppet/application/puppetrun.rb
135 135
        end
136 136

  
137 137
        case result
138
        when "success": exit(0)
139
        when "running":
138
        when "success"; exit(0)
139
        when "running"
140 140
            $stderr.puts "Host %s is already running" % host
141 141
            exit(3)
142 142
        else
b/lib/puppet/configurer.rb
150 150
    def self.timeout
151 151
        timeout = Puppet[:configtimeout]
152 152
        case timeout
153
        when String:
153
        when String
154 154
            if timeout =~ /^\d+$/
155 155
                timeout = Integer(timeout)
156 156
            else
157 157
                raise ArgumentError, "Configuration timeout must be an integer"
158 158
            end
159
        when Integer: # nothing
159
        when Integer # nothing
160 160
        else
161 161
            raise ArgumentError, "Configuration timeout must be an integer"
162 162
        end
b/lib/puppet/configurer/downloader.rb
8 8
    def self.timeout
9 9
        timeout = Puppet[:configtimeout]
10 10
        case timeout
11
        when String:
11
        when String
12 12
            if timeout =~ /^\d+$/
13 13
                timeout = Integer(timeout)
14 14
            else
15 15
                raise ArgumentError, "Configuration timeout must be an integer"
16 16
            end
17
        when Integer: # nothing
17
        when Integer # nothing
18 18
        else
19 19
            raise ArgumentError, "Configuration timeout must be an integer"
20 20
        end
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
39 39
    def self.timeout
40 40
        timeout = Puppet[:configtimeout]
41 41
        case timeout
42
        when String:
42
        when String
43 43
            if timeout =~ /^\d+$/
44 44
                timeout = Integer(timeout)
45 45
            else
46 46
                raise ArgumentError, "Configuration timeout must be an integer"
47 47
            end
48
        when Integer: # nothing
48
        when Integer # nothing
49 49
        else
50 50
            raise ArgumentError, "Configuration timeout must be an integer"
51 51
        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/handler/fileserver.rb
278 278
                    count = 1
279 279
                    f.each { |line|
280 280
                        case line
281
                        when /^\s*#/: next # skip comments
282
                        when /^\s*$/: next # skip blank lines
283
                        when /\[([-\w]+)\]/:
281
                        when /^\s*#/; next # skip comments
282
                        when /^\s*$/; next # skip blank lines
283
                        when /\[([-\w]+)\]/
284 284
                            name = $1
285 285
                            if newmounts.include?(name)
286 286
                                raise FileServerError, "%s is already mounted at %s" %
......
288 288
                            end
289 289
                            mount = Mount.new(name)
290 290
                            newmounts[name] = mount
291
                        when /^\s*(\w+)\s+(.+)$/:
291
                        when /^\s*(\w+)\s+(.+)$/
292 292
                            var = $1
293 293
                            value = $2
294 294
                            case var
295
                            when "path":
295
                            when "path"
296 296
                                if mount.name == MODULES
297 297
                                    Puppet.warning "The '#{mount.name}' module can not have a path. Ignoring attempt to set it"
298 298
                                else
......
304 304
                                        newmounts.delete(mount.name)
305 305
                                    end
306 306
                                end
307
                            when "allow":
307
                            when "allow"
308 308
                                value.split(/\s*,\s*/).each { |val|
309 309
                                    begin
310 310
                                        mount.info "allowing %s access" % val
......
314 314
                                            count, @configuration.file)
315 315
                                    end
316 316
                                }
317
                            when "deny":
317
                            when "deny"
318 318
                                value.split(/\s*,\s*/).each { |val|
319 319
                                    begin
320 320
                                        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
99 99
        result = aug.get(path) || ''
100 100
        unless result.nil?
101 101
            case comparator
102
                when "!=":
102
                when "!="
103 103
                    return_value = true if !(result == arg)
104
                when "=~":
104
                when "=~"
105 105
                    regex = Regexp.new(arg)
106 106
                    loc = result=~ regex
107 107
                    return_value = true if ! loc.nil?
......
129 129
        # Now do the work
130 130
        if (!result.nil?)
131 131
            case verb
132
                when "size":
132
                when "size"
133 133
                    fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length != 2
134 134
                    comparator = cmd_array.shift()
135 135
                    arg = cmd_array.shift().to_i
136 136
                    return_value = true if (result.size.send(comparator, arg))
137
                when "include":
137
                when "include"
138 138
                    arg = cmd_array.join(" ")
139 139
                    return_value = true if result.include?(arg)
140
                when "==":
140
                when "=="
141 141
                    begin
142 142
                        arg = cmd_array.join(" ")
143 143
                        new_array = eval arg
......
161 161
            begin
162 162
                data = nil
163 163
                case command
164
                    when "get" then return_value = process_get(cmd_array)
165
                    when "match" then return_value = process_match(cmd_array)
164
                    when "get"; return_value = process_get(cmd_array)
165
                    when "match"; return_value = process_match(cmd_array)
166 166
                end
167 167
            rescue Exception => e
168 168
                fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}")
......
182 182
            cmd_array.shift()
183 183
            begin
184 184
                case command
185
                    when "set":
185
                    when "set"
186 186
                        cmd_array[0]=File.join(context, cmd_array[0])
187 187
                        debug("sending command '#{command}' with params #{cmd_array.inspect}")
188 188
                        aug.set(cmd_array[0], cmd_array[1])
189
                    when "rm", "remove":
189
                    when "rm", "remove"
190 190
                        cmd_array[0]=File.join(context, cmd_array[0])
191 191
                        debug("sending command '#{command}' with params #{cmd_array.inspect}")                    
192 192
                        aug.rm(cmd_array[0])
193
                    when "clear":
193
                    when "clear"
194 194
                        cmd_array[0]=File.join(context, cmd_array[0])
195 195
                        debug("sending command '#{command}' with params #{cmd_array.inspect}")                    
196 196
                        aug.clear(cmd_array[0])
......
204 204
                        where = ext_array[0]
205 205
                        path = File.join(context, ext_array[1]) 
206 206
                        case where
207
                            when "before": before = true
208
                            when "after": before = false
207
                            when "before"; before = true
208
                            when "after"; before = false
209 209
                            else fail("Invalid value '#{where}' for where param")
210 210
                        end
211 211
                        debug("sending command '#{command}' with params #{[label, where, path].inspect()}") 
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
192 192
            next unless (@@ds_to_ns_attribute_map.keys.include?(ds_attribute) and type_properties.include? @@ds_to_ns_attribute_map[ds_attribute])
193 193
            ds_value = input_hash[key]
194 194
            case @@ds_to_ns_attribute_map[ds_attribute]
195
                when :members: 
195
                when :members
196 196
                    ds_value = ds_value # only members uses arrays so far
197
                when :gid, :uid:
197
                when :gid, :uid
198 198
                    # OS X stores objects like uid/gid as strings.
199 199
                    # Try casting to an integer for these cases to be
200 200
                    # consistent with the other providers and the group type
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
64 64
        # The other vertex in the edge.
65 65
        def other_vertex(direction, edge)
66 66
            case direction
67
            when :in: edge.source
67
            when :in; edge.source
68 68
            else
69 69
                edge.target
70 70
            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

  
......
1085 1085
        newvalues(:true, :false)
1086 1086
        munge do |value|
1087 1087
            case value
1088
            when true, :true, "true": @resource.noop = true
1089
            when false, :false, "false": @resource.noop = false
1088
            when true, :true, "true"; @resource.noop = true
1089
            when false, :false, "false"; @resource.noop = false
1090 1090
            end
1091 1091
        end
1092 1092
    end
......
1776 1776

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

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

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

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

  
669 669
            case s.ftype
670
            when "directory":
670
            when "directory"
671 671
                if self[:force] == :true
672 672
                    debug "Removing existing directory for replacement with %s" % should
673 673
                    FileUtils.rmtree(self[:path])
674 674
                else
675 675
                    notice "Not removing directory; use 'force' to override"
676 676
                end
677
            when "link", "file":
677
            when "link", "file"
678 678
                debug "Removing existing %s for replacement with %s" %
679 679
                    [s.ftype, should]
680 680
                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
99 99
        munge do |age|
100 100
            unit = multi = nil
101 101
            case age
102
            when /^([0-9]+)(\w)\w*$/:
102
            when /^([0-9]+)(\w)\w*$/
103 103
                multi = Integer($1)
104 104
                unit = $2.downcase.intern
105
            when /^([0-9]+)$/:
105
            when /^([0-9]+)$/
106 106
                multi = Integer($1)
107 107
                unit = :d
108 108
            else
......
147 147
        
148 148
        munge do |size|
149 149
            case size
150
            when /^([0-9]+)(\w)\w*$/:
150
            when /^([0-9]+)(\w)\w*$/
151 151
                multi = Integer($1)
152 152
                unit = $2.downcase.intern
153
            when /^([0-9]+)$/:
153
            when /^([0-9]+)$/
154 154
                multi = Integer($1)
155 155
                unit = :k
156 156
            else
......
181 181
        munge do |value|
182 182
            newval = super(value)
183 183
            case newval
184
            when :true, :inf: true
185
            when :false: false
186
            when Integer, Fixnum, Bignum: value
187
            when /^\d+$/: Integer(value)
184
            when :true, :inf; true
185
            when :false; false
186
            when Integer, Fixnum, Bignum; value
187
            when /^\d+$/; Integer(value)
188 188
            else
189 189
                raise ArgumentError, "Invalid recurse value %s" % value.inspect
190 190
            end
b/lib/puppet/type/user.rb
228 228
                }
229 229
                groups.each { |group|
230 230
                    case group
231
                    when Integer:
231
                    when Integer
232 232
                        if resource = catalog.resources.find { |r| r.is_a?(Puppet::Type.type(:group)) and r.should(:gid) == group }
233 233
                            autos << resource
234 234
                        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/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
282 282
        
283 283
        def colorize(level, str)
284 284
            case Puppet[:color]
285
            when false: str
286
            when true, :ansi, "ansi": console_color(level, str)
287
            when :html, "html": html_color(level, str)
285
            when false; str
... This diff was truncated because it exceeds the maximum size that can be displayed.