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(action, arguments=nil) click to toggle source

Executes git commmands in project using Grit

@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(action, arguments=nil)
  FileUtils.cd(destination_root) do
    require 'grit' unless defined?(::Grit)
    if action.to_s == 'init'
      ::Grit::Repo.init(arguments || destination_root)
      say "Git repo has been initialized", :green
    else
      @_git ||= ::Grit::Repo.new(destination_root)
      @_git.method(action).call(arguments)
    end
  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.