Responsible for executing plugin and template instructions including common actions for modifying a project or application.
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
# File lib/padrino-gen/generators/runner.rb, line 73 def app(name) 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 yield @_app_name = nil end end
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"
# 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
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"
# 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
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"
# 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
Executes rake command with given arguments.
@param [String] command
Rake tasks to execute.
@example
rake "custom task1 task2"
# File lib/padrino-gen/generators/runner.rb, line 55 def rake(command) Padrino.bin("rake", command, "-c=#{destination_root}") end