Class: PuppetX::Puppetlabs::Migration::OverviewModel::Report
- Inherits:
-
Object
- Object
- PuppetX::Puppetlabs::Migration::OverviewModel::Report
- Defined in:
- lib/puppet_x/puppetlabs/migration/overview_model/report.rb
Instance Method Summary collapse
- #initialize(overview) ⇒ Report constructor
-
#to_hash ⇒ Hash<Symbol,Hash>
Returns a hash representing the content of the report.
-
#to_json ⇒ String
Creates and returns a formatted JSON string that represents the content of the report.
-
#to_s ⇒ String
Returns this report as a human readable multi-line string.
Constructor Details
#initialize(overview) ⇒ Report
Creates a new PuppetX::Puppetlabs::Migration::OverviewModel::Report instance based on an Overview.
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_hash ⇒ Hash<Symbol,Hash>
Returns a hash representing the content of the report
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_json ⇒ String
Creates and returns a formatted JSON string that represents the content of the 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_s ⇒ String
Returns this report as a human readable multi-line string
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 |