Sha256: 1665c2cdd0acd9b328d93b102b822a83ace95256fde9cddf450dcfe329fee489

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'hanami/generators/generator'

module Hanami
  module Generators
    module Generatable

      def start
        map_templates
        process_templates
      end

      def destroy
        generator.behavior = :revoke
        self
      end

      def generator
        @generator ||= Hanami::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

4 entries across 4 versions & 1 rubygems

Version Path
hanami-0.7.3 lib/hanami/generators/generatable.rb
hanami-0.7.2 lib/hanami/generators/generatable.rb
hanami-0.7.1 lib/hanami/generators/generatable.rb
hanami-0.7.0 lib/hanami/generators/generatable.rb