Class: Webgen::WebgenTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Webgen::WebgenTask
- Defined in:
- lib/webgen/webgentask.rb
Overview
Task library to manage a webgen website.
It is assumed that you have already used the ‘webgen’ command to create the website directory for the site.
Basics
require 'webgen/webgentask'
Webgen::WebgenTask.new
Attributes
The attributes available in the new block are:
-
directory - the root directory of the webgen site
(default Dir.pwd) -
config - the config block for setting additional configuration options
-
clobber_outdir - remove webgens output directory on clobber
(default false)
Tasks Provided
The tasks provided are :
-
webgen - render the webgen website
-
clobber_webgen - remove all the files created during generation
Integrate webgen in other project
To integrate webgen tasks in another project you can use rake namespaces. For example assuming webgen’s site directory is webgen under the main project directory use the following code fragment in project Rakefile:
require 'webgen/webgentask'
namespace :dev do
Webgen::WebgenTask.new do |site|
site.directory = File.join(Dir.pwd, "webgen")
site.clobber_outdir = true
site.config_block = lambda |config|
config['website.lang'] = 'de'
end
end
end
task :clobber => ['dev:clobber_webgen']
This will create the following tasks:
-
dev:webgen
-
dev:clobber_webgen
and add dev:clobber_webgen to the main clobber task.
Instance Attribute Summary collapse
-
#clobber_outdir ⇒ Object
During the clobber, should webgen’s output directory be clobbered.
-
#config_block ⇒ Object
The configuration block that is invoked when the Webgen::Website object is initialized.
-
#directory ⇒ Object
The directory of the webgen website.
Instance Method Summary collapse
-
#initialize(name = 'webgen') {|_self| ... } ⇒ WebgenTask
constructor
Create webgen tasks.
Constructor Details
#initialize(name = 'webgen') {|_self| ... } ⇒ WebgenTask
Create webgen tasks. You can override the task name with the parameter name.
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/webgen/webgentask.rb', line 110 def initialize(name = 'webgen') @name = name @directory = Dir.pwd @clobber_outdir = false @config_block = nil yield self if block_given? define end |
Instance Attribute Details
#clobber_outdir ⇒ Object
During the clobber, should webgen’s output directory be clobbered. The default is false.
107 108 109 |
# File 'lib/webgen/webgentask.rb', line 107 def clobber_outdir @clobber_outdir end |
#config_block ⇒ Object
The configuration block that is invoked when the Webgen::Website object is initialized. This can be used to set configuration parameters and to avoid having a config.yaml file lying around.
104 105 106 |
# File 'lib/webgen/webgentask.rb', line 104 def config_block @config_block end |
#directory ⇒ Object
The directory of the webgen website. 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
Dir.pwd
99 100 101 |
# File 'lib/webgen/webgentask.rb', line 99 def directory @directory end |