X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=build.rb;h=7a1664784b009e3250713c2db4a1005c11d00893;hb=5b49dc530e446f2f6afbb68f9949edf20ad7bda3;hp=4afd7d1e6ce9df39cbc5d39e02cbe2fa67e97843;hpb=6a0e2acebdf4bb70c77ac562ce73d963f03e0754;p=ardour-manual diff --git a/build.rb b/build.rb old mode 100644 new mode 100755 index 4afd7d1..7a16647 --- a/build.rb +++ b/build.rb @@ -1,14 +1,20 @@ +#!/usr/bin/env ruby + require 'pathname' -require 'fileutils' require 'yaml' -require 'liquid' require 'optparse' +begin require 'liquid' +rescue LoadError + puts "Please install the 'liquid' Ruby gem (available in Debian/Ubuntu as 'ruby-liquid')" + exit 1 +end + CONFIG = { pages_dir: '_manual', layouts_dir: '_layouts', static_dir: 'source', - output_dir: '_site' # will get wiped! + output_dir: '_site' } def child_url?(a, b) @@ -58,7 +64,9 @@ class Site end def copy_static() - `rsync -a --delete --exclude='*~' #{static_dir}/. #{output_dir}` + unless system("rsync -a --delete --exclude='*~' #{static_dir}/. #{output_dir}") + puts "Couldn't copy static files, is rsync installed?" + end end def find_children(url) @@ -89,7 +97,7 @@ class Page s = a.join('/') @out_path = @site.output_dir + Pathname(s) + Pathname("index.html") - @url = "/#s/" + @url = "/#{s}/" @sort_url = @path.to_s.sub(/\.html$/, '') end @@ -218,7 +226,12 @@ end class Server def start_watcher() - require 'listen' + begin require 'listen' + rescue LoadError + puts "To use the --watch function, please install the 'listen' Ruby gem" + puts "(available in Debian/Ubuntu as 'ruby-listen')" + return nil + end listener = Listen.to(CONFIG[:pages_dir], wait_for_delay: 1.0, only: /.html$/) do |modified, added, removed| Site.new.build @@ -252,6 +265,11 @@ def main options = {} OptionParser.new do |opts| + opts.banner = %{Usage: build.rb [options] + +Use 'build.rb' to build the manual. Use 'build.rb serve' to also +start a web server. Options: +} opts.on("--watch", "Watch for changes") { options[:watch] = true } end.parse!