Module: RakeCommander::RakeTask::ClassMethods
- Defined in:
- lib/rake-commander/rake_task.rb
Instance Method Summary collapse
-
#desc(str = :not_used) ⇒ String
Give a description to the task.
-
#install_task(&task_method) ⇒ @see Rake::Task
Does the final rake
task
definition. -
#namespace(name = :not_used) ⇒ String
It can be hierarchical by using
NAMESPACE_DELIMITER
. -
#namespaced(name = namespace, &block) ⇒ Object
It builds the nested
namespace
rake blocks. -
#namespaced? ⇒ Boolean
Is this rake context namespaced?.
-
#rake ⇒ Object
The rake context wrapper (to invoke rake commands).
-
#task(name = :not_used) ⇒ Symbol
Give a name to the task.
-
#task_fullname ⇒ String
(also: #name)
It gives the task full name (including namespacing).
Instance Method Details
#desc(str = :not_used) ⇒ String
Give a description to the task
26 27 28 29 |
# File 'lib/rake-commander/rake_task.rb', line 26 def desc(str = :not_used) return @desc if str == :not_used @desc = str.to_s end |
#install_task(&task_method) ⇒ @see Rake::Task
although it will exist, the task won't be listed with rake -T
unless it has a description (desc
).
this method is extended by some modules
RakeCommander::Options::Result
: Ensure options are parsed before calling taskRakeCommander::Options::Arguments
:exit(0)
whenRake
interprets the fullARGV
rather than stopping at the delimiter (--
)
Does the final rake task
definition
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rake-commander/rake_task.rb', line 79 def install_task(&task_method) raise "Expected task_block." unless task_method if namespaced? namespaced do rake.desc desc rake.task task, &task_method end else rake.desc desc rake.task task, &task_method end end |
#namespace(name = :not_used) ⇒ String
It can be hierarchical by using NAMESPACE_DELIMITER
40 41 42 43 |
# File 'lib/rake-commander/rake_task.rb', line 40 def namespace(name = :not_used) return @namespace if name == :not_used @namespace = namespace_str(name) end |
#namespaced(name = namespace, &block) ⇒ Object
It builds the nested namespace
rake blocks
62 63 64 65 66 67 68 69 |
# File 'lib/rake-commander/rake_task.rb', line 62 def namespaced(name = namespace, &block) spaces = namespace_split(name) top = spaces.shift block = spaces.reverse.reduce(block) do |blk, nm| namespace_block(nm, &blk) end rake.namespace top, &block end |
#namespaced? ⇒ Boolean
Rake allows to namespace tasks (i.e. task :"run:this"
)
Although supported by this integration, namespace detection
is left to the core rake
gem. This method will return false
.
Is this rake context namespaced?
57 58 59 |
# File 'lib/rake-commander/rake_task.rb', line 57 def namespaced? !!namespace end |
#rake ⇒ Object
The rake context wrapper (to invoke rake commands)
20 21 22 |
# File 'lib/rake-commander/rake_task.rb', line 20 def rake @rake ||= RakeCommander::RakeContext::Wrapper.new end |
#task(name = :not_used) ⇒ Symbol
Give a name to the task
33 34 35 36 |
# File 'lib/rake-commander/rake_task.rb', line 33 def task(name = :not_used) return @task if name == :not_used @task = name.to_sym end |
#task_fullname ⇒ String Also known as: name
It gives the task full name (including namespacing)
47 48 49 |
# File 'lib/rake-commander/rake_task.rb', line 47 def task_fullname "#{namespace}:#{task}" end |