Sha256: 7d96f6ae8233e40962887e7c2f9f824e386f048c01c8e3c9ceed5382da7f3987

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

module Katapult
  class TemplatesGenerator < Rails::Generators::Base

    desc 'Copy Katapult templates to the target application'
    source_root File.expand_path('..', __dir__) # lib/generators/katapult

    def copy_view_templates
      copy_generator_templates 'views', %w[
        _form.html.haml
        edit.html.haml
        index.html.haml
        new.html.haml
        show.html.haml
      ]
    end

    def copy_controller_template
      copy_generator_templates 'web_ui', 'controller.rb'
    end

    private

    # file_list should contain paths relative the the respective generator
    # template root
    def copy_generator_templates(generator_name, file_list)
      Array(file_list).each do |filename|
        source = File.join generator_name, 'templates', filename
        destination = File.join 'lib/templates/katapult', generator_name, filename

        copy_file source, destination
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katapult-0.5.0 lib/generators/katapult/templates/templates_generator.rb