Sha256: 9ba9b1ba87054ed8751833dd993a48874a1ac6ec5e3d7f0e66dbcc73bc2e7444

Contents?: true

Size: 504 Bytes

Versions: 106

Compression:

Stored size: 504 Bytes

Contents

module Temple
  module Filters
    # Erase expressions with a certain type
    #
    # @api public
    class Eraser < Filter
      # [] is the empty type => keep all
      define_options :erase, keep: [[]]

      def compile(exp)
        exp.first == :multi || (do?(:keep, exp) && !do?(:erase, exp)) ?
          super(exp) : [:multi]
      end

      protected

      def do?(list, exp)
        options[list].to_a.map {|type| [*type] }.any? {|type| exp[0,type.size] == type }
      end
    end
  end
end

Version data entries

106 entries across 92 versions & 7 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-6.1.2 bundle/ruby/3.3.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-6.1.1 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-6.1.0 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-6.0.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-6.0.0 bundle/ruby/3.0.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-5.4.1 bundle/ruby/3.1.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
temple-0.10.0 lib/temple/filters/eraser.rb
brakeman-5.4.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
temple-0.9.1 lib/temple/filters/eraser.rb
temple-0.9.0 lib/temple/filters/eraser.rb
brakeman-5.3.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-5.3.0 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-5.2.3 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-5.2.2 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb
brakeman-5.2.1 bundle/ruby/2.7.0/gems/temple-0.8.2/lib/temple/filters/eraser.rb