Class: Drupid::Updater::MoveAction

Inherits:
AbstractAction show all
Defined in:
lib/drupid/updater.rb

Instance Attribute Summary

Attributes inherited from AbstractAction

#component, #platform

Instance Method Summary collapse

Methods inherited from AbstractAction

#pending?

Methods included from Drupid::Utils

#blah, #bzr, #compare_paths, #curl, #cvs, #debug, #dont_debug, #git, #hg, #ignore_interrupts, #interactive_shell, #odie, #ofail, #ohai, #owarn, #runBabyRun, #svn, #tempdir, #uncompress, #which, #writeFile

Constructor Details

#initialize(platform, component, new_path) ⇒ MoveAction

new_path must be relative to platform.local_path.



706
707
708
709
# File 'lib/drupid/updater.rb', line 706

def initialize(platform, component, new_path)
  super(platform, component)
  @destination = Pathname.new(new_path)
end

Instance Method Details

#fire!Object



711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
# File 'lib/drupid/updater.rb', line 711

def fire!
  if component.local_path.exist? # may have disappeared in the meantime (e.g., because of an update)
    dst = platform.local_path + @destination
    debug "Moving #{component.local_path} to #{dst}"
    if dst.exist?
      debug "#{dst} already exists, it will be deleted"
      dont_debug { dst.rmtree }
    end
    dont_debug { dst.parent.mkpath }
    dont_debug { FileUtils.mv component.local_path.to_s, dst.to_s }
  else
    blah "Cannot move #{component.local_path.relative_path_from(platform.local_path)}\n" +
      "(It does not exist any longer)"
  end
  @pending = false
end

#msgObject



728
729
730
731
# File 'lib/drupid/updater.rb', line 728

def msg
  src = component.local_path.relative_path_from(platform.local_path)
  "#{Tty.blue}[Move]#{Tty.white}    #{component.extended_name}:#{Tty.reset} #{src} => #{@destination}"
end