<commit_before>module AbAdmin
  module Models
    module Settings
      extend ActiveSupport::Concern

      included do
        extend ActiveModel::Naming
        extend ActiveRecord::Translation
        class_attribute :base_class
        self.base_class = self
      end

      module ClassMethods
        def load_config
          configatron.configure_from_hash instance.all
          configatron
        end
      end

      def initialize
        @data = {}
        @editable_path = find_editable_path
        @paths = find_paths
      end

      def find_editable_path
        edited_settings_paths = [
            Rails.root.join('config', 'settings', "#{Rails.env}.local.yml"),
            Rails.root.join('config', 'settings', 'settings.local.yml')
        ]
        path = edited_settings_paths.detect { |path| File.exists?(path) }
        path or raise("Create settings file for editing: #{edited_settings_paths.join(' or ')}")
      end

      def find_paths
        [
            Rails.root.join('config', 'settings', 'settings.yml'),
            Rails.root.join('config', 'settings', "#{Rails.env}.yml"),
            @editable_path
        ].find_all { |path| File.exists?(path) }
      end

      def all
        @paths.each do |path|
          @data.deep_merge!(YAML.load_file(path))
        end
        @data
      end

      def editable
        YAML.load_file(@editable_path) rescue {}
      end

      def save(raw_config)
        conf = {}<commit_msg>add editable_paths config to Settings<commit_after>module AbAdmin
  module Models
    module Settings
      extend ActiveSupport::Concern

      included do
        extend ActiveModel::Naming
        extend ActiveRecord::Translation
        class_attribute :base_class, :editable_paths
        self.base_class = self
        self.editable_paths = [
            Rails.root.join('config', 'settings', "#{Rails.env}.local.yml"),
            Rails.root.join('config', 'settings', 'settings.local.yml')
        ]
      end

      module ClassMethods
        def load_config
          configatron.configure_from_hash instance.all
          configatron
        end
      end

      def initialize
        @data = {}
        @editable_path = find_editable_path
        @paths = find_paths
      end

      def find_editable_path
        path = editable_paths.detect { |path| File.exists?(path) }
        path or raise("Create settings file for editing: #{editable_paths.join(' or ')}")
      end

      def find_paths
        [
            Rails.root.join('config', 'settings', 'settings.yml'),
            Rails.root.join('config', 'settings', "#{Rails.env}.yml"),
            @editable_path
        ].find_all { |path| File.exists?(path) }
      end

      def all
        @paths.each do |path|
          @data.deep_merge!(YAML.load_file(path))
        end
        @data
      end

      def editable
        YAML.load_file(@editable_path) rescue {}
      end

      def save(raw_config)
        conf = {}
{'fraction_non_alphanumeric': 0.10124453414059872, 'fraction_numerical': 0.0, 'mean_word_length': 1.9889447236180904, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4128382', 'n_tokens_mistral': 872, 'n_tokens_neox': 842, 'n_words': 183}