Class: Makitzo::Config
Constant Summary
collapse
- MERGER =
lambda do |k,o,n|
if o.is_a?(Array)
n.is_a?(Array) ? (o + n) : (o.dup << n)
else
n
end
end
Instance Method Summary
collapse
Methods included from Settings
#[], #[]=, #memo, #read, #set, #settings
#app, #config, #logger
Constructor Details
#initialize(app) ⇒ Config
Returns a new instance of Config.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/makitzo/config.rb', line 6
def initialize(app)
@app = app
@options_stack = []
@terminal = HighLine.new
@store = nil
@concurrency = nil
@helpers = Module.new do
def self.method_added(method_name)
if SSH::Context.protected_context_methods.include?(method_name.to_s)
raise "The method name '#{method_name}' is used internally by SSH sessions. Please rename your helper."
end
end
end
@mutex = Mutex.new
initialize_roles
initialize_hosts
end
|
Instance Method Details
#concurrency ⇒ Object
33
34
35
|
# File 'lib/makitzo/config.rb', line 33
def concurrency
@concurrency
end
|
#concurrency=(concurrency) ⇒ Object
29
30
31
|
# File 'lib/makitzo/config.rb', line 29
def concurrency=(concurrency)
@concurrency = concurrency
end
|
#helpers(&block) ⇒ Object
52
53
54
55
|
# File 'lib/makitzo/config.rb', line 52
def helpers(&block)
@helpers.class_eval(&block) if block_given?
@helpers
end
|
#memoize(&block) ⇒ Object
60
61
62
|
# File 'lib/makitzo/config.rb', line 60
def memoize(&block)
MemoizedProc.new(&block)
end
|
#merged_options(extra_options = {}) ⇒ Object
98
99
100
101
|
# File 'lib/makitzo/config.rb', line 98
def merged_options( = {})
opts = @options_stack.inject({}) { |m,hsh| m.update(hsh, &MERGER) }
opts.update(, &MERGER)
end
|
#password_prompt(prompt = 'Enter password: ') ⇒ Object
74
75
76
|
# File 'lib/makitzo/config.rb', line 74
def password_prompt(prompt = 'Enter password: ')
ask(prompt) { |q| q.echo = false }
end
|
#resolve_role(thing) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/makitzo/config.rb', line 139
def resolve_role(thing)
if thing.is_a?(::Makitzo::World::Role)
thing
else
role_for_name!(thing.to_s)
end
end
|
#store ⇒ Object
44
45
46
47
|
# File 'lib/makitzo/config.rb', line 44
def store
raise Store::MissingStoreError if @store.nil?
@store
end
|
#store=(store) ⇒ Object
40
41
42
|
# File 'lib/makitzo/config.rb', line 40
def store=(store)
@store = store
end
|
#synchronize(&block) ⇒ Object
64
65
66
|
# File 'lib/makitzo/config.rb', line 64
def synchronize(&block)
@mutex.synchronize(&block)
end
|
#with_options(options) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/makitzo/config.rb', line 81
def with_options(options)
begin
@options_stack.push(options)
yield if block_given?
ensure
@options_stack.pop
end
end
|