Class: VagrantPlugins::Bindfs::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Bindfs::Config
- Defined in:
- lib/vagrant-bindfs/config.rb
Instance Method Summary collapse
- #bind_folder(source_path, dest_path, options = nil) ⇒ Object
- #bind_folders ⇒ Object
- #default_options(new_options = {}) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merge(other) ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 |
# File 'lib/vagrant-bindfs/config.rb', line 5 def initialize @__default_options = {} @__bind_folders = {} end |
Instance Method Details
#bind_folder(source_path, dest_path, options = nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/vagrant-bindfs/config.rb', line 18 def bind_folder(source_path, dest_path, = nil) ||= {} [:source_path] = source_path [:dest_path] = dest_path @__bind_folders[[:dest_path]] = end |
#bind_folders ⇒ Object
10 11 12 |
# File 'lib/vagrant-bindfs/config.rb', line 10 def bind_folders @__bind_folders end |
#default_options(new_options = {}) ⇒ Object
14 15 16 |
# File 'lib/vagrant-bindfs/config.rb', line 14 def ( = {}) @__default_options.merge! end |
#merge(other) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-bindfs/config.rb', line 26 def merge(other) super.tap do |result| # merge the changes to default options result.instance_variable_set( :@__default_options, (other.)) # merge the folders to be bound new_folders = @__bind_folders.dup other_folders = other.instance_variable_get(:@__bind_folders) other_folders.each do |id, | new_folders[id] ||= {} new_folders[id].merge!() end result.instance_variable_set(:@__bind_folders, new_folders) end end |
#validate(machine) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vagrant-bindfs/config.rb', line 45 def validate(machine) errors = [] @__bind_folders.each do |id, | next if [:disabled] if Pathname.new([:dest_path]).relative? errors << I18n.t('vagrant.config.bindfs.errors.destination_path_relative', :path => [:dest_path]) end if Pathname.new([:source_path]).relative? errors << I18n.t('vagrant.config.bindfs.errors.source_path_relative', :path => [:source_path]) end end errors.empty? && {} || { 'bindfs' => errors } end |