Module: Gryphon::Compressors

Defined in:
lib/gryphon/compressors.rb,
lib/gryphon/compressors/gzip_compressor.rb,
lib/gryphon/compressors/brotli_compressor.rb

Defined Under Namespace

Classes: BrotliCompressor, GzipCompressor

Constant Summary collapse

COMPRESSABLE =
%w[
  .html
  .htm
  .xhtml
  .txt
  .csv
  .css
  .js
  .mjs
  .md
  .xml
  .svg
].freeze

Class Method Summary collapse

Class Method Details

.compressable?(file) ⇒ Boolean

Parameters:

  • file (Pathname)

Returns:

  • (Boolean)


25
# File 'lib/gryphon/compressors.rb', line 25

def compressable?(file) = file.size >= 40 && COMPRESSABLE.include?(file.extname)

.createObject

return [Array<Object>]



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gryphon/compressors.rb', line 28

def create
  compressors = [GzipCompressor.new]

  begin
    require 'brotli'
    compressors << BrotliCompressor.new
  rescue LoadError
    # Do nothing
  end

  compressors
end