Sha256: 2ed6920f77025b21d4f6d3ca5b154c9ed2937067465a5c27a3ef74ee54edf252

Contents?: true

Size: 889 Bytes

Versions: 10

Compression:

Stored size: 889 Bytes

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.alcn, dir, '/'), path)
        nodes = website.blackboard.invoke(:create_nodes, dir_path, self) do |dir_path|
          node_exists?(dir_path) || create_node(dir_path)
        end
        parent = nodes.first
      end
      parent
    end

  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.9.20090620 lib/webgen/sourcehandler/directory.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/sourcehandler/directory.rb
webgen-0.5.17 lib/webgen/sourcehandler/directory.rb
webgen-0.5.15 lib/webgen/sourcehandler/directory.rb
webgen-0.5.14 lib/webgen/sourcehandler/directory.rb
webgen-0.5.13 lib/webgen/sourcehandler/directory.rb
webgen-0.5.12 lib/webgen/sourcehandler/directory.rb
webgen-0.5.11 lib/webgen/sourcehandler/directory.rb
webgen-0.5.10 lib/webgen/sourcehandler/directory.rb
webgen-0.5.9 lib/webgen/sourcehandler/directory.rb