class Dflat::Version::Full
Constants
- DATA_DIR
Public Class Methods
mkdir(path, integer = 0777, args = {})
click to toggle source
Calls superclass method
# File lib/dflat/version.rb, line 49 def self.mkdir path, integer = 0777, args = {} super path, integer d = Full.new path Dnatural::Dir.mkdir File.join(d.path, DATA_DIR) d end
Public Instance Methods
add(src, dest, options = {})
click to toggle source
# File lib/dflat/version.rb, line 60 def add src, dest, options = {} file = FileUtils.cp src, File.join(data_path, dest), options manifest! lock m = manifest.add dest, :base => data_path File.open(File.join(path, 'manifest.txt'), 'w') do |f| f.write(m.to_s) end unlock File.new File.join(data_path, dest) end
list()
click to toggle source
# File lib/dflat/version.rb, line 56 def list manifest.entries.map { |e| e.sourcefileorurl } end
remove(list, options = {})
click to toggle source
# File lib/dflat/version.rb, line 74 def remove list, options = {} list = [list] if list.instance_of? String FileUtils.rm list.map { |x| File.join(data_path, x) }, options m = manifest! lock list.each do |l| m = m.remove l end File.open(File.join(path, 'manifest.txt'), 'w') do |f| f.write(m.to_s) end unlock end
to_delta(version)
click to toggle source
# File lib/dflat/version.rb, line 90 def to_delta version redd = ReDD::Dir.mkdir File.join(self.path, Delta::DATA_DIR) delta = Delta.new self.path old = self.manifest.to_hash new = version.manifest.to_hash changeset = {:delete => [], :add => []} new.select do |filename, entry| changeset[:delete] << filename unless old[filename] and old[filename] == entry[filename] end old.select do |filename, entry| changeset[:add] << filename unless new[filename] and old[filename] == entry[filename] end changeset[:delete].each do |filename| delta.remove filename end changeset[:add].each do |filename| delta.add File.join(data_path, filename), filename end FileUtils.rm_rf data_path return delta end
Private Instance Methods
data_path()
click to toggle source
# File lib/dflat/version.rb, line 120 def data_path File.join(self.path, DATA_DIR) end
manifest_path()
click to toggle source
# File lib/dflat/version.rb, line 123 def manifest_path File.join(path, 'manifest.txt') end