Class: Vagrant::Plugin::V2::Manager
- Inherits:
-
Object
- Object
- Vagrant::Plugin::V2::Manager
- Defined in:
- lib/vagrant/plugin/v2/manager.rb
Overview
This class maintains a list of all the registered plugins as well as provides methods that allow querying all registered components of those plugins as a single unit.
Instance Attribute Summary collapse
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
-
#action_hooks(hook_name) ⇒ Array
This returns all the action hooks.
-
#commands ⇒ Registry<Symbol, Array<Proc, Hash>>
This returns all the registered commands.
-
#communicators ⇒ Hash
This returns all the registered communicators.
-
#config ⇒ Hash
This returns all the registered configuration classes.
-
#guest_capabilities ⇒ Hash
This returns all the registered guest capabilities.
-
#guests ⇒ Hash
This returns all the registered guests.
-
#host_capabilities ⇒ Hash
This returns all the registered host capabilities.
-
#hosts ⇒ Hash
This returns all the registered guests.
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
-
#provider_capabilities ⇒ Hash
This returns all the registered provider capabilities.
-
#provider_configs ⇒ Hash
This returns all the config classes for the various providers.
-
#providers ⇒ Hash
This returns all registered providers.
-
#provisioner_configs ⇒ Registry
This returns all the config classes for the various provisioners.
-
#provisioners ⇒ Hash
This returns all registered provisioners.
-
#push_configs ⇒ Registry
This returns all the config classes for the various pushes.
-
#pushes ⇒ Registry
This returns all registered pushes.
-
#register(plugin) ⇒ Object
This registers a plugin.
-
#reset! ⇒ Object
This clears out all the registered plugins.
-
#synced_folders ⇒ Registry
This returns all synced folder implementations.
-
#unregister(plugin) ⇒ Object
This unregisters a plugin so that its components will no longer be used.
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
12 13 14 15 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 12 def initialize @logger = Log4r::Logger.new("vagrant::plugin::v2::manager") @registered = [] end |
Instance Attribute Details
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
10 11 12 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 10 def registered @registered end |
Instance Method Details
#action_hooks(hook_name) ⇒ Array
This returns all the action hooks.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 20 def action_hooks(hook_name) result = [] @registered.each do |plugin| result += plugin.components.action_hooks[Plugin::ALL_ACTIONS] result += plugin.components.action_hooks[hook_name] end result end |
#commands ⇒ Registry<Symbol, Array<Proc, Hash>>
This returns all the registered commands.
34 35 36 37 38 39 40 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 34 def commands Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.commands) end end end |
#communicators ⇒ Hash
This returns all the registered communicators.
45 46 47 48 49 50 51 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 45 def communicators Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.communicator) end end end |
#config ⇒ Hash
This returns all the registered configuration classes.
56 57 58 59 60 61 62 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 56 def config Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.configs[:top]) end end end |
#guest_capabilities ⇒ Hash
This returns all the registered guest capabilities.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 78 def guest_capabilities results = Hash.new { |h, k| h[k] = Registry.new } @registered.each do |plugin| plugin.components.guest_capabilities.each do |guest, caps| results[guest].merge!(caps) end end results end |
#guests ⇒ Hash
This returns all the registered guests.
67 68 69 70 71 72 73 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 67 def guests Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.guests) end end end |
#host_capabilities ⇒ Hash
This returns all the registered host capabilities.
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 104 def host_capabilities results = Hash.new { |h, k| h[k] = Registry.new } @registered.each do |plugin| plugin.components.host_capabilities.each do |host, caps| results[host].merge!(caps) end end results end |
#hosts ⇒ Hash
This returns all the registered guests.
93 94 95 96 97 98 99 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 93 def hosts Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.hosts) end end end |
#provider_capabilities ⇒ Hash
This returns all the registered provider capabilities.
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 130 def provider_capabilities results = Hash.new { |h, k| h[k] = Registry.new } @registered.each do |plugin| plugin.components.provider_capabilities.each do |provider, caps| results[provider].merge!(caps) end end results end |
#provider_configs ⇒ Hash
This returns all the config classes for the various providers.
145 146 147 148 149 150 151 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 145 def provider_configs Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.configs[:provider]) end end end |
#providers ⇒ Hash
This returns all registered providers.
119 120 121 122 123 124 125 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 119 def providers Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.providers) end end end |
#provisioner_configs ⇒ Registry
This returns all the config classes for the various provisioners.
156 157 158 159 160 161 162 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 156 def provisioner_configs Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.configs[:provisioner]) end end end |
#provisioners ⇒ Hash
This returns all registered provisioners.
167 168 169 170 171 172 173 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 167 def provisioners Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.provisioner) end end end |
#push_configs ⇒ Registry
This returns all the config classes for the various pushes.
189 190 191 192 193 194 195 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 189 def push_configs Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.configs[:push]) end end end |
#pushes ⇒ Registry
This returns all registered pushes.
178 179 180 181 182 183 184 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 178 def pushes Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.pushes) end end end |
#register(plugin) ⇒ Object
This registers a plugin. This should NEVER be called by the public and should only be called from within Vagrant. Vagrant will automatically register V2 plugins when a name is set on the plugin.
212 213 214 215 216 217 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 212 def register(plugin) if !@registered.include?(plugin) @logger.info("Registered plugin: #{plugin.name}") @registered << plugin end end |
#reset! ⇒ Object
This clears out all the registered plugins. This is only used by unit tests and should not be called directly.
221 222 223 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 221 def reset! @registered.clear end |
#synced_folders ⇒ Registry
This returns all synced folder implementations.
200 201 202 203 204 205 206 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 200 def synced_folders Registry.new.tap do |result| @registered.each do |plugin| result.merge!(plugin.components.synced_folders) end end end |
#unregister(plugin) ⇒ Object
This unregisters a plugin so that its components will no longer be used. Note that this should only be used for testing purposes.
227 228 229 230 231 232 |
# File 'lib/vagrant/plugin/v2/manager.rb', line 227 def unregister(plugin) if @registered.include?(plugin) @logger.info("Unregistered: #{plugin.name}") @registered.delete(plugin) end end |