10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/consist/commands/check.rb', line 10
def perform!(executor)
status = @command[:status]
flag, val = if @command.has_key?(:path) && !@command[:path].nil?
["d", @command[:path]]
else
["f", @command[:file]]
end
exists = executor.test("[ -#{flag} #{val} ]")
if status == :exist && !exists
@command[:block].call
elsif status == :nonexistant && !exists
@command[:block].call
else
tense = if status == :exist
"should"
elsif status == :nonexistant
"shoudlnt"
end
puts "Checking path `#{status}` - `#{val}` - #{exists ? "exists" : "doesn't exist"} and #{tense} - skipping"
end
end
|