Class: PushyClient::Whitelist
- Inherits:
-
Object
- Object
- PushyClient::Whitelist
show all
- Defined in:
- lib/pushy_client/whitelist.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(whitelist) ⇒ Whitelist
25
26
27
|
# File 'lib/pushy_client/whitelist.rb', line 25
def initialize(whitelist)
@whitelist = whitelist
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
62
63
64
|
# File 'lib/pushy_client/whitelist.rb', line 62
def method_missing(method, *args, &block)
@whitelist.send(method, *args, &block)
end
|
Instance Attribute Details
#whitelist ⇒ Object
Returns the value of attribute whitelist.
23
24
25
|
# File 'lib/pushy_client/whitelist.rb', line 23
def whitelist
@whitelist
end
|
Instance Method Details
#[](argument) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/pushy_client/whitelist.rb', line 29
def [](argument)
command = process(argument)
node_name = "UNKNOWN"
job_id = "UNKNOWN"
Chef::Log.info("[#{node_name}] Job #{job_id}: whitelist '#{argument}' to '#{command}'")
command
end
|
#process(argument) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/pushy_client/whitelist.rb', line 37
def process(argument)
if whitelist.has_key?(argument)
return whitelist[argument]
else
whitelist.keys.each do |key|
if key.kind_of?(Regexp)
if key.match(argument)
value = whitelist[key]
if value.kind_of?(Hash)
new_value = Marshal.load(Marshal.dump(value))
new_value[:command_line] = argument.gsub(key, value[:command_line])
return new_value
else
return argument.gsub(key, value)
end
end
end
end
end
nil
end
|