Class: Vagrant::Plugin::Remote::SyncedFolder
- Inherits:
-
V2::SyncedFolder
- Object
- V2::SyncedFolder
- Vagrant::Plugin::Remote::SyncedFolder
- Defined in:
- lib/vagrant/plugin/remote/synced_folder.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Add an attribute accesor for the client when applied to the SyncedFolder class.
Instance Method Summary collapse
- #_initialize(machine, synced_folder_type, client = nil) ⇒ Object
-
#capability(cap_name, *args) ⇒ Object
Executes the capability with the given name, optionally passing more arguments onwards to the capability.
-
#capability?(cap_name) ⇒ Boolean
Tests whether the given capability is possible.
- #cleanup(machine, opts) ⇒ Object
- #disable(machine, folders, opts) ⇒ Object
- #enable(machine, folders, opts) ⇒ Object
-
#initialize(client: nil) ⇒ SyncedFolder
constructor
A new instance of SyncedFolder.
- #initialize_capabilities!(host, hosts, capabilities, *args) ⇒ Object
- #prepare(machine, folders, opts) ⇒ Object
- #to_proto ⇒ Object
- #usable?(machine, raise_error = false) ⇒ Boolean
Methods included from CapabilityHost
Constructor Details
#initialize(client: nil) ⇒ SyncedFolder
Returns a new instance of SyncedFolder.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 12 def initialize(client: nil) if client.nil? raise ArgumentError, "Remote client is required for `#{self.class.name}`" end @client = client @logger = Log4r::Logger.new("vagrant::remote::synced_folder::#{self.class.name}") if client.nil? @logger.warn("synced folder remote client is unset") end end |
Instance Attribute Details
#client ⇒ Object
Add an attribute accesor for the client when applied to the SyncedFolder class
10 11 12 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 10 def client @client end |
Instance Method Details
#_initialize(machine, synced_folder_type, client = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 24 def _initialize(machine, synced_folder_type, client=nil) if client.nil? && Manager.client @client = Manager.client.get_plugin( name: synced_folder_type, type: :synced_folder, ) else raise "Cannot set remote client for synced folder, no manager available" end self end |
#capability(cap_name, *args) ⇒ Object
Executes the capability with the given name, optionally passing more arguments onwards to the capability. If the capability returns a value, it will be returned.
87 88 89 90 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 87 def capability(cap_name, *args) @logger.debug("running remote synced folder capability #{cap_name} with args #{args}") client.capability(cap_name, *args) end |
#capability?(cap_name) ⇒ Boolean
Tests whether the given capability is possible.
96 97 98 99 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 96 def capability?(cap_name) @logger.debug("checking for remote synced folder capability #{cap_name}") client.has_capability?(cap_name) end |
#cleanup(machine, opts) ⇒ Object
78 79 80 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 78 def cleanup(machine, opts) client.cleanup(machine, opts) end |
#disable(machine, folders, opts) ⇒ Object
72 73 74 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 72 def disable(machine, folders, opts) client.disable(machine, folders, opts) end |
#enable(machine, folders, opts) ⇒ Object
64 65 66 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 64 def enable(machine, folders, opts) client.enable(machine, folders, opts) end |
#initialize_capabilities!(host, hosts, capabilities, *args) ⇒ Object
37 38 39 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 37 def initialize_capabilities!(host, hosts, capabilities, *args) # no-op end |
#prepare(machine, folders, opts) ⇒ Object
45 46 47 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 45 def prepare(machine, folders, opts) client.prepare(machine, folders, opts) end |
#to_proto ⇒ Object
101 102 103 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 101 def to_proto client.proto end |
#usable?(machine, raise_error = false) ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/vagrant/plugin/remote/synced_folder.rb', line 53 def usable?(machine, raise_error=false) begin client.usable(machine) rescue raise if raise_error end end |