Sha256: cdf026b3d18c9c22062ed0e0cb8eeed11f2d52ca739e370f50f156c906ae5da0

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

class AppGenerator < RubiGen::Base

  attr_reader :name,:plural_name,:singular_name,:class_name,:file_name

  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.empty?
    @destination_root = File.expand_path(args.shift)
    @name             = base_name
    @plural_name      = @name.pluralize.underscore
    @singular_name    = @name.singularize.underscore

    @file_name        = @name.singularize.underscore
    @class_name       = @name.singularize.classify
  end

  def manifest
    record do |m|
      %w(
        lib tasks test test/app_root test/unit test/app_root/app/controllers
        test/app_root/config/environments test/app_root/config/initializers
      ).each do |path|
        m.directory path
      end

      m.template_copy_each %w(MIT-LICENSE README Rakefile init.rb install.rb uninstall.rb test/test_helper.rb test/app_root/app/controllers/application_controller.rb)
      m.template "lib/module.rb","lib/#{file_name}.rb"
      m.template "tasks/tasks.rake","tasks/#{file_name}_tasks.rake"

      m.file_copy_each %w(
        test/app_root/config/boot.rb
        test/app_root/config/database.yml
        test/app_root/config/environment.rb
        test/app_root/config/environments/in_memory.rb
        test/app_root/config/environments/mysql.rb
        test/app_root/config/environments/postgresql.rb
        test/app_root/config/environments/sqlite.rb
        test/app_root/config/environments/sqlite3.rb
        test/app_root/config/initializers/plugin.rb
        test/app_root/config/routes.rb
      )
    end
  end

  protected
    def banner
      <<-EOS
Creates a new plugin

USAGE: #{spec.name} name
EOS
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newplugin-0.0.2 generators/app/app_generator.rb
newplugin-0.0.1 generators/app/app_generator.rb