Class: Robocopy
- Inherits:
-
Object
- Object
- Robocopy
- Includes:
- Logging, RunCommand, YAMLConfig
- Defined in:
- lib/seabass/robocopy.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#directories ⇒ Object
Returns the value of attribute directories.
-
#files ⇒ Object
Returns the value of attribute files.
-
#mirror ⇒ Object
Returns the value of attribute mirror.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(env = @@env, executor = Executor.new) ⇒ Robocopy
constructor
A new instance of Robocopy.
Constructor Details
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
8 9 10 |
# File 'lib/seabass/robocopy.rb', line 8 def destination @destination end |
#directories ⇒ Object
Returns the value of attribute directories.
8 9 10 |
# File 'lib/seabass/robocopy.rb', line 8 def directories @directories end |
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/seabass/robocopy.rb', line 8 def files @files end |
#mirror ⇒ Object
Returns the value of attribute mirror.
8 9 10 |
# File 'lib/seabass/robocopy.rb', line 8 def mirror @mirror end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/seabass/robocopy.rb', line 18 def execute() raise "No files or directories were specified" if @files.length == 0 and @directories.length == 0 raise "Destination folder was not specified" if @destination.nil? copy = lambda { |type, collection| collection.each do |f| command = "#{@env.tools.robocopy} " + case type when 'file' then file_command(f, @destination) when 'directory' then directory_command(f, @destination) else raise "Unknown copy type" end command += " /MIR" if @mirror Log.("Copying #{f} #{destination}; #{command}", :info) @executor.run(command) end } copy.call('file', @files) copy.call('directory', @directories) end |