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 sends user notifications on Mac OS X (10.8 or higher). -
#ignore(regexp_or_string) ⇒ Object
Adds
regexp_or_string
as an ignore rule. -
#log(message) ⇒ Object
Prints a
message
with timestamp to stdout. -
#options ⇒ Object
Returns the global OptionParser instance that recipes can use to add options.
-
#perform_work(command, &block) ⇒ Object
When you perform some work (like shelling out a command to run without using
execute
) you need to call this method, with a block in which you perform your work, which will take care of logging the work appropriately. -
#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 sends user notifications on Mac OS X (10.8 or higher).
124 125 126 |
# File 'lib/kicker/utils.rb', line 124 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 |
#log(message) ⇒ Object
Prints a message
with timestamp to stdout.
111 112 113 |
# File 'lib/kicker/utils.rb', line 111 def log() Kicker::Utils.log() end |
#options ⇒ Object
Returns the global OptionParser instance that recipes can use to add options.
93 94 95 |
# File 'lib/kicker/options.rb', line 93 def Kicker::Options.parser end |
#perform_work(command, &block) ⇒ Object
When you perform some work (like shelling out a command to run without using execute
) you need to call this method, with a block in which you perform your work, which will take care of logging the work appropriately.
118 119 120 |
# File 'lib/kicker/utils.rb', line 118 def perform_work(command, &block) Kicker::Utils.perform_work(command, &block) 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
18 19 20 |
# File 'lib/kicker/recipes.rb', line 18 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 |