Sha256: 99d2c668ade5845a6cec7a464109d1b309269a702f62002d4786492f331b3962

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

Contents

require 'rails'

module Alchemy
  module Generators
    class ModuleGenerator < ::Rails::Generators::Base
      desc "This generator generates an Alchemy module for you."
      argument :module_name, :banner => "your_module_name"
      source_root File.expand_path('templates', File.dirname(__FILE__))

      def init
        @module_name = module_name.downcase
        @class_name = @module_name.singularize.classify
        @controller_name = @module_name.tableize
        @controller_class = @controller_name.classify.pluralize
      end

      def make_route
        route "namespace :admin do\n    resources :#{@controller_name}\n  end"
      end

      def copy_templates
        empty_directory Rails.root.join("app/controllers/admin")

        template "controller.rb.tt", Rails.root.join("app/controllers/admin/#{@controller_name}_controller.rb")
        template "ability.rb.tt", Rails.root.join('app/models', "alchemy_#{@module_name}_ability.rb")
        template "module_config.rb.tt", Rails.root.join("config/initializers/alchemy_#{@module_name}.rb")
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.3 lib/rails/generators/alchemy/module/module_generator.rb
lc_alchemy_cms-3.2.1 lib/rails/generators/alchemy/module/module_generator.rb
lc_alchemy_cms-3.2.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.2.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.2.0.rc1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.2.0.beta lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.rc3 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.rc2 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.rc1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta6 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta5 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta4 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta3 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta2 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.1.0.beta1 lib/rails/generators/alchemy/module/module_generator.rb