class SSC::DirectoryManager::FileListFile

Public Class Methods

new(path= nil) click to toggle source
# File lib/directory_manager.rb, line 74
def initialize(path= nil)
  super("files/.file_list", path)
end

Public Instance Methods

initiate_file(path, options) click to toggle source
# File lib/directory_manager.rb, line 89
def initiate_file(path, options)
  raise "Unknown file #{path}" unless File.exists?(path)
  file_path, file_name= File.split(path)
  file_path ||= options[:path]
  destination_path= File.join(File.split(@location)[0], file_name)
  FileUtils.cp(path, destination_path)
  if options[:id]
    push("list", {file_name => {
      "id" => options[:id],
      "path" => file_path }})
  else
    file_params= options.slice(:permissions, :group, :owner).merge(:path => file_path)
    push("add", {file_name => file_params})
  end
  destination_path
end
is_uploaded?(file_name) click to toggle source
# File lib/directory_manager.rb, line 106
def is_uploaded?(file_name)
  read
  list= @parsed_file["list"].select{|i| i.keys[0] == file_name}
  list[0][file_name]["id"] if list.length > 0 
end
pop(section) click to toggle source
# File lib/directory_manager.rb, line 78
def pop(section)
  file_hash= super(section)
  if file_hash
    file_name= file_hash.keys[0]
    file_hash= file_hash[file_name]
    { :name      => file_name,
      :full_path => File.join(file_hash["path"]),
      :params    => file_hash.slice("owner", "group", "permissions")}
  end
end