class CFBundle::Storage::FileSystem

A bundle storage that reads from the file system.

Public Class Methods

new(path) click to toggle source

@param path [String] The path of the bundle on the file system.

# File lib/cfbundle/storage/file_system.rb, line 9
def initialize(path)
  @root = path
end

Public Instance Methods

directory?(path) click to toggle source

(see Base#directory?)

# File lib/cfbundle/storage/file_system.rb, line 25
def directory?(path)
  entry = find(path)
  !entry.nil? && File.directory?(entry)
end
exist?(path) click to toggle source

(see Base#exist?)

# File lib/cfbundle/storage/file_system.rb, line 14
def exist?(path)
  find(path) != nil
end
file?(path) click to toggle source

(see Base#file?)

# File lib/cfbundle/storage/file_system.rb, line 19
def file?(path)
  entry = find(path)
  !entry.nil? && File.file?(entry)
end
foreach(path) click to toggle source

(see Base#foreach)

# File lib/cfbundle/storage/file_system.rb, line 36
def foreach(path)
  Enumerator.new do |y|
    base = Dir.entries(find!(path)).sort.each
    loop do
      entry = base.next
      y << PathUtils.join(path, entry) unless ['.', '..'].include?(entry)
    end
  end
end
open(path, &block) click to toggle source

(see Base#open)

# File lib/cfbundle/storage/file_system.rb, line 31
def open(path, &block)
  File.open find!(path), &block
end

Private Instance Methods

find(path) click to toggle source
# File lib/cfbundle/storage/file_system.rb, line 48
def find(path)
  entry = PathUtils.join(@root, path)
  entry if File.exist? entry
end
find!(path) click to toggle source
# File lib/cfbundle/storage/file_system.rb, line 53
def find!(path)
  find(path) || raise(Errno::ENOENT, path)
end