Class: SimpleTemplater

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-templater/generator.rb,
lib/simple-templater/discoverer.rb,
lib/simple-templater/hooks/hook.rb,
lib/simple-templater/argv_parsing.rb,
lib/simple-templater/generator_set.rb,
lib/simple-templater/discoverers/gems.rb

Overview

This provides a hook system which programs that use Templater can use to discover generators installed through gems. This requires two separate things, the Templater-using progrma will have to call the #discover! method giving a scope, like this:

Templater::Discovery.discover!("name-of-scope")

Where “name-of-scope” should be a string that uniquely identifies your program. Any gem wishing to then add a generator, that is automatically picked up, will then need to add a simple-templater.scope file at the root of the project (don’t forget to add it to the gem’s manifest of files).

- lib /
- spec /
- Rakefile
- simple-templater.scope

This file should look something like this:

SimpleTemplater.scope(:rango) do
  root = File.dirname(__FILE__)
  Dir["#{root}/stubs/*"].each do |stub_dir|
    if File.directory?(stub_dir)
      SimpleTemplater.register(:rango, stub_dir)
    end
  end
end

Multiple scopes can be added to the same simple-templater.scope file for use with different generator programs.

Defined Under Namespace

Modules: ArgvParsingMixin, Hooks Classes: Discoverer, Generator, GeneratorSet, RubyGems