Module: Padrino::Generators::Runner

### Home Classes Methods

### In Files

- lib/padrino-gen/generators/runner.rb

### Methods

- #app
- #generate
- #git
- #project
- #rake

### Files

- README.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Generators
- Padrino::Generators::Actions
- Padrino::Generators::Actions::ClassMethods
- Padrino::Generators::App
- Padrino::Generators::AppRootNotFound
- Padrino::Generators::Cli
- Padrino::Generators::Components
- Padrino::Generators::Components::Actions
- Padrino::Generators::Controller
- Padrino::Generators::Mailer
- Padrino::Generators::Migration
- Padrino::Generators::Model
- Padrino::Generators::Plugin
- Padrino::Generators::Project
- Padrino::Generators::Runner
- Padrino::Generators::SqlHelpers
- ActiveRecord
- ActiveRecord::Schema
- Object

No matching classes.

# Padrino::Generators::Runner

Responsible for executing plugin and template instructions including common actions for modifying a project or application.

### Public Instance Methods

app(name, &block) click to toggle source

Executes App generator. Accepts an optional block allowing generation inside subapp.

@param [Symbol] name

    name of (sub)application to generate

@param [Proc] block

    commands to execute in context of (sub)appliation directory

@example

    app :name
    app :name do
     generate :model, "posts title:string" # generate a model inside of subapp
    end

@api public

    # File lib/padrino-gen/generators/runner.rb, line 73
    def app(name, &block)
      say "=> Executing: padrino-gen app #{name} -r=#{destination_root}", :magenta
      Padrino.bin_gen(:app, name.to_s, "-r=#{destination_root}")
      if block_given?
        @_app_name = name
        block.call
        @_app_name = nil
      end
    end

generate(type, arguments="") click to toggle source

Executes generator command for specified type with given arguments

@param [Symbol] type

    Type of component module

@param [String] arguments

    Arguments to send to component generator

@example

    generate :model, "post title:string body:text"
    generate :controller, "posts get:index get:new post:new"
    generate :migration, "AddEmailToUser email:string"

@api public

    # File lib/padrino-gen/generators/runner.rb, line 39
    def generate(type, arguments="")
      params = arguments.split(" ").push("-r=#{destination_root}")
      params.push("--app=#{@_app_name}") if @_app_name
      say "=> Executing: padrino-gen #{type} #{params.join(" ")}", :magenta
      Padrino.bin_gen(*params.unshift(type))
    end

git(*args) click to toggle source

Executes git commmands in project

@param [Symbol] action

    Git command to execute

@param [String] arguments

    Arguments to invoke on git command

@example

    git :init
    git :add, "."
    git :commit, "hello world"

@api public

    # File lib/padrino-gen/generators/runner.rb, line 96
    def git(*args)
      FileUtils.cd(destination_root) do
        cmd = "git %s" % args.join(' ')
        say cmd, :green
        system cmd
      end
    end

project(options={}) click to toggle source

Generates project scaffold based on a given template file

@param [Hash] options

    Options to use to generate the project

@example

    project :test => :shoulda, :orm => :activerecord, :renderer => "haml"

@api public

    # File lib/padrino-gen/generators/runner.rb, line 19
    def project(options={})
      components = options.sort_by { |k, v| k.to_s }.map { |component, value| "--#{component}=#{value}" }
      params = [name, *components].push("-r=#{destination_root("../")}")
      say "=> Executing: padrino-gen project #{params.join(" ")}", :magenta
      Padrino.bin_gen(*params.unshift("project"))
    end

rake(command) click to toggle source

Executes rake command with given arguments

@param [String] command

    Rake tasks to execute

@example

    rake "custom task1 task2"

@api public

    # File lib/padrino-gen/generators/runner.rb, line 55
    def rake(command)
      Padrino.bin("rake", command, "-c=#{destination_root}")
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.