<commit_before>module Lanes

    class SystemSettings < Lanes::Model

        has_one :logo, as: :owner, :class_name=>'Lanes::Asset', :dependent => :destroy

        class ExtensionSettings < OpenStruct
            def initialize(ext_id, settings)
                @extension_id = ext_id
                super(settings)
            end
            def persist!
                SystemSettings.persist!(@extension_id, self.to_h)
            end
            def apply!
                CarrierWave.configure do |config|
                    config.storage = Lanes.config.storage_type.to_sym
                    config.root = lambda {
                        Lanes::Extensions.controlling
                            .root_path.join('public/files').to_s
                    }
                    config.asset_host = Lanes.config.api_path + '/asset'
                    config.fog_credentials = self.fog_credentials
                    config.ignore_integrity_errors = false
                    config.ignore_processing_errors = false
                    config.ignore_download_errors = false
                end
            end
        end

        after_commit :notify_updated
        def notify_updated
            Lanes.redis_connection.publish('lanes-system-configuration-update', self.id)
        end

        class << self
            def config
                @config ||= SystemSettings.find_or_create_by(id: Lanes.config.configuration_id)
            end

            def for_ext(extension_id)
                ExtensionSettings.new(extension_id, config.settings[extension_id])<commit_msg>test if Fog is loaded before setting config<commit_after>module Lanes

    class SystemSettings < Lanes::Model

        has_one :logo, as: :owner, :class_name=>'Lanes::Asset', :dependent => :destroy

        class ExtensionSettings < OpenStruct
            def initialize(ext_id, settings)
                @extension_id = ext_id
                super(settings)
            end
            def persist!
                SystemSettings.persist!(@extension_id, self.to_h)
            end
            def apply!
                CarrierWave.configure do |config|
                    config.storage = Lanes.config.storage_type.to_sym
                    config.root = lambda {
                        Lanes::Extensions.controlling
                            .root_path.join('public/files').to_s
                    }
                    config.asset_host = Lanes.config.api_path + '/asset'
                    if self.fog_credentials and Object.const_defined?(:Fog)
                        config.fog_credentials = self.fog_credentials
                    end
                    config.ignore_integrity_errors = false
                    config.ignore_processing_errors = false
                    config.ignore_download_errors = false
                end
            end
        end

        after_commit :notify_updated
        def notify_updated
            Lanes.redis_connection.publish('lanes-system-configuration-update', self.id)
        end

        class << self
            def config
                @config ||= SystemSettings.find_or_create_by(id: Lanes.config.configuration_id)
            end

            def for_ext(extension_id)
                ExtensionSettings.new(extension_id, config.settings[extension_id])
{'fraction_non_alphanumeric': 0.0700060350030175, 'fraction_numerical': 0.0, 'mean_word_length': 1.5170842824601367, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4795709', 'n_tokens_mistral': 841, 'n_tokens_neox': 790, 'n_words': 153}