class Overapp::Files

Public Instance Methods

add(ops) click to toggle source
# File lib/overapp/files.rb, line 16
def add(ops)
  ops = file_class.new(:path => ops[:file], :full_body => ops[:body]) if ops.kind_of?(Hash)
  self.files[ops.path] = ops
end
apply(on_top,ops={}) click to toggle source
# File lib/overapp/files.rb, line 28
def apply(on_top,ops={})
  res = self.class.new(:files => files.clone)
  on_top.each do |top_file|
    res.apply_file(top_file,ops)
  end
  res
end
apply_file(top_file,ops={}) click to toggle source
# File lib/overapp/files.rb, line 36
def apply_file(top_file,ops={})
  if ops[:vars] && ops[:vars].size > 0
    top_file.vars = ops[:vars]
  end
  existing = files[top_file.path]
  raise MissingBaseFileError.new(:top_file => top_file, :base => self) if !existing && top_file.has_note?
  new_file = top_file.combined(existing)
  if new_file
    add new_file
  else
    delete top_file.path
  end
end
delete(path) click to toggle source
# File lib/overapp/files.rb, line 20
def delete(path)
  self.files.delete(path)
end
each(&b) click to toggle source
# File lib/overapp/files.rb, line 51
def each(&b)
  files.values.each(&b)
end
size() click to toggle source
# File lib/overapp/files.rb, line 24
def size
  files.size
end
with_tmp(&b) click to toggle source
# File lib/overapp/files.rb, line 62
def with_tmp(&b)
  Overapp::TmpDir.with do |dir|
    write_to! dir
    b[dir]
  end
end
write_to!(dir) click to toggle source
# File lib/overapp/files.rb, line 55
def write_to!(dir)
  each do |f|
    f.write_to! dir
  end
  self
end