Module: RVGP::Base::Command::RakeTask::ClassMethods
- Defined in:
- lib/rvgp/base/command.rb
Overview
These methods are automatically included by the RakeTask module, and provide helper methods, to the class itself, of the command that RakeTask was included in.
Instance Attribute Summary collapse
-
#rake_namespace ⇒ Object
readonly
The namespace in which this command’s targets are defined.
Instance Method Summary collapse
-
#initialize_rake(rake_main) ⇒ void
This method initializes rake tasks in the provided context.
-
#rake_tasks(namespace) ⇒ void
This method is provided for classes that include this module.
Instance Attribute Details
#rake_namespace ⇒ Object (readonly)
The namespace in which this command’s targets are defined. This value is set by #rake_tasks.
394 395 396 |
# File 'lib/rvgp/base/command.rb', line 394 def rake_namespace @rake_namespace end |
Instance Method Details
#initialize_rake(rake_main) ⇒ void
This method returns an undefined value.
This method initializes rake tasks in the provided context. This method exists as a default implementation for commands, with which to initialize their rake tasks. Feel free to overload this default behavior in your commands.
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/rvgp/base/command.rb', line 437 def initialize_rake(rake_main) command_klass = self if rake_namespace rake_main.instance_eval do namespace command_klass.rake_namespace do command_klass.const_get('Target').all.each do |target| unless Rake::Task.task_defined?(target.name) desc target.description task(target.name) { |_task, _task_args| command_klass.task_exec(target) } end end end end end end |
#rake_tasks(namespace) ⇒ void
This method returns an undefined value.
This method is provided for classes that include this module. Calling this method, with a namespace, ensures that all the targets in the command, are setup as rake tasks inside the provided namespace.
400 401 402 |
# File 'lib/rvgp/base/command.rb', line 400 def rake_tasks(namespace) @rake_namespace = namespace end |