Sha256: 0437787664998cf13636822d02b14d2528290d1b0092d9a800d7465cdc7dfcf4

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 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

      def argument_blank?(value)
        Hanami::Utils::Blank.blank?(value)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-1.0.0.beta2 lib/hanami/generators/generatable.rb
hanami-1.0.0.beta1 lib/hanami/generators/generatable.rb
hanami-0.9.2 lib/hanami/generators/generatable.rb
hanami-0.9.1 lib/hanami/generators/generatable.rb
hanami-0.9.0 lib/hanami/generators/generatable.rb
hanami-0.8.0 lib/hanami/generators/generatable.rb