Class: DryRunReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/dry_run_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDryRunReporter

Returns a new instance of DryRunReporter.



6
7
8
# File 'lib/dry_run_reporter.rb', line 6

def initialize
  @report = {}
end

Instance Attribute Details

#reportObject (readonly)

Returns the value of attribute report.



4
5
6
# File 'lib/dry_run_reporter.rb', line 4

def report
  @report
end

Instance Method Details

#add_to_report(*args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/dry_run_reporter.rb', line 10

def add_to_report(*args)
  if args.first.is_a?(Hash)
    add_to_report_as_hash(args.first)
  else
    add_to_report_as_key_and_values(*args)
  end
end


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dry_run_reporter.rb', line 18

def print_report
  if @report.to_a.map(&:second).flatten.empty?
    puts 'Dry run active. No data would be removed in normal run.'
  else
    puts 'Dry run active. The following data would be removed in normal run:'

    @report.to_a.map(&:first).each do |symbol|
      print_report_line(symbol)
    end
  end
end