Class: VagrantBindfs::Vagrant::Config
- Inherits:
-
Object
- Object
- VagrantBindfs::Vagrant::Config
- Defined in:
- lib/vagrant-bindfs/vagrant/config.rb
Instance Attribute Summary collapse
-
#binded_folders ⇒ Object
Returns the value of attribute binded_folders.
-
#bindfs_version ⇒ Object
Returns the value of attribute bindfs_version.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#install_bindfs_from_source ⇒ Object
Returns the value of attribute install_bindfs_from_source.
-
#skip_validations ⇒ Object
Returns the value of attribute skip_validations.
Instance Method Summary collapse
- #bind_folder(source, destination, options = {}) ⇒ Object
- #binded_folder=(*_any_variant) ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merge(other) ⇒ Object
- #source_version=(value) ⇒ Object
- #validate(_machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 16 def initialize @debug = false @bindfs_version = UNSET_VALUE @install_bindfs_from_source = false @binded_folders = {} = Bindfs::OptionSet.new(nil, 'force-user' => 'vagrant', 'force-group' => 'vagrant', 'perms' => 'u=rwX:g=rD:o=rD') @skip_validations = [] end |
Instance Attribute Details
#binded_folders ⇒ Object
Returns the value of attribute binded_folders.
12 13 14 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 12 def binded_folders @binded_folders end |
#bindfs_version ⇒ Object
Returns the value of attribute bindfs_version.
8 9 10 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 8 def bindfs_version @bindfs_version end |
#debug ⇒ Object
Returns the value of attribute debug.
6 7 8 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 6 def debug @debug end |
#default_options ⇒ Object
Returns the value of attribute default_options.
11 12 13 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 11 def end |
#install_bindfs_from_source ⇒ Object
Returns the value of attribute install_bindfs_from_source.
9 10 11 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 9 def install_bindfs_from_source @install_bindfs_from_source end |
#skip_validations ⇒ Object
Returns the value of attribute skip_validations.
14 15 16 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 14 def skip_validations @skip_validations end |
Instance Method Details
#bind_folder(source, destination, options = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 50 def bind_folder(source, destination, = {}) hook = .delete(:after) || :synced_folders folder = Bindfs::Folder.new(hook, source, destination, ) @binded_folders[folder.id] = folder end |
#binded_folder=(*_any_variant) ⇒ Object
46 47 48 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 46 def binded_folder=(*_any_variant) raise VagrantBindfs::Vagrant::ConfigError, :binded_folders end |
#finalize! ⇒ Object
71 72 73 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 71 def finalize! @bindfs_version = :latest if @bindfs_version == UNSET_VALUE end |
#merge(other) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 56 def merge(other) super.tap do |result| result.debug = (debug || other.debug) result_bindfs_version = [bindfs_version, other.bindfs_version].reject { |v| v == UNSET_VALUE }.min result.bindfs_version = result_bindfs_version unless result_bindfs_version.nil? result.install_bindfs_from_source = (install_bindfs_from_source || other.install_bindfs_from_source) result. = .merge(other.) result.binded_folders = binded_folders.merge(other.binded_folders) result.skip_validations = (skip_validations + other.skip_validations).uniq end end |
#source_version=(value) ⇒ Object
34 35 36 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 34 def source_version=(value) @bindfs_version = Gem::Version.new(value.to_s) end |
#validate(_machine) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 75 def validate(_machine) errors = _detected_errors binded_folders.each do |_, folder| validator = Bindfs::Validators::Config.new(folder) errors << validator.errors unless validator.valid? end { 'vagrant-bindfs' => errors.flatten } end |