<commit_before>module Inch
  module CodeObject
    module Proxy
      def self.for(code_object)
        class_for(code_object).new(code_object)
      end

      private
      def self.class_for(code_object)
        class_name = code_object.class.to_s.split('::').last
        eval("::Inch::CodeObject::Proxy::#{class_name}")
      rescue
        Base
      end
    end
  end
end

require_relative 'proxy/base'
require_relative 'proxy/namespace_object'
require_relative 'proxy/class_object'
require_relative 'proxy/constant_object'
require_relative 'proxy/method_object'
require_relative 'proxy/method_parameter_object'
require_relative 'proxy/module_object'<commit_msg>Add caching for proxy code objects<commit_after>module Inch
  module CodeObject
    module Proxy
      class << self
        def for(code_object)
          @cache ||= {}
          if proxy_object = @cache[cache_key(code_object)]
            proxy_object
          else
            @cache[cache_key(code_object)] = class_for(code_object).new(code_object)
          end
        end

        private

        def class_for(code_object)
          class_name = code_object.class.to_s.split('::').last
          eval("::Inch::CodeObject::Proxy::#{class_name}")
        rescue
          Base
        end

        def cache_key(o)
          o.path
        end
      end
    end
  end
end

require_relative 'proxy/base'
require_relative 'proxy/namespace_object'
require_relative 'proxy/class_object'
require_relative 'proxy/constant_object'
require_relative 'proxy/method_object'
require_relative 'proxy/method_parameter_object'
require_relative 'proxy/module_object'
{'fraction_non_alphanumeric': 0.0878918254456054, 'fraction_numerical': 0.0, 'mean_word_length': 3.0397022332506203, 'pattern_counts': {'":': 2, '<': 5, '<?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': '1980271', 'n_tokens_mistral': 482, 'n_tokens_neox': 484, 'n_words': 91}