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

Instance Method Details

#execute(command, &block) ⇒ Object

Executes the command, logs the output, and optionally growls.



99
100
101
# File 'lib/kicker/utils.rb', line 99

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_commandObject

Returns the last executed command.



104
105
106
# File 'lib/kicker/utils.rb', line 104

def last_command
  Kicker::Utils.last_command
end

#log(message) ⇒ Object

Prints a message with timestamp to stdout.



94
95
96
# File 'lib/kicker/utils.rb', line 94

def log(message)
  Kicker::Utils.log(message)
end

#optionsObject

Returns the global OptionParser instance that recipes can use to add options.



93
94
95
# File 'lib/kicker/options.rb', line 93

def options
  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


21
22
23
# File 'lib/kicker/recipes.rb', line 21

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