<commit_before>require 'gir_ffi/builders/callback_builder'
require 'gir_ffi/builders/constant_builder'
require 'gir_ffi/builders/enum_builder'
require 'gir_ffi/builders/interface_builder'
require 'gir_ffi/builders/object_builder'
require 'gir_ffi/builders/struct_builder'
require 'gir_ffi/builders/signal_closure_builder'
require 'gir_ffi/builders/unintrospectable_builder'
require 'gir_ffi/builders/union_builder'
require 'gir_ffi/builders/vfunc_builder'

module GirFFI
  module Builders
    # Builds a class based on information found in the introspection
    # repository.
    module TypeBuilder
      CACHE = {}

      TYPE_MAP = {
        callback:         CallbackBuilder,
        constant:         ConstantBuilder,
        enum:             EnumBuilder,
        flags:            EnumBuilder,
        interface:        InterfaceBuilder,
        object:           ObjectBuilder,
        struct:           StructBuilder,
        union:            UnionBuilder,
        unintrospectable: UnintrospectableBuilder
      }

      def self.build info
        TYPE_MAP[info.info_type].new(info).build_class
      end

      # TODO: Pull up to include :function and :module
      def self.builder_for info
        TYPE_MAP[info.info_type].new(info)
      end
    end
  end
end<commit_msg>DRY up TypeBuilder code<commit_after>require 'gir_ffi/builders/callback_builder'
require 'gir_ffi/builders/constant_builder'
require 'gir_ffi/builders/enum_builder'
require 'gir_ffi/builders/interface_builder'
require 'gir_ffi/builders/object_builder'
require 'gir_ffi/builders/struct_builder'
require 'gir_ffi/builders/signal_closure_builder'
require 'gir_ffi/builders/unintrospectable_builder'
require 'gir_ffi/builders/union_builder'
require 'gir_ffi/builders/vfunc_builder'

module GirFFI
  module Builders
    # Builds a class based on information found in the introspection
    # repository.
    module TypeBuilder
      CACHE = {}

      TYPE_MAP = {
        callback:         CallbackBuilder,
        constant:         ConstantBuilder,
        enum:             EnumBuilder,
        flags:            EnumBuilder,
        interface:        InterfaceBuilder,
        object:           ObjectBuilder,
        struct:           StructBuilder,
        union:            UnionBuilder,
        unintrospectable: UnintrospectableBuilder
      }

      def self.build info
        builder_for(info).build_class
      end

      # TODO: Pull up to include :function and :module
      def self.builder_for info
        TYPE_MAP[info.info_type].new(info)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06705653021442495, 'fraction_numerical': 0.0, 'mean_word_length': 2.6552706552706553, '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': '349203', 'n_tokens_mistral': 776, 'n_tokens_neox': 763, 'n_words': 158}