Sha256: 0c51c5fa038f366c2b421cf9acf79046b137afbdef799a26325528edb68f0249

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 Bytes

Contents

# The katapult generator base class, slightly adapted from Rails generators.

require 'rails/generators'

module Katapult
  class Generator < Rails::Generators::NamedBase

    attr_accessor :element

    def initialize(element)
      self.element = element

      super([element.name], {}, {}) # args, opts, config
    end

    private

    def app_name
      File.basename(Dir.pwd)
    end

    def render_partial(template_path, given_binding = nil)
      path = File.join(self.class.source_root, template_path)
      ERB.new(::File.binread(path), nil, '%').result(given_binding || binding)
    end

    def run(*)
      Bundler.with_clean_env do
        super
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katapult-0.2.0 lib/katapult/generator.rb