module Padrino::Generators

This module it’s used for register generators.

Can be useful for 3rd party generators:

# custom_generator.rb
class CustomGenerator < Thor::Group
  Padrino::Generators.add_generator(:custom_generator, self)
end

Now for handle generators in padrino you need to add it to into load_paths.

::load_paths << “custom_generator.rb”

Constants

DEFAULT_HELPER_NAME

Default helper name for use in tiny app skeleton generator.

DEV_PATH

Defines the absolute path to the padrino source folder.

Public Class Methods

add_generator(name, klass) click to toggle source

Global add a new generator class to padrino-gen.

@param [Symbol] name

Key name for generator mapping.

@param [Class] klass

Class of generator.

@return [Hash] generator mappings

@example

Padrino::Generators.add_generator(:controller, Controller)
# File lib/padrino-gen.rb, line 53
def add_generator(name, klass)
  mappings[name] = klass
end
load_components!() click to toggle source

Load Global Actions and Component Actions then all files in load_path.

# File lib/padrino-gen.rb, line 60
def load_components!
  require 'padrino-gen/generators/actions'
  require 'padrino-gen/generators/components/actions'
  require 'padrino-gen/generators/runner'
  load_paths.flatten.each { |file| require file  }
end
load_paths() click to toggle source

Store our generators paths.

# File lib/padrino-gen.rb, line 29
def load_paths
  @_files ||= []
end
mappings() click to toggle source

Return an ordered list of task with their class.

# File lib/padrino-gen.rb, line 36
def mappings
  @_mappings ||= {}
end