<commit_before>require 'set'

module SignedForm
  class Digestor
    attr_accessor :view_paths

    def initialize(template)
      @view_paths = Set.new []
      @views  = Set.new []
      self << template
    end

    def <<(template)
      virtual_path = get_virtual_path(template)
      raise Errors::UnableToDigest, "Unable to get virtual path from template" unless virtual_path

      @views << virtual_path
      @view_paths += template.view_paths.map(&:to_s)
      @digest = nil
    rescue NoMethodError
      raise Errors::UnableToDigest, "Unable get view paths from template"
    end

    def marshal_dump
      [@views.to_a, to_s]
    end

    def marshal_load(input)
      @views, @digest = *input
      @view_paths = []
      @digest.taint
    end

    def to_s
      @digest ||= SignedForm.digest_store.fetch(@views.sort.join(':')) { hash_files(glob_files) }
    end
    alias_method :digest, :to_s<commit_msg>Splat operator not needed here.<commit_after>require 'set'

module SignedForm
  class Digestor
    attr_accessor :view_paths

    def initialize(template)
      @view_paths = Set.new []
      @views  = Set.new []
      self << template
    end

    def <<(template)
      virtual_path = get_virtual_path(template)
      raise Errors::UnableToDigest, "Unable to get virtual path from template" unless virtual_path

      @views << virtual_path
      @view_paths += template.view_paths.map(&:to_s)
      @digest = nil
    rescue NoMethodError
      raise Errors::UnableToDigest, "Unable get view paths from template"
    end

    def marshal_dump
      [@views.to_a, to_s]
    end

    def marshal_load(input)
      @views, @digest = input
      @view_paths = []
      @digest.taint
    end

    def to_s
      @digest ||= SignedForm.digest_store.fetch(@views.sort.join(':')) { hash_files(glob_files) }
    end
    alias_method :digest, :to_s
{'fraction_non_alphanumeric': 0.09876543209876543, 'fraction_numerical': 0.0, 'mean_word_length': 2.819672131147541, 'pattern_counts': {'":': 0, '<': 15, '<?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': '5495999', 'n_tokens_mistral': 618, 'n_tokens_neox': 592, 'n_words': 145}