Sha256: d6acad8db2d72c8d7c791d415037fef700fb1d166d35cf9c244fb79cd0670248

Contents?: true

Size: 1.71 KB

Versions: 47

Compression:

Stored size: 1.71 KB

Contents

require 'rails'

module Alchemy
  module Generators
    class PluginGenerator < ::Rails::Generators::Base
      desc "This generator generates a Alchemy plugin skeleton for you."
      argument :plugin_name, :banner => "your_plugin_name"
      source_root File.expand_path('templates', File.dirname(__FILE__))

      def create_directories
        @plugin_name = plugin_name.underscore
        @plugin_path = Rails.root.join('vendor/plugins', @plugin_name)
        empty_directory "#{@plugin_path}/lib/#{@plugin_name}"
        empty_directory "#{@plugin_path}/rails"
        empty_directory "#{@plugin_path}/app/controllers/admin"
        empty_directory "#{@plugin_path}/app/models"
        empty_directory "#{@plugin_path}/app/views/admin"
        empty_directory "#{@plugin_path}/config/alchemy"
        empty_directory "#{@plugin_path}/config/initializers"
        empty_directory "#{@plugin_path}/locale/de"
        empty_directory "#{@plugin_path}/locale/en"
      end

      def create_defaults
        copy_file("#{File.dirname(__FILE__)}/files/translation.pot", "#{@plugin_path}/locale/#{@plugin_name}.pot")
        copy_file("#{File.dirname(__FILE__)}/files/translation_de.po", "#{@plugin_path}/locale/de/#{@plugin_name}.po")
        copy_file("#{File.dirname(__FILE__)}/files/translation_en.po", "#{@plugin_path}/locale/en/#{@plugin_name}.po")
        template("config.yml", "#{@plugin_path}/config/alchemy/config.yml")
        template("authorization_rules.rb", "#{@plugin_path}/config/authorization_rules.rb")
        template("routes.rb", "#{@plugin_path}/config/routes.rb")
        template("plugin.rb", "#{@plugin_path}/lib/#{@plugin_name}.rb")
        template("init.rb", "#{@plugin_path}/rails/init.rb")
      end

    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
alchemy_cms-2.3.2 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.4 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.1 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.0 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.rc4 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.rc2 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.rc1 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.3.1 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.4.beta2 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.3.2 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.3.1 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.1.12 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.3.0 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.3.rc5 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.2 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.1 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.0 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.rc15 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.1.11 lib/rails/generators/alchemy/plugin/plugin_generator.rb
alchemy_cms-2.2.rc14 lib/rails/generators/alchemy/plugin/plugin_generator.rb