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

      ALLOWED_SCOPES = %w( box machine )

      def initialize
        @scope = UNSET_VALUE
        @auto_detect = UNSET_VALUE
        @synced_folder_opts = UNSET_VALUE
        @ui = Vagrant::UI::Colored.new
      end

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

      def enable_nfs=(value)
        @ui.warn "The `enable_nfs` config for vagrant-cachier has been deprecated " \
                "and will be removed on 0.7.0, please use " \
                "`synced_folder_opts = { type: :nfs }` instead.\n"

        @synced_folder_opts = { type: :nfs } if value
      end

      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

      def enabled?
        return @enabled unless @enabled.nil?

        @enabled = (@auto_detect != UNSET_VALUE || @buckets != nil)
      end

      def disable!
        @enabled = false
      end

      def finalize!
        return unless enabled?

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

      private

      def backed_by_cloud_provider?(machine)
        CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
      end
    end
  end
end<commit_msg>Trigger plugin activation by setting cache scope [GH-17]<commit_after>module VagrantPlugins
  module Cachier
    class Config < Vagrant.plugin(2, :config)
      attr_accessor :scope, :auto_detect, :synced_folder_opts
      attr_reader   :buckets

      ALLOWED_SCOPES = %w( box machine )

      def initialize
        @scope = UNSET_VALUE
        @auto_detect = UNSET_VALUE
        @synced_folder_opts = UNSET_VALUE
        @ui = Vagrant::UI::Colored.new
      end

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

      def enable_nfs=(value)
        @ui.warn "The `enable_nfs` config for vagrant-cachier has been deprecated " \
                "and will be removed on 0.7.0, please use " \
                "`synced_folder_opts = { type: :nfs }` instead.\n"

        @synced_folder_opts = { type: :nfs } if value
      end

      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

      def enabled?
        return @enabled unless @enabled.nil?

        @enabled = @scope != UNSET_VALUE
      end

      def disable!
        @enabled = false
      end

      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

      private

      def backed_by_cloud_provider?(machine)
        CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09142019066242972, 'fraction_numerical': 0.004399902224395014, 'mean_word_length': 1.9890430971512052, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7365085', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1270, 'n_words': 279}