Class: AbideDevUtils::Ppt::PuppetModule

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/ppt/puppet_module.rb

Overview

Class for working with Puppet Modules

Constant Summary collapse

DEF_FILES =
{
  metadata: 'metadata.json',
  readme: 'README.md',
  reference: 'REFERENCE.md',
  changelog: 'CHANGELOG.md',
  fixtures: '.fixtures.yml',
  rubocop: '.rubocop.yml',
  sync: '.sync.yml',
  pdkignore: '.pdkignore',
  gitignore: '.gitignore'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory = Dir.pwd) ⇒ PuppetModule

Returns a new instance of PuppetModule.



26
27
28
29
30
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 26

def initialize(directory = Dir.pwd)
  AbideDevUtils::Validate.directory(directory)
  @directory = directory
  @special_files = DEF_FILES.dup.transform_values { |v| File.expand_path(File.join(@directory, v)) }
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



24
25
26
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 24

def directory
  @directory
end

#special_filesObject (readonly)

Returns the value of attribute special_files.



24
25
26
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 24

def special_files
  @special_files
end

Instance Method Details

#hiera_confObject



44
45
46
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 44

def hiera_conf
  @hiera_conf ||= AbideDevUtils::Ppt::Hiera::Config.new
end

#metadataObject



36
37
38
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 36

def 
  @metadata ||= JSON.parse(File.read(special_files[:metadata]))
end

#name(strip_namespace: false) ⇒ Object



32
33
34
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 32

def name(strip_namespace: false)
  strip_namespace ? ['name'].split('-')[-1] : ['name']
end

#supported_osObject



40
41
42
# File 'lib/abide_dev_utils/ppt/puppet_module.rb', line 40

def supported_os
  @supported_os ||= find_supported_os
end