Class: PuppetX::Puppetlabs::Migration::OverviewModel::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/migration/overview_model/report.rb

Instance Method Summary collapse

Constructor Details

#initialize(overview) ⇒ Report

Parameters:

  • overview (Overview)

    the overview to create a report from



6
7
8
# File 'lib/puppet_x/puppetlabs/migration/overview_model/report.rb', line 6

def initialize(overview)
  @overview = overview
end

Instance Method Details

#to_hashHash<Symbol,Hash>

Returns a hash representing the content of the report

Returns:

  • (Hash<Symbol,Hash>)

    the report hash



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/puppet_x/puppetlabs/migration/overview_model/report.rb', line 12

def to_hash
  hash = {
    :stats => stats,
    :top_ten => top_ten,
    :changes => changes
  }
  baseline = log_entries_hash(true)
  hash[:baseline] = baseline unless baseline.empty?
  preview = log_entries_hash(false)
  hash[:preview] = preview unless preview.empty?
  hash
end

#to_jsonString

Creates and returns a formatted JSON string that represents the content of the report

Returns:

  • (String)

    The JSON representation of this report



27
28
29
# File 'lib/puppet_x/puppetlabs/migration/overview_model/report.rb', line 27

def to_json
  PSON::pretty_generate(to_hash, :allow_nan => true, :max_nesting => false)
end

#to_sString

Returns this report as a human readable multi-line string

Returns:

  • (String)

    The textual representation of this report



33
34
35
36
37
38
39
40
41
# File 'lib/puppet_x/puppetlabs/migration/overview_model/report.rb', line 33

def to_s
  bld = StringIO.new
  stats_to_s(bld, stats)
  log_entries_hash_to_s(bld, log_entries_hash(true), true)
  log_entries_hash_to_s(bld, log_entries_hash(false), false)
  changes_to_s(bld, changes)
  top_ten_to_s(bld, top_ten)
  bld.string
end