Class: Rake::WebbyTask
- Inherits:
-
TaskLib
- Object
- TaskLib
- Rake::WebbyTask
- Defined in:
- lib/webby/webby_task.rb
Overview
The WebbyTask defines several rake tasks for working with Webby based websites:
- :build
-
Build the site by compiling only those resources in the content folder that have been modifed recently. If the a content file has a modification time more recent then its corresponding output file, then it will be built by this task.
- :rebuild
-
Rebuild the entire site from the content folder and store the results in the output folder.
- :autobuild
-
Monitors the content and layout directories for modified resources and compiles those files as needed. This task returns only when the user hits Ctrl-C.
- :create:page
-
Create a new page in the content folder based on the template ‘page’ found in the templates folder. One task will be created for each file found in the templates folder.
Instance Method Summary collapse
-
#define_build_tasks ⇒ Object
Defines the :build and :rebuild tasks.
-
#define_create_tasks ⇒ Object
Scans the templates directory for any files, and creats a corresponding task for creating a new page based on that template.
-
#initialize {|_self| ... } ⇒ WebbyTask
constructor
call-seq: WebbyTask.new {|self| block}.
Constructor Details
#initialize {|_self| ... } ⇒ WebbyTask
call-seq:
WebbyTask.new {|self| block}
Create the tasks used by Webby to build a website and to create new pages in the website.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/webby/webby_task.rb', line 42 def initialize yield self if block_given? # load any user defined libraries glob = ::File.join(FileUtils.pwd, 'lib', '**', '*.rb') Dir.glob(glob).sort.each {|fn| require fn} # create the Webby rake tasks define_build_tasks namespace(:create) {define_create_tasks} end |
Instance Method Details
#define_build_tasks ⇒ Object
Defines the :build and :rebuild tasks
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/webby/webby_task.rb', line 56 def define_build_tasks task :configure_basepath do ::Webby.site.base = ENV['BASE'] if ENV.has_key?('BASE') end desc "build the website" task :build => :configure_basepath do |t| ::Webby::Builder.run end desc "rebuild the website" task :rebuild => :configure_basepath do |t| ::Webby::Builder.run :rebuild => true end desc "continuously build the website" task :autobuild => :configure_basepath do |t| ::Webby::AutoBuilder.run end desc "delete the website" task :clobber do |t| rm_rf ::Webby.site.output_dir mkdir ::Webby.site.output_dir end end |
#define_create_tasks ⇒ Object
Scans the templates directory for any files, and creats a corresponding task for creating a new page based on that template.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/webby/webby_task.rb', line 86 def define_create_tasks FileList["#{::Webby.site.template_dir}/*"].each do |template| name = template.pathmap '%n' desc "create a new #{name}" task name do |t| raise "Usage: rake #{t.name} path" unless ARGV.length == 2 page = t.application.top_level_tasks.pop name = ::Webby::File.basename(page) ext = ::Webby::File.extname(page) dir = ::Webby::File.dirname(page) if ::Webby.site.create_mode == 'directory' page = ::File.join(::Webby.site.content_dir, name, 'index') page << '.' << (ext.empty? ? 'txt' : ext) else page = ::File.join(::Webby.site.content_dir, page) page << '.txt' if ext.empty? end ::Webby::Builder.create page, :from => template end # task end # each end |