Class: VagrantBindfs::Vagrant::Config
- Inherits:
-
Object
- Object
- VagrantBindfs::Vagrant::Config
- Defined in:
- lib/vagrant-bindfs/vagrant/config.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_OPTIONS =
{ 'force-user' => 'vagrant', 'force-group' => 'vagrant', 'perms' => 'u=rwX:g=rD:o=rD' }.freeze
Instance Attribute Summary collapse
-
#bindfs_version ⇒ Object
Returns the value of attribute bindfs_version.
-
#bound_folders ⇒ Object
Returns the value of attribute bound_folders.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#force_empty_mountpoints ⇒ Object
Returns the value of attribute force_empty_mountpoints.
-
#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
- #bound_folder=(*_any_variant) ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
rubocop:disable Lint/MissingSuper.
-
#merge(other) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #source_version=(value) ⇒ Object
- #validate(_machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
rubocop:disable Lint/MissingSuper
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 21 def initialize # rubocop:disable Lint/MissingSuper @debug = false @bindfs_version = UNSET_VALUE @install_bindfs_from_source = false @bound_folders = {} @default_options = UNSET_VALUE @skip_validations = [] @force_empty_mountpoints = false end |
Instance Attribute Details
#bindfs_version ⇒ Object
Returns the value of attribute bindfs_version.
17 18 19 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 17 def bindfs_version @bindfs_version end |
#bound_folders ⇒ Object
Returns the value of attribute bound_folders.
17 18 19 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 17 def bound_folders @bound_folders end |
#debug ⇒ Object
Returns the value of attribute debug.
12 13 14 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 12 def debug @debug end |
#default_options ⇒ Object
Returns the value of attribute default_options.
12 13 14 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 12 def @default_options end |
#force_empty_mountpoints ⇒ Object
Returns the value of attribute force_empty_mountpoints.
12 13 14 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 12 def force_empty_mountpoints @force_empty_mountpoints end |
#install_bindfs_from_source ⇒ Object
Returns the value of attribute install_bindfs_from_source.
12 13 14 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 12 def install_bindfs_from_source @install_bindfs_from_source end |
#skip_validations ⇒ Object
Returns the value of attribute skip_validations.
17 18 19 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 17 def skip_validations @skip_validations end |
Instance Method Details
#bind_folder(source, destination, options = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 58 def bind_folder(source, destination, = {}) hook = .delete(:after) || :synced_folders folder = Bindfs::Folder.new(hook, source, destination, ) @bound_folders[folder.id] = folder end |
#bound_folder=(*_any_variant) ⇒ Object
54 55 56 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 54 def bound_folder=(*_any_variant) raise VagrantBindfs::Vagrant::ConfigError, :bound_folders end |
#finalize! ⇒ Object
77 78 79 80 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 77 def finalize! @bindfs_version = :latest if @bindfs_version == UNSET_VALUE self. = DEFAULT_OPTIONS if == UNSET_VALUE end |
#merge(other) ⇒ Object
rubocop:disable Metrics/AbcSize
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 64 def merge(other) # rubocop:disable Metrics/AbcSize super.tap do |result| %i[debug force_empty_mountpoints install_bindfs_from_source].each do |boolean| result.send(:"#{boolean}=", (send(boolean) || other.send(boolean))) end result.bound_folders = bound_folders.merge(other.bound_folders) result.skip_validations = (skip_validations + other.skip_validations).uniq result.bindfs_version = merge_bindfs_version(other) unless merge_bindfs_version(other) == UNSET_VALUE result. = (other) unless (other) == UNSET_VALUE end end |
#source_version=(value) ⇒ Object
38 39 40 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 38 def source_version=(value) @bindfs_version = Gem::Version.new(value.to_s) end |
#validate(_machine) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/vagrant-bindfs/vagrant/config.rb', line 82 def validate(_machine) errors = _detected_errors bound_folders.each_value do |folder| validator = Bindfs::Validators::Config.new(folder) errors << validator.errors unless validator.valid? end { 'vagrant-bindfs' => errors.flatten } end |