Class: AbideDevUtils::CEM::HieraData::ResourceData::Resource
- Inherits:
-
Object
- Object
- AbideDevUtils::CEM::HieraData::ResourceData::Resource
- Defined in:
- lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb
Overview
Represents a resource data resource statement
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #cem_options ⇒ Object
- #cem_protected ⇒ Object
- #controls ⇒ Object
-
#initialize(title, data, framework, mapper) ⇒ Resource
constructor
A new instance of Resource.
- #to_puppet_code ⇒ Object
- #to_reference ⇒ Object
- #to_stubbed_h ⇒ Object
Constructor Details
#initialize(title, data, framework, mapper) ⇒ Resource
Returns a new instance of Resource.
16 17 18 19 20 21 22 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 16 def initialize(title, data, framework, mapper) @title = title @data = data @type = data['type'] @framework = framework @mapper = mapper end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
14 15 16 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 14 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 14 def type @type end |
Instance Method Details
#cem_options ⇒ Object
28 29 30 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 28 def @cem_options ||= Parameters.new(data['cem_options']) end |
#cem_protected ⇒ Object
32 33 34 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 32 def cem_protected @cem_protected ||= Parameters.new(data['cem_protected']) end |
#controls ⇒ Object
24 25 26 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 24 def controls @controls ||= load_controls end |
#to_puppet_code ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 50 def to_puppet_code parray = controls.map { |x| x.parameters.to_puppet_code if x.parameters.exist? }.flatten.compact.uniq return "#{type} { '#{title}': }" if parray.empty? || parray.all?(&:empty?) || parray.all?("\n") # if title == 'cem_linux::utils::packages::linux::auditd::time_change' # require 'pry' # binding.pry # end <<~EOPC #{type} { '#{title}': #{parray.join("\n")} } EOPC end |
#to_reference ⇒ Object
46 47 48 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 46 def to_reference "#{type.split('::').map(&:capitalize).join('::')}['#{title}']" end |
#to_stubbed_h ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/abide_dev_utils/cem/hiera_data/resource_data/resource.rb', line 36 def to_stubbed_h { title: title, type: type, cem_options: .to_h, cem_protected: cem_protected.to_h, reference: to_reference, } end |