module Omnibus::Compressor

Public Class Methods

for_current_system(compressors) click to toggle source

Determine the best compressor for the current system. This method returns the class, not an instance of the class.

@example

Compressor.for_current_system([:dmg, :tgz]) #=> Packager::DMG

@param [Array<Symbol>] compressors

the list of configured compressors

@return [~Compressor::Base]

# File lib/omnibus/compressor.rb, line 38
def for_current_system(compressors)
  family = Ohai["platform_family"]

  if family == "mac_os_x"
    if compressors.include?(:dmg)
      return DMG
    end

    if compressors.include?(:tgz)
      return TGZ
    end
  end

  if compressors.include?(:tgz)
    TGZ
  else
    log.info(log_key) { "No compressor defined for `#{family}'." }
    Null
  end
end

Private Instance Methods

for_current_system(compressors) click to toggle source

Determine the best compressor for the current system. This method returns the class, not an instance of the class.

@example

Compressor.for_current_system([:dmg, :tgz]) #=> Packager::DMG

@param [Array<Symbol>] compressors

the list of configured compressors

@return [~Compressor::Base]

# File lib/omnibus/compressor.rb, line 38
def for_current_system(compressors)
  family = Ohai["platform_family"]

  if family == "mac_os_x"
    if compressors.include?(:dmg)
      return DMG
    end

    if compressors.include?(:tgz)
      return TGZ
    end
  end

  if compressors.include?(:tgz)
    TGZ
  else
    log.info(log_key) { "No compressor defined for `#{family}'." }
    Null
  end
end