Sha256: 8d6648b7b8d3adfe50910757f69f8524bfb868ccbc16de14dcbf761902bf51bd

Contents?: true

Size: 1.32 KB

Versions: 28

Compression:

Stored size: 1.32 KB

Contents

require 'rails/generators/rails/generator/generator_generator'

module Rails
  module Generators
    class PluginGenerator < NamedBase
      class_option :tasks, :desc => "When supplied creates tasks base files."

      def show_deprecation
        return unless behavior == :invoke
        message = "Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure."
        ActiveSupport::Deprecation.warn message
      end

      check_class_collision

      def create_root_files
        directory '.', plugin_dir, :recursive => false
      end

      def create_lib_files
        directory 'lib', plugin_dir('lib'), :recursive => false
      end

      def create_tasks_files
        return unless options[:tasks]
        directory 'lib/tasks', plugin_dir('lib/tasks')
      end

      hook_for :generator do |generator|
        inside plugin_dir, :verbose => true do
          invoke generator, [ name ], :namespace => false
        end
      end

      hook_for :test_framework do |test_framework|
        inside plugin_dir, :verbose => true do
          invoke test_framework
        end
      end

      protected

        def plugin_dir(join=nil)
          if join
            File.join(plugin_dir, join)
          else
            "vendor/plugins/#{file_name}"
          end
        end

    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
railties-3.1.12 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.11 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.10 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.9 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.8 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.7 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.6 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.5 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.5.rc1 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.4 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.4.rc1 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.3 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.2 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.2.rc2 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.2.rc1 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.1 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.1.rc3 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.1.rc2 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.1.rc1 lib/rails/generators/rails/plugin/plugin_generator.rb
railties-3.1.0 lib/rails/generators/rails/plugin/plugin_generator.rb