Class: Balmora::Command::File
Defined Under Namespace
Classes: Error
Class Method Summary
collapse
Instance Method Summary
collapse
#_execute, #execute, #initialize, #option
Class Method Details
.resolve_path(shell, source, storage, path) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/balmora/command/file.rb', line 5
def self.resolve_path(shell, source, storage, path)
if !source.nil?()
return shell.expand(source)
end
storage = shell.expand(storage)
if path.start_with?('~/')
result = ::File.join(storage, path[1..-1])
elsif path.start_with?('/')
result = ::File.join(storage, path[1..-1])
else
result = ::File.join(storage, path)
end
return result
end
|
Instance Method Details
#init ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/balmora/command/file.rb', line 23
def init()
super()
@action = @variables.inject(@action)
@file = @variables.inject(@file)
@source = @variables.inject(@source)
@storage = @variables.inject(@storage)
end
|
#options ⇒ Object
32
33
34
35
|
# File 'lib/balmora/command/file.rb', line 32
def options()
return super().concat([:file, :source, :storage, :action, :always,
:options])
end
|
#run ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/balmora/command/file.rb', line 37
def run()
if @always == true || _source_equals_to_target?()
return nil
end
_create_target_path()
_copy_file()
end
|
#verify ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/balmora/command/file.rb', line 46
def verify()
if @file.nil?()
raise Error.new('"file" should be defined')
end
if !@storage.nil?() && !@source.nil?()
raise Error.new('"storage" and "source" could not be defined together')
end
if @storage.nil?() && @source.nil?()
raise Error.new('"storage" or "source" should be defined')
end
if @action.nil?()
raise Error.new('"action" should be set')
end
if !['pull', 'push'].include?(@action)
Error.new("Unknown action #{@action.inspect()}")
end
end
|