# -*- ruby -*- # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'webgen/webgentask' require 'webgen/website' task :default => :webgen task :auto => :auto_webgen Webgen::WebgenTask.new do |website| website.clobber_outdir = true website.config_block = lambda do |config| # you can set configuration options here end end desc "Render the website automatically on changes" task :auto_webgen do puts 'Starting auto-render mode' time = Time.now abort = false old_paths = [] Signal.trap('INT') {abort = true} while !abort # you may need to adjust the glob so that all your sources are included paths = Dir['src/**/*'].sort if old_paths != paths || paths.any? {|p| File.mtime(p) > time} Rake::Task['webgen'].execute({}) end time = Time.now old_paths = paths sleep 2 end end