<commit_before>module INotify
  class Event
    attr_reader :cookie
    attr_reader :name

    def self.consume(data)
      return nil if data.empty?
      ev = new(data)
      data.replace data[ev.size..-1]
      ev
    end

    def initialize(data)
      ptr = FFI::MemoryPointer.from_string(data)
      @native = Native::Event.new(ptr)
      @cookie = @native[:cookie]
      @name = data[@native.size, @native[:len]]
    end

    def callback!
      watcher.callback!(self)
    end

    def size
      @native.size + @native[:len]
    end

    def watcher
      @watcher ||= Watcher.from_wd(@native[:wd])
    end

    def flags
      @flags ||= Native::Flags.from_mask(@native[:mask])
    end
  end
end
<commit_msg>Don't include stray null bytes in the event name field.<commit_after>module INotify
  class Event
    attr_reader :cookie
    attr_reader :name

    def self.consume(data)
      return nil if data.empty?
      ev = new(data)
      data.replace data[ev.size..-1]
      ev
    end

    def initialize(data)
      ptr = FFI::MemoryPointer.from_string(data)
      @native = Native::Event.new(ptr)
      @cookie = @native[:cookie]
      @name = data[@native.size, @native[:len]].gsub(/\0+$/, '')
    end

    def callback!
      watcher.callback!(self)
    end

    def size
      @native.size + @native[:len]
    end

    def watcher
      @watcher ||= Watcher.from_wd(@native[:wd])
    end

    def flags
      @flags ||= Native::Flags.from_mask(@native[:mask])
    end
  end
end

{'fraction_non_alphanumeric': 0.12642140468227425, 'fraction_numerical': 0.002006688963210702, 'mean_word_length': 2.3846153846153846, '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': '6238684', 'n_tokens_mistral': 503, 'n_tokens_neox': 489, 'n_words': 115}