Class: CFBundle::Storage::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cfbundle/storage/base.rb

Overview

The Base class defines the methods required to access a bundle’s underlying storage.

Most of the time, you don’t need to concern youself with storages as Bundle.open and Bundle#initialize automatically detect and instantiate the appropriate storage.

Direct Known Subclasses

FileSystem, Zip

Instance Method Summary collapse

Instance Method Details

#closevoid

This method returns an undefined value.

Invoked when the storage is no longer needed.

The default implementation does nothing.



66
# File 'lib/cfbundle/storage/base.rb', line 66

def close; end

#directory?(path) ⇒ Boolean

Returns whether a given directory exists within the storage.

Parameters:

  • path (String)

    The path of a directory, relative to the storage.

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/cfbundle/storage/base.rb', line 32

def directory?(path)
  # :nocov:
  false
  # :nocov:
end

#exist?(path) ⇒ Boolean

Returns whether a given path exists within the storage.

Parameters:

  • path (String)

    The path of a file or directory, relative to the storage.

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/cfbundle/storage/base.rb', line 14

def exist?(path)
  # :nocov:
  false
  # :nocov:
end

#file?(path) ⇒ Boolean

Returns whether a given file exists within the storage.

Parameters:

  • path (String)

    The path of a file, relative to the storage.

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/cfbundle/storage/base.rb', line 23

def file?(path)
  # :nocov:
  false
  # :nocov:
end

#foreach(path) ⇒ Enumerator

Returns an enumerator that enumerates the files contained in a directory.

Parameters:

  • path (String)

    The path to the directory to enumerate.

Returns:

  • (Enumerator)

Raises:

  • (Errno::ENOENT)


56
57
58
59
60
# File 'lib/cfbundle/storage/base.rb', line 56

def foreach(path)
  # :nocov:
  raise(Errno::ENOENT, path)
  # :nocov:
end

#open(path) {|file| ... } ⇒ Object, IO

Opens a file for reading in the storage.

Parameters:

  • path (String)

    The path of the file to open.

Yield Parameters:

  • file (IO)

    The opened file. It is automatically closed when the block terminates.

Returns:

  • (Object)

    The return value of the block when a block if given.

  • (IO)

    The opened file when no block is given.

Raises:

  • (Errno::ENOENT)


45
46
47
48
49
# File 'lib/cfbundle/storage/base.rb', line 45

def open(path, &block)
  # :nocov:
  raise(Errno::ENOENT, path)
  # :nocov:
end