Module: Webgen::Output

Defined in:
lib/webgen/output.rb,
lib/webgen/output/filesystem.rb

Overview

Namespace for all classes that know how to write out node content.

Implementing an output class

Output classes know how to write rendered node data to an output location.

An output class must respond to three methods

exists?(path)

Return true if the output path exists.

delete(path)

Delete the given output path.

write(path, data, type)

Write the data to the given output path. The parameter type specifies the type of the to be written path: :file or :directory.

read(path):

Return the content of the given path if it exists or raise an error otherwise.

Defined Under Namespace

Classes: FileSystem

Class Method Summary collapse

Class Method Details

.instanceObject

Returns an instance of the configured output class.


28
29
30
31
32
33
34
35
# File 'lib/webgen/output.rb', line 28

def self.instance
  classes = (WebsiteAccess.website.cache.volatile[:classes] ||= {})
  unless classes.has_key?(:output_instance)
    klass, *args = WebsiteAccess.website.config['output']
    classes[:output_instance] = Object.constant(klass).new(*args)
  end
  classes[:output_instance]
end