Class: KubernetesDeploy::DeferredSummaryLogging::DeferredSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/kubernetes-deploy/deferred_summary_logging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeferredSummary

Returns a new instance of DeferredSummary.



56
57
58
59
# File 'lib/kubernetes-deploy/deferred_summary_logging.rb', line 56

def initialize
  @actions_taken = []
  @paragraphs = []
end

Instance Attribute Details

#paragraphsObject (readonly)

Returns the value of attribute paragraphs.



54
55
56
# File 'lib/kubernetes-deploy/deferred_summary_logging.rb', line 54

def paragraphs
  @paragraphs
end

Instance Method Details

#actions_sentenceObject



61
62
63
64
65
66
67
# File 'lib/kubernetes-deploy/deferred_summary_logging.rb', line 61

def actions_sentence
  case @actions_taken.length
  when 0 then "No actions taken"
  else
    @actions_taken.to_sentence.capitalize
  end
end

#add_action(sentence_fragment) ⇒ Object

Saves a sentence fragment to be displayed in the first sentence of the summary section

Example: # The resulting summary will begin with “Created 3 secrets and failed to deploy 2 resources” @logger.summary.add_action(“created 3 secrets”) @logger.summary.add_cation(“failed to deploy 2 resources”)



75
76
77
# File 'lib/kubernetes-deploy/deferred_summary_logging.rb', line 75

def add_action(sentence_fragment)
  @actions_taken << sentence_fragment
end

#add_paragraph(paragraph) ⇒ Object

Adds a paragraph to be displayed in the summary section Paragraphs will be printed in the order they were added, separated by a blank line This can be used to log a block of data on a particular topic, e.g. debug info for a particular failed resource



82
83
84
# File 'lib/kubernetes-deploy/deferred_summary_logging.rb', line 82

def add_paragraph(paragraph)
  paragraphs << paragraph
end