Class: ConfigmonkeyCli::Application::ManifestAction::Link
- Inherits:
-
Base
- Object
- Base
- ConfigmonkeyCli::Application::ManifestAction::Link
show all
- Defined in:
- lib/configmonkey_cli/application/manifest_actions/link.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
40
41
42
|
# File 'lib/configmonkey_cli/application/manifest_actions/link.rb', line 40
def destructive
thor.create_link(@destination, @source, @opts)
end
|
#init(hargs_and_opts = {}) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/configmonkey_cli/application/manifest_actions/link.rb', line 5
def init hargs_and_opts = {}
@args, @opts = args_and_opts(hargs_and_opts)
@opts = @opts.reverse_merge({
prefix: nil,
map: "d:d",
hard: false,
})
end
|
#prepare ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/configmonkey_cli/application/manifest_actions/link.rb', line 14
def prepare
@opts[:force] = app.opts[:default_yes]
@opts[:symbolic] = !@opts[:hard]
@source = @args[0]
@destination = @args[1]
map = @opts[:map].split(":")
@source = File.join(map[0]["d"] ? thor.destination_root : manifest.directory, @source)
@destination = File.join(map[1]["d"] ? thor.destination_root : manifest.directory, @destination)
if(@opts[:prefix] && map[1].downcase["p"])
prefix = "cm--#{manifest.checksum(@opts[:prefix], soft: !map[1]["H"])}--"
@destination = File.join(File.dirname(@destination), "#{prefix}#{File.basename(@destination)}")
end
end
|
#simulate ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/configmonkey_cli/application/manifest_actions/link.rb', line 32
def simulate
if thor.options[:pretend]
destructive
else
status :fake, :black, rel(@destination)
end
end
|