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
taskdefinition. -
#namespace(name = :not_used) ⇒ String
It can be hierarchical by using
NAMESPACE_DELIMITER. -
#namespaced(name = namespace, &block) ⇒ Object
It builds the nested
namespacerake 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
27 28 29 30 31 |
# File 'lib/rake-commander/rake_task.rb', line 27 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)whenRakeinterprets the fullARGVrather than stopping at the delimiter (--)
Does the final rake task definition
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rake-commander/rake_task.rb', line 84 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
43 44 45 46 47 |
# File 'lib/rake-commander/rake_task.rb', line 43 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
66 67 68 69 70 71 72 73 74 |
# File 'lib/rake-commander/rake_task.rb', line 66 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?
61 62 63 |
# File 'lib/rake-commander/rake_task.rb', line 61 def namespaced? !!namespace end |
#rake ⇒ Object
The rake context wrapper (to invoke rake commands)
21 22 23 |
# File 'lib/rake-commander/rake_task.rb', line 21 def rake @rake ||= RakeCommander::RakeContext::Wrapper.new end |
#task(name = :not_used) ⇒ Symbol
Give a name to the task
35 36 37 38 39 |
# File 'lib/rake-commander/rake_task.rb', line 35 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)
51 52 53 |
# File 'lib/rake-commander/rake_task.rb', line 51 def task_fullname "#{namespace}:#{task}" end |