Sha256: fd4b9756986f2e2eebcdf05a93903324b4a75942ab1b6ed60e9481b9e4221a60

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module VagrantPlugins
  module Cachier
    class Config < Vagrant.plugin(2, :config)
      attr_accessor :scope, :auto_detect, :enable_nfs
      attr_reader   :buckets

      ALLOWED_SCOPES = %w( box machine )

      def initialize
        @scope       = UNSET_VALUE
        @auto_detect = UNSET_VALUE
        @enable_nfs  = UNSET_VALUE
      end

      def enable(bucket, opts = {})
        (@buckets ||= {})[bucket] = opts
      end

      def validate(machine)
        errors = _detected_errors

        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

      def finalize!
        return unless enabled?

        @scope       = :box  if @scope == UNSET_VALUE
        @auto_detect = false if @auto_detect == UNSET_VALUE
        @enable_nfs  = false if @enable_nfs == UNSET_VALUE
        @buckets     = @buckets ? @buckets.dup : {}
      end

      def enabled?
        @enabled ||= @auto_detect != UNSET_VALUE ||
                     @buckets != nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-cachier-0.5.1 lib/vagrant-cachier/config.rb
vagrant-cachier-0.5.0 lib/vagrant-cachier/config.rb
vagrant-cachier-0.4.1 lib/vagrant-cachier/config.rb
vagrant-cachier-0.4.0 lib/vagrant-cachier/config.rb
vagrant-cachier-0.3.3 lib/vagrant-cachier/config.rb
vagrant-cachier-0.3.2 lib/vagrant-cachier/config.rb
vagrant-cachier-0.3.1 lib/vagrant-cachier/config.rb
vagrant-cachier-0.3.0 lib/vagrant-cachier/config.rb