<commit_before>module Pathmap
  class Map
    include Enumerable
    attr_reader :path, :names, :attributes, :current_path

    def initialize(path, names: {})
      @path = path
      @names = names
      @attributes = {file: "#{path.basename}"}
    end

    def each(&block)
      names.each(&block)
    end

    def name(regex)
      @current_path = find(regex)
      cp = @current_path and cp.basename.to_s
    end

    def call
      each do |key, value|
        create_method(key) {name(value)}
        attributes[key] = name(value)
      end
    end

    def create_method(name, &block)
      self.class.send(:define_method, name, &block)
    end

  private
    def find(regex, direction: :ascend)
      path.
        to_enum(direction).<commit_msg>pathmap create default file 'name'<commit_after>module Pathmap
  class Map
    include Enumerable
    attr_reader :path, :names, :attributes, :current_path

    def initialize(path, names: {})
      @path = path
      @names = names
      @attributes = {file: "#{path.basename}"}
      create_method(:file) {"#{path.basename}"}
    end

    def each(&block)
      names.each(&block)
    end

    def name(regex)
      @current_path = find(regex)
      cp = @current_path and cp.basename.to_s
    end

    def call
      each do |key, value|
        create_method(key) {name(value)}
        attributes[key] = name(value)
      end
    end

    def create_method(name, &block)
      self.class.send(:define_method, name, &block)
    end

  private
    def find(regex, direction: :ascend)
      path.
        to_enum(direction).
{'fraction_non_alphanumeric': 0.11321948134092347, 'fraction_numerical': 0.0, 'mean_word_length': 2.469298245614035, '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': '7013806', 'n_tokens_mistral': 514, 'n_tokens_neox': 502, 'n_words': 127}