Class: PuppetX::Puppetlabs::Migration::CatalogDeltaModel::Exclude

Inherits:
DeltaEntity
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb

Constant Summary collapse

DEFAULT_EXCLUSIONS =
[
  Exclude.new('file', '/etc/puppetlabs/console-services/conf.d/console_secret_key.conf', ['content'])
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DeltaEntity

from_hash

Methods included from ModelObject

#initialize_from_hash, #to_hash

Constructor Details

#initialize(type, title, attributes) ⇒ Exclude

Returns a new instance of Exclude.



20
21
22
23
24
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 20

def initialize(type, title, attributes)
  @type = assert_type(String, type)
  @title = assert_type(String, title)
  @attributes = assert_type(Array, attributes)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



18
19
20
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 18

def attributes
  @attributes
end

#titleObject (readonly)

Returns the value of attribute title.



17
18
19
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 17

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 16

def type
  @type
end

Class Method Details

.parse_file(file_name) ⇒ Object

Raises:

  • (Puppet::Error)


26
27
28
29
30
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 26

def self.parse_file(file_name)
  json = File.read(file_name)
  raise Puppet::Error.new('Excludes file must contain well formed JSON') if json.nil? || json.empty?
  parse_json(json)
end

.parse_json(json) ⇒ Object

Raises:

  • (Puppet::Error)


32
33
34
35
36
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 32

def self.parse_json(json)
  array = JSON.load(json)
  raise Puppet::Error.new('Excludes file must contain a JSON Array') unless array.is_a?(Array)
  array.map { |hash| Exclude.new(hash['type'], hash['title'], hash['attributes']) }
end

Instance Method Details

#excluded_title?(title) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/puppet_x/puppetlabs/migration/catalog_delta_model.rb', line 38

def excluded_title?(title)
  (@title.nil? || @title == title) && @attributes.nil?
end