Module: Padrino::Generators::Runner
Overview
Responsible for executing plugin and template instructions including common actions for modifying a project or application.
Instance Method Summary collapse
-
#app(name) ⇒ Object
Executes App generator.
-
#generate(type, arguments = '') ⇒ Object
Executes generator command for specified type with given arguments.
-
#git(*args) ⇒ Object
Executes git commmands in project.
-
#project(options = {}) ⇒ Object
Generates project scaffold based on a given template file.
-
#rake(command) ⇒ Object
Executes rake command with given arguments.
Instance Method Details
#app(name) ⇒ Object
Executes App generator. Accepts an optional block allowing generation inside subapp.
73 74 75 76 77 78 79 80 81 82 |
# File 'padrino-gen/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}") return unless block_given? @_app_name = name yield ensure @_app_name = nil end |
#generate(type, arguments = '') ⇒ Object
Executes generator command for specified type with given arguments.
39 40 41 42 43 44 |
# File 'padrino-gen/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) ⇒ Object
Executes git commmands in project.
97 98 99 100 101 102 103 |
# File 'padrino-gen/lib/padrino-gen/generators/runner.rb', line 97 def git(*args) FileUtils.cd(destination_root) do cmd = format('git %s', args.join(' ')) say cmd, :green system cmd end end |
#project(options = {}) ⇒ Object
Generates project scaffold based on a given template file.
19 20 21 22 23 24 |
# File 'padrino-gen/lib/padrino-gen/generators/runner.rb', line 19 def project( = {}) components = .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 |