Module: Baptize::Registry
- Defined in:
- lib/baptize/registry.rb
Class Method Summary collapse
- .after(subject_name, other_task = nil, &block) ⇒ Object
- .apply_policy(role, host, ssh_connection) ⇒ Object
- .before(subject_name, other_task = nil, &block) ⇒ Object
- .define_package(package_name, &config_block) ⇒ Object
- .define_policy(role, package_names) ⇒ Object
- .execution_scope ⇒ Object
- .logger ⇒ Object
- .packages ⇒ Object
- .packages_executed ⇒ Object
- .plugins ⇒ Object
- .policies ⇒ Object
Class Method Details
.after(subject_name, other_task = nil, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/baptize/registry.rb', line 44 def self.after(subject_name, other_task=nil, &block) @afters ||= {} @afters[subject_name] ||= [] if other_task task = packages[other_task] if other_task.kind_of?(String) raise "Didn't find a package by that name" if task.nil? @afters[subject_name] << task.method(:execute) elsif block_given? @afters[subject_name] << block end @afters[subject_name] end |
.apply_policy(role, host, ssh_connection) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/baptize/registry.rb', line 80 def self.apply_policy(role, host, ssh_connection) execution_scope.set :current_host, host execution_scope.set :current_ssh_connection, ssh_connection policies[role.to_sym].each do |package_name| raise "No package '#{package_name}'" unless packages[package_name] packages[package_name].execute end end |
.before(subject_name, other_task = nil, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/baptize/registry.rb', line 31 def self.before(subject_name, other_task=nil, &block) @befores ||= {} @befores[subject_name] ||= [] if other_task task = packages[other_task] if other_task.kind_of?(String) raise "Didn't find a package by that name" if task.nil? @befores[subject_name] << task.method(:execute) elsif block_given? @befores[subject_name] << block end @befores[subject_name] end |
.define_package(package_name, &config_block) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/baptize/registry.rb', line 57 def self.define_package(package_name, &config_block) package = PackageDefinition.new(package_name, self.execution_scope, self) packages[package.full_name] = package package.instance_eval(&config_block) if ENV['SKIP_DEPENDENCIES'] before package.full_name do logger.important "Skipping dependencies for package #{package.name}" end else package.dependencies.each do |task_name| before package.full_name, task_name end end end |
.define_policy(role, package_names) ⇒ Object
76 77 78 |
# File 'lib/baptize/registry.rb', line 76 def self.define_policy(role, package_names) policies[role.to_sym] = package_names.map(&:to_s) end |
.execution_scope ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/baptize/registry.rb', line 9 def self.execution_scope unless @execution_scope @execution_scope = ExecutionScope.new plugins.each do |plugin_module| (class << @execution_scope ; self ; end).send(:include, plugin_module) end end @execution_scope end |
.logger ⇒ Object
19 20 21 |
# File 'lib/baptize/registry.rb', line 19 def self.logger @logger ||= ::Logger.new(STDOUT) end |
.packages ⇒ Object
23 24 25 |
# File 'lib/baptize/registry.rb', line 23 def self.packages @packages ||= {} end |
.packages_executed ⇒ Object
27 28 29 |
# File 'lib/baptize/registry.rb', line 27 def self.packages_executed @packages_executed ||= [] end |
.plugins ⇒ Object
5 6 7 |
# File 'lib/baptize/registry.rb', line 5 def self.plugins @plugins ||= [] end |
.policies ⇒ Object
72 73 74 |
# File 'lib/baptize/registry.rb', line 72 def self.policies @policies ||= {} end |