Sha256: 7875e4f27b0f4b40018c102e2079526bb82df4341f6340bc35100152cc47c718

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'lotus/generators/generator'

module Lotus
  module Generators
    module Generatable

      def start
        map_templates
        process_templates
      end

      def destroy
        generator.behavior = :revoke
        self
      end

      def generator
        @generator ||= Lotus::Generators::Generator.new(template_source_path, target_path)
      end

      def map_templates
        raise NotImplementedError, "must implement the map_templates method"
      end

      def add_mapping(source, target)
        generator.add_mapping(source, target)
      end

      def process_templates
        generator.process_templates(template_options)
        post_process_templates
      end

      def post_process_templates
        nil
      end

      def template_options
        {}
      end

      def template_source_path
        raise NotImplementedError, "must implement the template_source_path method"
      end

      def target_path
        raise NotImplementedError, "must implement the target_path method"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lotusrb-0.6.1 lib/lotus/generators/generatable.rb
lotusrb-0.6.0 lib/lotus/generators/generatable.rb