Sha256: edec3eace761a0487160cf692d0d567bb8cf9a65d901ab74f0e8a7c84b367832

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

#
# Copyright 2014 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Omnibus
  module Compressor
    include Logging

    autoload :Base, "omnibus/compressors/base"
    autoload :DMG,  "omnibus/compressors/dmg"
    autoload :Null, "omnibus/compressors/null"
    autoload :TGZ,  "omnibus/compressors/tgz"

    #
    # 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]
    #
    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)
        return TGZ
      else
        log.info(log_key) { "No compressor defined for `#{family}'." }
        return Null
      end
    end
    module_function :for_current_system
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omnibus-5.6.8 lib/omnibus/compressor.rb
omnibus-5.6.6 lib/omnibus/compressor.rb
omnibus-5.6.1 lib/omnibus/compressor.rb
omnibus-5.6.0 lib/omnibus/compressor.rb
omnibus-5.5.0 lib/omnibus/compressor.rb