Class: PuppetX::Puppetlabs::Migration::CatalogDeltaModel::Exclude
- Inherits:
-
DeltaEntity
- Object
- DeltaEntity
- PuppetX::Puppetlabs::Migration::CatalogDeltaModel::Exclude
- 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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #excluded_title?(title) ⇒ Boolean
-
#initialize(type, title, attributes) ⇒ Exclude
constructor
A new instance of Exclude.
Methods inherited from DeltaEntity
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
#attributes ⇒ Object (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 |
#title ⇒ Object (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 |
#type ⇒ Object (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
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
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
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 |