Module: Evoke
- Defined in:
- lib/evoke.rb,
lib/evoke/cli.rb,
lib/evoke/task.rb,
lib/evoke/comment.rb,
lib/evoke/version.rb,
lib/evoke/parameters.rb,
lib/evoke/inflections.rb,
lib/evoke/inflections/camelize.rb,
lib/evoke/inflections/underscore.rb
Defined Under Namespace
Modules: Comment, Inflections, Parameters Classes: CLI, Task
Constant Summary collapse
- VERSION =
'0.1.3'
Class Method Summary collapse
-
.before_task(&block) ⇒ Object
Adds a code block that will be called before the task is invoked.
-
.find_task(name) ⇒ Evoke::Task
Finds a task with the supplied name.
-
.invoke(task, *arguments) ⇒ Object
Creates an instance of a task, validates the amount of arguments supplied matches the task’s #invoke method, executes the #before_task callbacks, and invokes the task.
-
.load_tasks(path, relative = true) ⇒ Array
Loads all the Evoke tasks in the supplied path.
-
.tasks ⇒ Array
Gets all the classes that descend from Evoke::Task.
Class Method Details
.before_task(&block) ⇒ Object
Adds a code block that will be called before the task is invoked.
62 63 64 65 |
# File 'lib/evoke.rb', line 62 def before_task(&block) @before_hooks ||= [] @before_hooks << block if block_given? end |
.find_task(name) ⇒ Evoke::Task
Finds a task with the supplied name.
24 25 26 |
# File 'lib/evoke.rb', line 24 def find_task(name) tasks.find { |task| task.to_s == name.camelize } end |
.invoke(task, *arguments) ⇒ Object
Creates an instance of a task, validates the amount of arguments supplied matches the task’s #invoke method, executes the #before_task callbacks, and invokes the task.
73 74 75 76 77 78 |
# File 'lib/evoke.rb', line 73 def invoke(task, *arguments) task.validate_arguments(arguments) task = task.new Evoke.call_before_hooks(task, *arguments) task.invoke(*arguments) end |
.load_tasks(path, relative = true) ⇒ Array
Loads all the Evoke tasks in the supplied path.
42 43 44 45 46 47 48 49 |
# File 'lib/evoke.rb', line 42 def load_tasks(path, relative=true) if relative path = File.join(Dir.pwd, path) path = File.(path) end Dir[File.join(path, '**', '*_task.rb')].each { |f| load f } end |