Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Watches a specified folder of html files for changes and creates a table of contents (html) file containing links to all the files in the specified directory
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/guard
.gitignore
Gemfile
LICENSE
README.md
Rakefile
guard-toc.gemspec

README.md

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

Screenshot

Here is an images of how the html output files could appear:

Something went wrong with that request. Please try again.