<commit_before>module Approvals
  module Namers
    class DirectoryNamer < RSpecNamer

      def initialize(example)
        @name = directorize example
      end

      private

      def directorize(example)
        parts     = [ ]
        metadata  = example.metadata

        begin
          parts << metadata[ :description ]
        end while metadata = metadata[ :example_group ]

        parts.reverse.map { |p| normalize p }.join '/'
      end
    end
  end
end<commit_msg>Fixed approvals path<commit_after>module Approvals
  module Namers
    class DirectoryNamer < RSpecNamer

      def initialize(example)
        @name = directorize example
      end

      private

      def directorize(example)
        parts     = [ ]
        metadata  = example.metadata

        approvals_name_for = lambda do |metadata|
          description = normalize metadata[:description]
          example_group = if metadata.key?(:example_group)
                            metadata[:example_group]
                          else
                            metadata[:parent_example_group]
                          end

          if example_group
            [approvals_name_for[example_group], description].join('/')
          else
            description
          end
        end

        approvals_name_for[example.metadata]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06078576723498888, 'fraction_numerical': 0.0, 'mean_word_length': 1.6574803149606299, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2543239', 'n_tokens_mistral': 345, 'n_tokens_neox': 327, 'n_words': 84}