Class: Preflight::Rules::CompressionAlgorithms

Inherits:
Object
  • Object
show all
Defined in:
lib/preflight/rules/compression_algorithms.rb

Overview

check a file doesn’t use unwanted compression algorithms

Arguments: a list of permitted compression algorithms.

Usage:

class MyPreflight
  include Preflight::Profile

  rule Preflight::Rules::CompressionAlgorithms, :CCITTFaxDecode, :DCTDecode, :FlateDecode
end

Instance Method Summary collapse

Constructor Details

#initialize(*algorithms) ⇒ CompressionAlgorithms

Returns a new instance of CompressionAlgorithms.



20
21
22
# File 'lib/preflight/rules/compression_algorithms.rb', line 20

def initialize(*algorithms)
  @algorithms = algorithms.flatten
end

Instance Method Details

#check_hash(ohash) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/preflight/rules/compression_algorithms.rb', line 24

def check_hash(ohash)
  algorithms = banned_algorithms(ohash)

  if algorithms.size > 0
    [Issue.new("File uses excluded compression algorithm", self, :algorithms => algorithms)]
  else
    []
  end
end