Class: DnsMadeEasy::Zone::PlanRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsmadeeasy/zone/plan_renderer.rb

Overview

Renders zone plans for humans and automation.

Instance Method Summary collapse

Constructor Details

#initialize(plan) ⇒ PlanRenderer

Returns a new instance of PlanRenderer.



9
10
11
# File 'lib/dnsmadeeasy/zone/plan_renderer.rb', line 9

def initialize(plan)
  @plan = plan
end

Instance Method Details

#to_jsonObject



24
25
26
# File 'lib/dnsmadeeasy/zone/plan_renderer.rb', line 24

def to_json(*)
  JSON.pretty_generate(plan_hash)
end

#to_textObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/dnsmadeeasy/zone/plan_renderer.rb', line 13

def to_text
  return "No changes.\n" if plan.empty?

  [
    section('Create', plan.creates),
    section('Update', plan.updates),
    section('Skipped Deletes', plan.skipped_deletes),
    section('Manual Review', plan.ambiguous)
  ].reject(&:empty?).join("\n")
end