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',
  hiera_config: 'hiera.yaml',
  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.



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

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.



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

def directory
  @directory
end

#special_filesObject (readonly)

Returns the value of attribute special_files.



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

def special_files
  @special_files
end

Instance Method Details

#hiera_confObject



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

def hiera_conf
  @hiera_conf ||= AbideDevUtils::Ppt::Hiera::Config.new(special_files[:hiera_config])
end

#metadataObject



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

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

#name(strip_namespace: false) ⇒ Object



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

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

#supported_osObject



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

def supported_os
  @supported_os ||= find_supported_os
end