Class: Upkeep::HerbSupport::ManifestDiff
- Inherits:
-
Object
- Object
- Upkeep::HerbSupport::ManifestDiff
- Defined in:
- lib/upkeep/herb/manifest_diff.rb
Defined Under Namespace
Classes: Plan
Constant Summary collapse
- PARSE_OPTIONS =
TemplateManifest::DEFAULT_PARSE_OPTIONS.merge( action_view_helpers: false, transform_conditionals: false ).freeze
- CONTENT_ONLY_OPERATION_TYPES =
%i[ attribute_added attribute_removed attribute_value_changed text_changed ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path:, old_source:, new_source:, parse_options: PARSE_OPTIONS) ⇒ ManifestDiff
constructor
A new instance of ManifestDiff.
- #plan ⇒ Object
Constructor Details
#initialize(path:, old_source:, new_source:, parse_options: PARSE_OPTIONS) ⇒ ManifestDiff
Returns a new instance of ManifestDiff.
60 61 62 63 64 65 |
# File 'lib/upkeep/herb/manifest_diff.rb', line 60 def initialize(path:, old_source:, new_source:, parse_options: PARSE_OPTIONS) @path = path @old_source = old_source @new_source = new_source @parse_options = end |
Class Method Details
.plan(path:, old_source:, new_source:, parse_options: PARSE_OPTIONS) ⇒ Object
56 57 58 |
# File 'lib/upkeep/herb/manifest_diff.rb', line 56 def self.plan(path:, old_source:, new_source:, parse_options: PARSE_OPTIONS) new(path: path, old_source: old_source, new_source: new_source, parse_options: ).plan end |
Instance Method Details
#plan ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/upkeep/herb/manifest_diff.rb', line 67 def plan old_manifest = build_manifest(old_source) new_manifest = build_manifest(new_source) diff_result = ::Herb.diff(old_source, new_source) old_signature = topology_signature(old_manifest) new_signature = topology_signature(new_manifest) action, reason, topology_changed = classify( diff_result: diff_result, old_manifest: old_manifest, new_manifest: new_manifest, old_signature: old_signature, new_signature: new_signature ) Plan.new( path: path, action: action, reason: reason, topology_changed: topology_changed, diff_identical: diff_result.identical?, operation_types: diff_result.map { |operation| operation.type.to_s }, operations: diff_result.map { |operation| operation_payload(operation) }, old_manifest: old_manifest, new_manifest: new_manifest, old_topology_signature: old_signature, new_topology_signature: new_signature, error: nil ) rescue StandardError => error Plan.new( path: path, action: "full_rebuild", reason: "herb_diff_failed", topology_changed: true, diff_identical: false, operation_types: [], operations: [], old_manifest: nil, new_manifest: nil, old_topology_signature: nil, new_topology_signature: nil, error: { class: error.class.name, message: error. } ) end |