Parent

Methods

Class/Module Index [+]

Quicksearch

Fog::Storage::Local::Files

Public Instance Methods

all() click to toggle source
# File lib/fog/local/models/storage/files.rb, line 12
def all
  requires :directory
  if directory.collection.get(directory.key)
    data = []
    Dir.chdir(service.path_to(directory.key)) {
      data = Dir.glob('**/*').reject do |file|
        ::File.directory?(file)
      end.map do |key|
        path = file_path(key)
        {
          :content_length => ::File.size(path),
          :key            => key,
          :last_modified  => ::File.mtime(path)
        }
      end
    }
    load(data)
  else
    nil
  end
end
get(key, &block) click to toggle source
# File lib/fog/local/models/storage/files.rb, line 34
def get(key, &block)
  requires :directory
  path = file_path(key)
  if ::File.exist?(path)
    data = {
      :content_length => ::File.size(path),
      :key            => key,
      :last_modified  => ::File.mtime(path)
    }
    if block_given?
      file = ::File.open(path)
      while (chunk = file.read(Excon::CHUNK_SIZE)) && yield(chunk); end
      file.close
      new(data)
    else
      body = ::File.read(path)
      new(data.merge!(:body => body))
    end
  else
    nil
  end
end
head(key) click to toggle source
# File lib/fog/local/models/storage/files.rb, line 57
def head(key)
  requires :directory
  path = file_path(key)
  if ::File.exist?(path)
    new({
      :content_length => ::File.size(path),
      :key            => key,
      :last_modified  => ::File.mtime(path)
    })
  else
    nil
  end
end
new(attributes = {}) click to toggle source
# File lib/fog/local/models/storage/files.rb, line 71
def new(attributes = {})
  requires :directory
  super({ :directory => directory }.merge!(attributes))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.