Guard::Toc

Toc guard will watch a folder for changes and add each of the files in the specified folder to a specified file as links... sort of like a table of contents, hence the name 'guard-toc'.

Install

You'll need Guard first.

Once you have guard, install this gem with

$ gem install guard-toc

Or add it to your Gemfile

gem 'guard-toc'    

Usage

Go see the Guard usage doc for general instructions

The Guardfile - where the magic happens

The Guardfile is where you define your desired input and output paths.

Create it with:

$ guard init toc

Then tweak the watch statements to your hearts content. It'll look a lot like this:

guard 'toc', :convert_on_start => true, :dry_run => true do
    # Will not convert while :dry_run is true. Once you're happy with your watch statements remove it
    watch (/source_dir\/(.+\/)*(.+\.)(html_or_other_extension)/i) {"input_dir|output_dir|output_file|path_to_optional_template.html.erb"}
end

The guard statement defines which guard your configuring and sets any optional parameters.

  • :convert_on_start - if true will run all conversions when you start the guard. Defaults to true
  • :dry_run - if true won't actually run the conversion process, but it will output the files being watched and the file it would write to. Use it to tweak your watch statements and when you're happy set it to false.

Have Fun

Go see the other great guards available

TODO

  • Test