<commit_before>class AngryMob
  class Builder
    class Targets
      def initialize(name,options={},&blk)
        @dependencies = options[:requires] || []
        @name = name
        @blk  = blk
      end

      def bind(mob)
        @mob = mob
        instance_eval(&@blk)
        self
      end

      def TargetHelpers(&blk)
        @helpers ||= Module.new
        @helpers.module_eval(&blk)
      end

      def SingletonTarget(nickname,&blk)
        add_class(nickname,SingletonTarget,&blk)
      end

      def Target(nickname,&blk)
        add_class(nickname,Target,&blk)
      end
      
      def method_missing(method,*args,&blk)
        if args.size == 1
          add_class(args.first, @mob.target_classes[method], &blk)
        else
          super
        end
      end

      protected
      def add_class(nickname,superclass,&blk)
        klass = @mob.target_classes[nickname] = Class.new(superclass, &blk)
        if h = @helpers
          klass.module_eval {
            @nickname = nickname
            include h
          }
        end
      end
    end
  end
end<commit_msg>fixed nicknames not being set if no helpers<commit_after>class AngryMob
  class Builder
    class Targets
      def initialize(name,options={},&blk)
        @dependencies = options[:requires] || []
        @name = name
        @blk  = blk
      end

      def bind(mob)
        @mob = mob
        instance_eval(&@blk)
        self
      end

      def TargetHelpers(&blk)
        @helpers ||= Module.new
        @helpers.module_eval(&blk)
      end

      def SingletonTarget(nickname,&blk)
        add_class(nickname,SingletonTarget,&blk)
      end

      def Target(nickname,&blk)
        add_class(nickname,Target,&blk)
      end
      
      def method_missing(method,*args,&blk)
        if args.size == 1
          add_class(args.first, @mob.target_classes[method], &blk)
        else
          super
        end
      end

      protected
      def add_class(nickname,superclass,&blk)
        # TODO disallow duplicate definition
        klass = @mob.target_classes[nickname.to_sym] = Class.new(superclass, &blk)
        h = @helpers

        klass.module_eval {
          @nickname = nickname.to_sym
          include h if h
        }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0939982347749338, 'fraction_numerical': 0.00088261253309797, 'mean_word_length': 1.83375, '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': '224194', 'n_tokens_mistral': 685, 'n_tokens_neox': 677, 'n_words': 146}