Module: Omnizip::Filters::Registry

Defined in:
lib/omnizip/filters/registry.rb

Overview

Registry for auto-registering all preprocessing filters.

This module centralizes filter registration, ensuring all filters are properly registered with their supported formats.

Class Method Summary collapse

Class Method Details

.register_allvoid

This method returns an undefined value.

Register all filters.

This method registers all available filters with their appropriate format support. Call this during application initialization to ensure all filters are available.



101
102
103
104
105
# File 'lib/omnizip/filters/registry.rb', line 101

def self.register_all
  register_bcj_filters
  register_delta_filter
  register_bcj2_filter
end

.register_bcj2_filtervoid

This method returns an undefined value.

Register BCJ2 filter.

BCJ2 is a 4-stream variant of BCJ, primarily used by 7z. XZ does not support BCJ2.



86
87
88
89
90
91
92
# File 'lib/omnizip/filters/registry.rb', line 86

def self.register_bcj2_filter
  Omnizip::FilterRegistry.register_with_formats(
    :bcj2,
    Bcj2,
    formats: [:seven_zip], # Only 7z supports BCJ2
  )
end

.register_bcj_filter(name, filter_class, architecture:, xz_supported: true) ⇒ void

This method returns an undefined value.

Register a BCJ filter with format support.

Parameters:

  • name (Symbol)

    Filter name identifier

  • filter_class (Class)

    Filter class to register

  • architecture (Symbol)

    Target architecture

  • xz_supported (Boolean) (defaults to: true)

    Whether XZ format supports this architecture



59
60
61
62
63
64
65
# File 'lib/omnizip/filters/registry.rb', line 59

def self.register_bcj_filter(name, filter_class, architecture:,
xz_supported: true)
  formats = [:seven_zip]
  formats << :xz if xz_supported
  Omnizip::FilterRegistry.register_with_formats(name, filter_class,
                                                formats: formats)
end

.register_bcj_filtersvoid

This method returns an undefined value.

Register all BCJ filters with appropriate format support.

BCJ filters are architecture-specific filters for executable code. XZ format supports a subset of architectures (no ARM64), while 7z supports all.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/omnizip/filters/registry.rb', line 33

def self.register_bcj_filters
  # Individual BCJ architecture filters (use hyphens to match existing convention)
  register_bcj_filter(:"bcj-x86", BcjX86, architecture: :x86)
  register_bcj_filter(:"bcj-arm", BcjArm, architecture: :arm)
  register_bcj_filter(:"bcj-arm64", BcjArm64, architecture: :arm64,
                                              xz_supported: false)
  register_bcj_filter(:"bcj-ia64", BcjIa64, architecture: :ia64)
  register_bcj_filter(:"bcj-ppc", BcjPpc, architecture: :powerpc)
  register_bcj_filter(:"bcj-sparc", BcjSparc, architecture: :sparc)

  # Unified BCJ filter (Task 2) - supports all architectures
  # Note: We register it as 'bcj' without architecture suffix
  Omnizip::FilterRegistry.register_with_formats(
    :bcj,
    Omnizip::Filters::BCJ,
    formats: [:seven_zip], # Only 7z for now (uses architecture parameter)
  )
end

.register_delta_filtervoid

This method returns an undefined value.

Register Delta filter.

Delta filter is supported by both XZ and 7z formats.



72
73
74
75
76
77
78
# File 'lib/omnizip/filters/registry.rb', line 72

def self.register_delta_filter
  Omnizip::FilterRegistry.register_with_formats(
    :delta,
    Delta,
    formats: %i[seven_zip xz],
  )
end