Class: CemAcpt::Utils::Puppet::ModulePackageBuilder

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/utils/puppet.rb

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

current_log_config, #current_log_config, current_log_format, #current_log_format, #current_log_level, current_log_level, included, #logger, logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, #new_log_level, new_log_level, #new_logger, new_logger, verbose?, #verbose?

Constructor Details

#initialize(module_dir, target_dir: nil, should_log: false, builder: ::Puppet::Modulebuilder::Builder) ⇒ ModulePackageBuilder

Returns a new instance of ModulePackageBuilder.



16
17
18
19
20
21
22
23
24
# File 'lib/cem_acpt/utils/puppet.rb', line 16

def initialize(module_dir, target_dir: nil, should_log: false, builder: ::Puppet::Modulebuilder::Builder)
  @module_dir = ::File.expand_path(module_dir)
  @target_dir = target_dir
  @should_log = should_log
  @builder = new_builder(builder)
  @metadata = @builder. # Validates metadata
  @package_built = false
  @package_path = nil
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



14
15
16
# File 'lib/cem_acpt/utils/puppet.rb', line 14

def 
  @metadata
end

#module_dirObject (readonly)

Returns the value of attribute module_dir.



14
15
16
# File 'lib/cem_acpt/utils/puppet.rb', line 14

def module_dir
  @module_dir
end

#package_pathObject (readonly)

Returns the value of attribute package_path.



14
15
16
# File 'lib/cem_acpt/utils/puppet.rb', line 14

def package_path
  @package_path
end

#should_logObject (readonly)

Returns the value of attribute should_log.



14
15
16
# File 'lib/cem_acpt/utils/puppet.rb', line 14

def should_log
  @should_log
end

#target_dirObject (readonly)

Returns the value of attribute target_dir.



14
15
16
# File 'lib/cem_acpt/utils/puppet.rb', line 14

def target_dir
  @target_dir
end

Instance Method Details

#buildString

Builds a Puppet module package.

Returns:

  • (String)

    Path to the built package.



28
29
30
31
32
33
# File 'lib/cem_acpt/utils/puppet.rb', line 28

def build
  @package_path = @metadata['name'].include?('windows') ? build_windows_package : @builder.build
  @package_built = true
  logger.info('CemAcpt::Utils::Puppet::ModulePackageBuilder') { "Built module package: #{@package_path}" }
  @package_path
end

#package_built?Boolean

Determines if a package has been built.

Returns:

  • (Boolean)


36
37
38
# File 'lib/cem_acpt/utils/puppet.rb', line 36

def package_built?
  @package_built
end