Module: Kernel
- Defined in:
- lib/kicker/utils.rb,
lib/kicker/options.rb,
lib/kicker/recipes.rb,
lib/kicker/callback_chain.rb,
lib/kicker/recipes/ignore.rb
Instance Method Summary collapse
-
#execute(command, &block) ⇒ Object
Executes the
command
, logs the output, and optionally growls. -
#ignore(regexp_or_string) ⇒ Object
Adds
regexp_or_string
as an ignore rule. -
#last_command ⇒ Object
Returns the last executed command.
-
#log(message) ⇒ Object
Prints a
message
with timestamp to stdout. -
#options ⇒ Object
Returns the global OptionParser instance that recipes can use to add options.
-
#post_process(callback = nil, &block) ⇒ Object
Adds a handler to the post_process chain.
-
#pre_process(callback = nil, &block) ⇒ Object
Adds a handler to the pre_process chain.
-
#process(callback = nil, &block) ⇒ Object
Adds a handler to the process chain.
-
#recipe(name, &block) ⇒ Object
If only given a
name
, the specified recipe will be loaded. -
#startup(callback = nil, &block) ⇒ Object
Adds a handler to the startup chain.
Instance Method Details
#execute(command, &block) ⇒ Object
Executes the command
, logs the output, and optionally growls.
70 71 72 |
# File 'lib/kicker/utils.rb', line 70 def execute(command, &block) Kicker::Utils.execute(command, &block) end |
#ignore(regexp_or_string) ⇒ Object
Adds regexp_or_string
as an ignore rule.
require 'ignore'
ignore /^data\//
ignore 'Rakefile'
Only available if the ‘ignore’ recipe is required.
29 30 31 |
# File 'lib/kicker/recipes/ignore.rb', line 29 def ignore(regexp_or_string) Ignore.ignore(regexp_or_string) end |
#last_command ⇒ Object
Returns the last executed command.
75 76 77 |
# File 'lib/kicker/utils.rb', line 75 def last_command Kicker::Utils.last_command end |
#log(message) ⇒ Object
Prints a message
with timestamp to stdout.
65 66 67 |
# File 'lib/kicker/utils.rb', line 65 def log() Kicker::Utils.log() end |
#options ⇒ Object
Returns the global OptionParser instance that recipes can use to add options.
80 81 82 |
# File 'lib/kicker/options.rb', line 80 def Kicker::Options.parser end |
#post_process(callback = nil, &block) ⇒ Object
Adds a handler to the post_process chain. This chain is ran after the process chain and is processed from last to first.
Takes a callback
object that responds to #call
, or a block.
92 93 94 |
# File 'lib/kicker/callback_chain.rb', line 92 def post_process(callback = nil, &block) Kicker.post_process_chain.prepend_callback(block ? block : callback) end |
#pre_process(callback = nil, &block) ⇒ Object
Adds a handler to the pre_process chain. This chain is ran before the process chain and is processed from first to last.
Takes a callback
object that responds to #call
, or a block.
76 77 78 |
# File 'lib/kicker/callback_chain.rb', line 76 def pre_process(callback = nil, &block) Kicker.pre_process_chain.append_callback(block ? block : callback) end |
#process(callback = nil, &block) ⇒ Object
Adds a handler to the process chain. This chain is ran in between the pre_process and post_process chains. It is processed from first to last.
Takes a callback
object that responds to #call
, or a block.
84 85 86 |
# File 'lib/kicker/callback_chain.rb', line 84 def process(callback = nil, &block) Kicker.process_chain.append_callback(block ? block : callback) end |
#recipe(name, &block) ⇒ Object
If only given a name
, the specified recipe will be loaded. For instance, the following, in a .kick
file, will load the Rails recipe:
recipe :rails
However, this same method is used to define a callback that is called if the recipe is loaded. For instance, the following, in a recipe file, will be called if the recipe is actually used:
recipe :rails do
# Load anything needed for the recipe.
process do
# ...
end
end
24 25 26 |
# File 'lib/kicker/recipes.rb', line 24 def recipe(name, &block) Kicker::Recipes.recipe(name, &block) end |
#startup(callback = nil, &block) ⇒ Object
Adds a handler to the startup chain. This chain is ran once Kicker is done loading before starting the normal operations. Note that an empty files array is given to the callback.
Takes a callback
object that responds to #call
, or a block.
68 69 70 |
# File 'lib/kicker/callback_chain.rb', line 68 def startup(callback = nil, &block) Kicker.startup_chain.append_callback(block ? block : callback) end |