Class Webgen::Rake::WebgenTask
In: lib/webgen/rake/webgentask.rb
Parent: ::Rake::TaskLib
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

A Rake task that generates a webgen website.

It is assumed that you have already used the ‘webgen’ command to create the base directory for the site. This task is here to make it easier to integrate the generation of the website within the broader scope of another project.

Basics

  require 'webgen0.4/rake/webgentask'

  Webgen::Rake::WebgenTask.new do |t|
      t.directory = File.join(Dir.pwd, "webgen")
  end

Attributes

The attributes available to the task in the new block are:A

  • name - the name of the task. This can also be set as
                        a parameter to new (default :webgen)
    
  • directory - the root directory of the webgen site
                        (default File.join(Dir.pwd, "webgen")
    
  • clobber_outdir - remove webgens output directory on clobber
                        (default false)
    

Tasks Provided

The tasks provided are :

  • webgen - create the website
  • clobber_webgen - remove all the files created during creation

If the name attribute is changed then the tasks are changed to reflect that. For Example:

  Webgen::Rake::WebgenTask.new(:my_webgen) do |t|
      t.clobber_outdir = true
  end

This will create tasks:

  • my_webgen
  • clobber_my_webgen

Methods

define   new  

Attributes

clobber_outdir  [RW]  During the clobber, should webgen‘s output directory be clobbered. The default is false
directory  [RW]  The directory of the webgen site. This would be the directory of your config.yaml file. Or the parent directory of the src/ directory for webgen

The default for this is assumed to be

  File.join(Dir.pwd,"webgen")
name  [RW]  Name of webgen task. (default is :webgen)

Public Class methods

Create a webgen task

[Source]

     # File lib/webgen/rake/webgentask.rb, line 100
100:       def initialize(name = :webgen)
101:         @name           = name
102:         @directory      = File.join(Dir.pwd, "webgen")
103:         @clobber_outdir = false
104: 
105:         yield self if block_given?
106: 
107:         @rendered_files = FileList.new
108: 
109:         define
110:       end

Public Instance methods

[Source]

     # File lib/webgen/rake/webgentask.rb, line 112
112:       def define
113:         desc "Run webgen"
114:         task @name do |t|
115:           Dir.chdir(@directory) do
116:             begin
117:               # some items from webgen may be sensitive to the
118:               # current directory when it runs
119: 
120:               require 'webgen0.4/website'
121:               @website = Webgen::WebSite.new @directory
122:               @out_dir = File.expand_path(@website.param_for_plugin('Core/Configuration', 'outDir'))
123:               @website.render
124:               puts "Webgen rendered to : #{@out_dir}"
125: 
126:               file_list = @website.manager['Misc/RenderedFiles'].files
127: 
128:               # remove @out_dir from the list of rendered_files
129:               file_list.delete @out_dir
130: 
131:               @rendered_files << file_list
132:             rescue => e
133:               puts "Webgen task failed: #{e}"
134:               raise e
135:             end
136:           end
137:         end
138: 
139:         clobber_task = paste("clobber_",@name)
140: 
141:         # bit of conundrum here since we don't know what files
142:         # to remove until they have been generated, so we have
143:         # to generate all the files to remove them.
144:         #
145:         # I don't know of the right way to do this yet.
146:         desc "Remove webgen products"
147:         task clobber_task => [@name] do
148:           rm_rf @rendered_files
149:           if @clobber_outdir then
150:             rm_r @out_dir rescue nil
151:           end
152:         end
153: 
154:         task :clobber => [clobber_task]
155:         self
156:       end

[Validate]