Module: FileCrawler::Finder::Command::Move

Included in:
FileCrawler::Finder
Defined in:
lib/file_crawler/finder/command/move.rb

Defined Under Namespace

Classes: Fixer

Instance Method Summary collapse

Instance Method Details

#cmdsObject



21
22
23
24
25
26
# File 'lib/file_crawler/finder/command/move.rb', line 21

def cmds
  return nil if @targets.nil?

  fixer = Fixer.new
  fixer.make_mv(@targets)
end

#move(destination, options = {dry_run: true}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/file_crawler/finder/command/move.rb', line 7

def move(destination, options={dry_run: true})
  tap {
    target = @collections.empty? ? @files : @collections
    fixer = Fixer.new
    @targets = fixer.make_new_path(target, destination)

    if !options[:dry_run]
      fixer.make_mv(@targets).each {|cmd|
        exec(cmd)
      }
    end
  }
end