<commit_before>require_relative "concerns/attr_accessor_with_default"
require 'securerandom'
require 'pathname'
require 'carrierwave'
require 'active_job'
require 'jobba'
require 'fog'

module Lanes

    class Configuration
        include Concerns::AttrAccessorWithDefault

        # Since changing a config value inadvertently
        # can have pretty drastic consequences that might not be
        # discovered immediately, we log each time a value is changed
        def self.config_option( name, default, options={} )
            define_method( "#{name}=" ) do | value |
                old_value = self.send( name )
                if old_value && !options[:silent]
                    Lanes.logger.info "Config option #{name} changed from '#{old_value.inspect}' to '#{value.inspect}'"
                end
                instance_variable_set( "@#{name}", value )
                if @observers.has_key?(name)
                    @observers[name].each{ |cb| cb.call(value, old_value) }
                end
            end
            attr_reader_with_default(name, default)
        end

        def initialize
            @observers=Hash.new{ |hash,key| hash[key] = Array.new }
        end

        def on_change(config, &block)
            @observers[config.to_sym] << block
        end

        def get(config, &block)
            value = self.send(config.to_sym)
            if block
                on_change(config,&block)
                block.call( value, value )
            end
            value
        end

        def self.apply
            ActiveJob::Base.queue_adapter = Lanes.env.test? ? :test : :resque
            Lanes::Job::FailureLogger.configure
            Jobba.configure do |config|
                config.redis_options = Lanes.config.redis
                config.namespace = 'jobba'
            end

            CarrierWave.configure do |config|
                settings = Lanes::SystemSettings.for_ext('lanes')
                config.storage = settings.file_storage ? settings.file_storage.to_sym : :file
                config.root = lambda {
                    Lanes::SystemSettings.for_ext('lanes').storage_dir ||
                        Lanes::Extensions.controlling.root_path.join('public')
                }
                config.asset_host = Lanes.config.mounted_at + '/file'
                config.fog_credentials = settings.fog_credentials
                config.ignore_integrity_errors = false
                config.ignore_processing_errors = false
                config.ignore_download_errors = false
            end<commit_msg>Convert root_path from pathname to string<commit_after>require_relative "concerns/attr_accessor_with_default"
require 'securerandom'
require 'pathname'
require 'carrierwave'
require 'active_job'
require 'jobba'
require 'fog'

module Lanes

    class Configuration
        include Concerns::AttrAccessorWithDefault

        # Since changing a config value inadvertently
        # can have pretty drastic consequences that might not be
        # discovered immediately, we log each time a value is changed
        def self.config_option( name, default, options={} )
            define_method( "#{name}=" ) do | value |
                old_value = self.send( name )
                if old_value && !options[:silent]
                    Lanes.logger.info "Config option #{name} changed from '#{old_value.inspect}' to '#{value.inspect}'"
                end
                instance_variable_set( "@#{name}", value )
                if @observers.has_key?(name)
                    @observers[name].each{ |cb| cb.call(value, old_value) }
                end
            end
            attr_reader_with_default(name, default)
        end

        def initialize
            @observers=Hash.new{ |hash,key| hash[key] = Array.new }
        end

        def on_change(config, &block)
            @observers[config.to_sym] << block
        end

        def get(config, &block)
            value = self.send(config.to_sym)
            if block
                on_change(config,&block)
                block.call( value, value )
            end
            value
        end

        def self.apply
            ActiveJob::Base.queue_adapter = Lanes.env.test? ? :test : :resque
            Lanes::Job::FailureLogger.configure
            Jobba.configure do |config|
                config.redis_options = Lanes.config.redis
                config.namespace = 'jobba'
            end

            CarrierWave.configure do |config|
                settings = Lanes::SystemSettings.for_ext('lanes')
                config.storage = settings.file_storage ? settings.file_storage.to_sym : :file
                config.root = lambda {
                    Lanes::SystemSettings.for_ext('lanes').storage_dir ||
                        Lanes::Extensions.controlling.root_path.join('public').to_s
                }
                config.asset_host = Lanes.config.mounted_at + '/file'
                config.fog_credentials = settings.fog_credentials
                config.ignore_integrity_errors = false
                config.ignore_processing_errors = false
                config.ignore_download_errors = false
            end
{'fraction_non_alphanumeric': 0.08736740597878495, 'fraction_numerical': 0.0, 'mean_word_length': 1.8169473112438892, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7027759', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1341, 'n_words': 306}