Sha256: ea976eecc012e2b7b1d2ff85d8fd94357a9c509df98dd3fc20157f4b9e84938f

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# -*- encoding: utf-8 -*-

module Webgen::SourceHandler

  # Handles directory source paths.
  class Directory

    include Base
    include Webgen::WebsiteAccess

    def initialize # :nodoc:
      website.blackboard.add_service(:create_directories, method(:create_directories))
    end

    # Recursively create the directories specified in +dirname+ under +parent+ (a leading slash is
    # ignored). The path +path+ is the path that lead to the creation of these directories.
    def create_directories(parent, dirname, path)
      dirname.sub(/^\//, '').split('/').each do |dir|
        dir_path = Webgen::Path.new(File.join(parent.absolute_lcn, dir, '/'), path)
        nodes = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
                                           dir_path, self) do |dir_parent, dir_path|
          node_exists?(dir_parent, dir_path) || create_node(dir_parent, dir_path)
        end
        parent = nodes.first
      end
      parent
    end

    # Return an empty string to signal that the directory should be written to the output.
    def content(node)
      ''
    end

  end

end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/sourcehandler/directory.rb
gettalong-webgen-0.5.8.20090507 lib/webgen/sourcehandler/directory.rb
thewoolleyman-webgen-0.5.8.20090419 lib/webgen/sourcehandler/directory.rb
webgen-0.5.7 lib/webgen/sourcehandler/directory.rb
webgen-0.5.8 lib/webgen/sourcehandler/directory.rb