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.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 15 def initialize @debug = false @bindfs_version = UNSET_VALUE @install_bindfs_from_source = false @binded_folders = {} @default_options = 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.
11 12 13 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 11 def binded_folders @binded_folders end |
#bindfs_version ⇒ Object
Returns the value of attribute bindfs_version.
7 8 9 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 7 def bindfs_version @bindfs_version end |
#debug ⇒ Object
Returns the value of attribute debug.
5 6 7 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 5 def debug @debug end |
#default_options ⇒ Object
Returns the value of attribute default_options.
10 11 12 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 10 def @default_options end |
#install_bindfs_from_source ⇒ Object
Returns the value of attribute install_bindfs_from_source.
8 9 10 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 8 def install_bindfs_from_source @install_bindfs_from_source end |
#skip_validations ⇒ Object
Returns the value of attribute skip_validations.
13 14 15 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 13 def skip_validations @skip_validations end |
Instance Method Details
#bind_folder(source, destination, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 49 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
45 46 47 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 45 def binded_folder=(*_any_variant) raise VagrantBindfs::Vagrant::ConfigError, :binded_folders end |
#finalize! ⇒ Object
70 71 72 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 70 def finalize! @bindfs_version = :latest if @bindfs_version == UNSET_VALUE end |
#merge(other) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 55 def merge(other) super.tap do |result| result.debug = (debug || other.debug) result_bindfs_version = [bindfs_version, other.bindfs_version].select { |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
33 34 35 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 33 def source_version=(value) @bindfs_version = Gem::Version.new(value.to_s) end |
#validate(_machine) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 74 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 |