Class: ConfigmonkeyCli::Application::ManifestAction::Chmod
- Inherits:
-
Base
- Object
- Base
- ConfigmonkeyCli::Application::ManifestAction::Chmod
show all
- Defined in:
- lib/configmonkey_cli/application/manifest_actions/chmod.rb
Instance Attribute Summary
Attributes inherited from Base
#app, #args, #manifest, #opts, #thor
Instance Method Summary
collapse
Methods inherited from Base
#args_and_opts, #exists?, #expand_dst, #expand_src, #initialize, #rel, #to_s
Instance Method Details
#destructive ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/configmonkey_cli/application/manifest_actions/chmod.rb', line 26
def destructive
if File.exist?(@path)
if @mode == File.stat(@path).mode - 0100000
status :identical, :blue, "#{@args[0]} (#{@args[1].to_s(8)})"
else
thor.chmod(@path, @mode)
end
else
status :noexist, :red, "#{@args[0]} (#{@args[1].to_s(8)})"
end
end
|
#init(path, mode, opts = {}) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/configmonkey_cli/application/manifest_actions/chmod.rb', line 5
def init path, mode, opts = {}
@opts = opts.reverse_merge({
})
@args = [path, mode]
end
|
#prepare ⇒ Object
13
14
15
16
|
# File 'lib/configmonkey_cli/application/manifest_actions/chmod.rb', line 13
def prepare
@path = expand_dst(@args[0])
@mode = @args[1]
end
|
#simulate ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/configmonkey_cli/application/manifest_actions/chmod.rb', line 18
def simulate
if thor.options[:pretend]
destructive
else
status :fake, :black, "#{@args[0]} (#{@args[1].to_s(8)})"
end
end
|