<commit_before>verbose = $VERBOSE; $VERBOSE = false; require 'sequel'; $VERBOSE = verbose

Sequel.extension :migration

module Kamerling class Repos
  class << self
    def << object, repos: repos
      repos[object.class] << object
    end

    def [] klass, repo: repos[klass]
      repo
    end

    def db= db
      Sequel::Migrator.run db, "#{__dir__}/migrations"
      @repos = nil
      @db    = db
    end

    private

    def db
      @db ||= self.db = Sequel.sqlite
    end

    def repos
      @repos ||= {
        Client       => Repo.new(db[:clients],       Client),
        Project      => Repo.new(db[:projects],      Project),
        Registration => Repo.new(db[:registrations], Registration),
        Result       => Repo.new(db[:results],       Result),
        Task         => Repo.new(db[:tasks],         Task),
      }
    end
  end
end end<commit_msg>refactor Repos.repos<commit_after>verbose = $VERBOSE; $VERBOSE = false; require 'sequel'; $VERBOSE = verbose

Sequel.extension :migration

module Kamerling class Repos
  class << self
    def << object, repos: repos
      repos[object.class] << object
    end

    def [] klass, repo: repos[klass]
      repo
    end

    def db= db
      Sequel::Migrator.run db, "#{__dir__}/migrations"
      @repos = nil
      @db    = db
    end

    private

    def db
      @db ||= self.db = Sequel.sqlite
    end

    def repos
      @repos ||= Hash.new do |repos, klass|
        table = "#{klass.name.split('::').last.downcase}s".to_sym
        repos[klass] = Repo.new db[table], klass
      end
    end
  end
end end
{'fraction_non_alphanumeric': 0.12563131313131312, 'fraction_numerical': 0.0, 'mean_word_length': 2.107843137254902, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 8, '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': '3062626', 'n_tokens_mistral': 545, 'n_tokens_neox': 523, 'n_words': 134}