Sha256: ba59f1fc31ee80e0f7f35cca195fcc2eaa1598331ab63a07de5a76e816b911c7

Contents?: true

Size: 1.7 KB

Versions: 6

Compression:

Stored size: 1.7 KB

Contents

require 'padrino-core/support_lite'
require 'padrino-core/tasks'

module Padrino
  ##
  # 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+
  # 
  # Padrino::Generators.load_paths << "custom_generator.rb"
  # 
  module Generators

    DEV_PATH = File.expand_path("../../", File.dirname(__FILE__))

    class << self

      ##
      # Here we store our generators paths
      # 
      def load_paths
        @_files ||= []
      end

      ##
      # Return a ordered list of task with their class
      # 
      def mappings
        @_mappings ||= SupportLite::OrderedHash.new
      end

      ##
      # Gloabl add a new generator class to +padrino-gen+
      # 
      def add_generator(name, klass)
        mappings[name] = klass
      end

      ##
      # Load Global Actions and Component Actions then all files in +load_path+.
      # 
      def lockup!
        require 'padrino-gen/generators/actions'
        Dir[File.dirname(__FILE__) + '/padrino-gen/generators/components/**/*.rb'].each { |lib| require lib }
        load_paths.flatten.each { |file| require file  }
      end
    end
  end # Generators
end # Padrino

##
# We add our generators to Padrino::Genererator 
# 
Padrino::Generators.load_paths << Dir[File.dirname(__FILE__) + '/padrino-gen/generators/{project,app,mailer,controller,model,migration}.rb']

##
# We add our tasks to padrino-core
# 
Padrino::Tasks.files << Dir[File.dirname(__FILE__) + "/padrino-gen/padrino-tasks/**/*.rb"]

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
padrino-gen-0.9.1 lib/padrino-gen.rb
padrino-gen-0.9.0 lib/padrino-gen.rb
padrino-gen-0.8.5 lib/padrino-gen.rb
padrino-gen-0.8.4 lib/padrino-gen.rb
padrino-gen-0.8.3 lib/padrino-gen.rb
padrino-gen-0.8.2 lib/padrino-gen.rb