Module: CrowdFavorite::Support::Namespace
- Included in:
- Tasks::LocalChanges, Tasks::WordPress, WordPress
- Defined in:
- lib/crowdfavorite/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 ‘CrowdFavorite::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
29 30 31 |
# File 'lib/crowdfavorite/support/namespace.rb', line 29 def self.default_config @default_config end |
.default_config=(config) ⇒ Object
33 34 35 |
# File 'lib/crowdfavorite/support/namespace.rb', line 33 def self.default_config=(config) @default_config = config end |
Instance Method Details
#capistrano_definitions ⇒ Object
41 42 43 |
# File 'lib/crowdfavorite/support/namespace.rb', line 41 def capistrano_definitions @capistrano_definitions ||= [] end |
#load_into(configuration) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/crowdfavorite/support/namespace.rb', line 55 def load_into(configuration) configuration.extend(self) capistrano_definitions.each do |definition| configuration.load(&definition) end end |
#namespace(name, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/crowdfavorite/support/namespace.rb', line 45 def namespace(name, &block) capistrano_definitions << Proc.new do namespace name do instance_eval(&block) end end load_into(CrowdFavorite::Support::Namespace.default_config) if CrowdFavorite::Support::Namespace.default_config end |