Class Webgen::DirectoryInfo
In: lib/webgen/website.rb
Parent: Object
RuntimeError PluginParamNotFound PluginNotFound ConfigurationFileInvalid CmdParse::CommandParser CommandParser DirectoryInfo GalleryStyle WebSiteStyle WebSiteTemplate SipttraStyle Test::Unit::TestCase TestCase PluginTestCase TagTestCase CmdParse::Command ShowCommand CheckCommand UseCommand CreateCommand TSort DependencyHash Hash Comparable Language DEFAULT_WRAPPER_MODULE WebSite ::Logger Logger Logger Qt::MainWindow MainWindow Qt::Dialog NewWebsiteDialog Qt::TextEdit LogWidget ::Rake::TaskLib WebgenTask ConfigurationFile Website PluginManager PluginLoader PluginParamValueNotFound Dummy Color CliUtils PluginDefs lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/gui/common.rb lib/webgen/plugin.rb lib/webgen/test.rb lib/webgen/cli.rb ClassMethods PluginDefs LanguageManager lib/webgen/gui/new_website_dlg.rb lib/webgen/gui/main.rb GUI lib/webgen/rake/webgentask.rb Rake Webgen dot/m_60_0.png

Base class for directories which have a README file with information stored in YAML format. Should not be used directly, use its child classes!

Methods

copy_to   entries   files   new   path  

Attributes

infos  [R]  Contains additional information, like a description or the creator.
name  [R]  The unique name.

Public Class methods

Returns all available entries.

[Source]

    # File lib/webgen/website.rb, line 76
76:     def self.entries
77:       unless defined?( @entries )
78:         @entries = {}
79:         Dir.glob( File.join( self::BASE_PATH, '*' ), File::FNM_CASEFOLD ).each do |f|
80:           next unless File.directory?( f )
81:           name = File.basename( f );
82:           @entries[name] = self.new( name )
83:         end
84:       end
85:       @entries
86:     end

Returns a new object for the given name.

[Source]

    # File lib/webgen/website.rb, line 43
43:     def initialize( name )
44:       @name = name
45:       raise ArgumentError.new( "'#{name}' is not a directory!" ) if !File.directory?( path )
46:       @infos = YAML::load( File.read( File.join( path, 'README' ) ) )
47:       raise ArgumentError.new( "'#{name}/README' does not contain key-value pairs in YAML format!" ) unless @infos.kind_of?( Hash )
48:     end

Public Instance methods

Copies the files returned by +files+ into the directory dest, preserving the directory hierarchy.

[Source]

    # File lib/webgen/website.rb, line 62
62:     def copy_to( dest )
63:       files.collect do |file|
64:         destpath = File.join( dest, File.dirname( file ).sub( /^#{path}/, '' ) )
65:         FileUtils.mkdir_p( File.dirname( destpath ) )
66:         if File.directory?( file )
67:           FileUtils.mkdir_p( File.join( destpath, File.basename( file ) ) )
68:         else
69:           FileUtils.cp( file, destpath )
70:         end
71:         File.join( destpath, File.basename( file ) )
72:       end
73:     end

The files under the directory.

[Source]

    # File lib/webgen/website.rb, line 56
56:     def files
57:       Dir.glob( File.join( path, '**', '*' ), File::FNM_CASEFOLD )
58:     end

The absolute directory path. Requires that child classes have defined a constant BASE_PATH.

[Source]

    # File lib/webgen/website.rb, line 51
51:     def path
52:       File.expand_path( File.join( self.class::BASE_PATH, name ) )
53:     end

[Validate]