Module: Recap::Support::Namespace
- Included in:
- Compatibility, Tasks::Bootstrap, Tasks::Bundler, Tasks::Deploy, Tasks::Env, Tasks::Foreman, Tasks::Preflight, Tasks::Rails, Tasks::Ruby
- Defined in:
- lib/recap/support/namespace.rb
Overview
This module is used to capture the definition of capistrano tasks, which makes it easier to test the behaviour of specific tasks without loading everything. If you are writing tests for a collection of tasks, you should put those tasks in a module and extend that module with ‘Recap::Support::Namespace.
You can look at some of the existing tasks (such as [env](../tasks/env.html)) and its corresponding specs for an example of this in practice.
You should not need to use this module directly when using recap to deploy.
Class Method Summary collapse
Instance Method Summary collapse
- #capistrano_definitions ⇒ Object
- #load_into(configuration) ⇒ Object
- #namespace(name, &block) ⇒ Object
Class Method Details
.default_config ⇒ Object
15 16 17 |
# File 'lib/recap/support/namespace.rb', line 15 def self.default_config @default_config end |
.default_config=(config) ⇒ Object
19 20 21 |
# File 'lib/recap/support/namespace.rb', line 19 def self.default_config=(config) @default_config = config end |
Instance Method Details
#capistrano_definitions ⇒ Object
27 28 29 |
# File 'lib/recap/support/namespace.rb', line 27 def capistrano_definitions @capistrano_definitions ||= [] end |
#load_into(configuration) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/recap/support/namespace.rb', line 41 def load_into(configuration) configuration.extend(self) capistrano_definitions.each do |definition| configuration.load(&definition) end end |
#namespace(name, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/recap/support/namespace.rb', line 31 def namespace(name, &block) capistrano_definitions << Proc.new do namespace name do instance_eval(&block) end end load_into(Recap::Support::Namespace.default_config) if Recap::Support::Namespace.default_config end |