Module: Releasy::Mixins::HasPackagers

Included in:
Builders::Builder, Project
Defined in:
lib/releasy/mixins/has_packagers.rb

Overview

An object that owns one or more instances of Packagers::Packager

Instance Method Summary collapse

Instance Method Details

#add_package(type, &block) ⇒ Project

Add an archive type to be generated for each of your outputs.

Parameters:

  • type (:exe, :"7z", :tar_bz2, :tar_gz, :zip)

Returns:

Raises:

  • (ArgumentError)

See Also:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/releasy/mixins/has_packagers.rb', line 9

def add_package(type, &block)
  raise ArgumentError, "Unsupported archive format #{type.inspect}" unless Packagers.has_type? type
  raise ArgumentError, "Already have archive format #{type.inspect}" if packagers.any? {|a| a.type == type }

  packager = Packagers[type].new(respond_to?(:project) ? project : self)
  packagers << packager

  if block_given?
    if block.arity <= 0
      DSLWrapper.new(packager, &block)
    else
      yield packager
    end
  end

  packager
end