Class: VagrantPlugins::Cachier::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Cachier::Config
- Defined in:
- lib/vagrant-cachier/config.rb
Constant Summary collapse
- ALLOWED_SCOPES =
%w( box machine )
Instance Attribute Summary collapse
-
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
-
#buckets ⇒ Object
readonly
Returns the value of attribute buckets.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#synced_folder_opts ⇒ Object
Returns the value of attribute synced_folder_opts.
Instance Method Summary collapse
- #disable! ⇒ Object
- #enable(bucket, opts = {}) ⇒ Object
- #enabled? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 |
# File 'lib/vagrant-cachier/config.rb', line 9 def initialize @scope = UNSET_VALUE @auto_detect = UNSET_VALUE @synced_folder_opts = UNSET_VALUE @ui = Vagrant::UI::Colored.new end |
Instance Attribute Details
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def auto_detect @auto_detect end |
#buckets ⇒ Object (readonly)
Returns the value of attribute buckets.
5 6 7 |
# File 'lib/vagrant-cachier/config.rb', line 5 def buckets @buckets end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def scope @scope end |
#synced_folder_opts ⇒ Object
Returns the value of attribute synced_folder_opts.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def synced_folder_opts @synced_folder_opts end |
Instance Method Details
#disable! ⇒ Object
44 45 46 |
# File 'lib/vagrant-cachier/config.rb', line 44 def disable! @enabled = false end |
#enable(bucket, opts = {}) ⇒ Object
16 17 18 |
# File 'lib/vagrant-cachier/config.rb', line 16 def enable(bucket, opts = {}) (@buckets ||= {})[bucket] = opts end |
#enabled? ⇒ Boolean
38 39 40 41 42 |
# File 'lib/vagrant-cachier/config.rb', line 38 def enabled? return @enabled unless @enabled.nil? @enabled = @scope != UNSET_VALUE end |
#finalize! ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/vagrant-cachier/config.rb', line 48 def finalize! return unless enabled? @auto_detect = true if @auto_detect == UNSET_VALUE @synced_folder_opts = nil if @synced_folder_opts == UNSET_VALUE @buckets = @buckets ? @buckets.dup : {} end |
#validate(machine) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-cachier/config.rb', line 20 def validate(machine) errors = _detected_errors if enabled? && backed_by_cloud_provider?(machine) machine.ui.warn(I18n.t('vagrant_cachier.backed_by_cloud_provider', provider: machine.provider_name)) disable! end if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s) errors << I18n.t('vagrant_cachier.unknown_cache_scope', allowed: ALLOWED_SCOPES.inspect, cache_scope: @scope) end { "vagrant cachier" => errors } end |