Sha256: 9172b94aea93e09cdeb18a0c6f25d8b9b6f5498bbc73a51311a11fed76f4ec18

Contents?: true

Size: 711 Bytes

Versions: 4

Compression:

Stored size: 711 Bytes

Contents

require 'hedgelog/scrub_replacement'

class Hedgelog
  class Scrubber
    def initialize(replacements = nil)
      @replacements = [ScrubReplacement.new('password', '**********')]
      replacements&.each do |x|
        @replacements << if x.instance_of?(ScrubReplacement)
                           x
                         else
                           ScrubReplacement.new(x, '**********')
                         end
      end
    end

    def scrub(data)
      # Need to Marshal.dump/Marshal.load to deep copy the input so that scrubbing doesn't change global state
      d = Marshal.load(Marshal.dump(data))
      @replacements.each do |r|
        r.scrub_hash(d)
      end
      d
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hedgelog-0.2.1.alpha.4 lib/hedgelog/scrubber.rb
hedgelog-0.2.1.alpha.3 lib/hedgelog/scrubber.rb
hedgelog-0.2.1.alpha.2 lib/hedgelog/scrubber.rb
hedgelog-0.2.1.alpha1 lib/hedgelog/scrubber.rb