class PFPuX
Public Class Methods
new(dir, target, msg='')
click to toggle source
# File lib/pfpux.rb, line 12 def initialize(dir, target, msg='') directories = rsync dir, target directories.each do |dirpath, files| dtx = DirToXML.new File.join(target, dirpath) files.each do |filename| row = dtx.find_by_filename filename next unless row row[:description] = msg end dtx.save end end
Private Instance Methods
rsync(dir, target)
click to toggle source
# File lib/pfpux.rb, line 36 def rsync(dir, target) h = {} Rsync.run(dir, target ,'-a --delete --exclude "dir.xml"') do |result| if result.success? result.changes.each do |change| puts ":: #{change.filename} (#{change.summary})" s = change.filename if s[-1] == '/' then curkey = s h.merge!(curkey => []) else curkey = File.dirname(s) h.merge!(curkey => []) unless h.has_key? curkey h[curkey] << File.basename(s) end end else puts result.error end end return h end