Skip to content

Summary

rockbruno edited this page May 9, 2020 · 1 revision

Summary

A Summary is a wrapper struct that represents the result of comparing two instances of a provider.

public struct Summary: Codable, Hashable

Inheritance

Codable, Hashable

Initializers

init(text:style:numericValue:stringValue:)

Creates a Summary.

public init(text: String, style: Style, numericValue: Float, stringValue: String)

Parameters

  • text: The description of this summary.
  • style: The sentimental result of this summary. See Summary.Style for more information.
  • numericValue: The numeric value that represents this summary, to be used in tools like SwiftInfo-Reader. For example, if a build increased the number of tests by 3, numericValue should be 3.
  • stringValue: The string value that represents this summary. For example, if a build increased the number of tests by 3, stringValue can be either 3 or 'Three'. This is used only for visual purposes.

Properties

text

The descriptive result of this summary.

let text: String

color

A hex value that represents the result of this summary.

let color: String

numericValue

The numeric value that represents this summary, to be used in tools like SwiftInfo-Reader.

let numericValue: Float

stringValue

The string value that represents this summary, to be used in tools like SwiftInfo-Reader.

let stringValue: String

slackDictionary

var slackDictionary: [String: Any]

Methods

genericFor(prefix:now:old:increaseIsBad:stringValueFormatter:numericValueFormatter:difference:)

Creates a basic Summary that differs depending if a provider's value increased, decreased or stayed the same. Here's an example: Build Time: Increased by 3 (100 seconds)

public static func genericFor<T: BinaryInteger & SignedNumeric>(prefix: String, now: T, old: T?, increaseIsBad: Bool, stringValueFormatter: ((T) -> String)? = nil, numericValueFormatter: ((T) -> Float)? = nil, difference: ((T, T) -> T)? = nil) -> Summary

Parameters

  • prefix: The prefix of the message. Ideally, this should be the description of your provider.
  • now: The current numeric value of the provider.
  • old: The previous numeric value of the provider.
  • increaseIsBad: If set to true, increases in value will use the .negative Summary.Style.
  • stringValueFormatter: (Optional) The closure that translates the numeric value to a visual string. By default, the behavior is to simply cast the number to a String.
  • numericValueFormatter: (Optional) The closure that translates the numeric value to a Float. Float is the type used by reader tools like SwiftInfo-Reader, and by default, the behavior is to simply convert the number to a Float.
  • difference: (Optional) The closure that shows how to calculate the numerical difference between the providers. The first argument is the new value, and the second is the old one. By default, this closure is { abs(old - new) }.
Clone this wiki locally