class Highway::Interface

This class is responsible for interfacing with the user (e.g. displaying error messages), using Fastlane UI mechanism underneath.

Public Class Methods

new() click to toggle source

Initialize an instance.

# File lib/highway/interface.rb, line 18
def initialize()
  @history = []
end

Public Instance Methods

error(message) click to toggle source

Display an error message.

@param message [String] The error message.

@return [Void]

# File lib/highway/interface.rb, line 65
def error(message)
  message.to_s.strip.split("\n").each { |line| FastlaneCore::UI.error(line) }
  @history << message.to_s.strip
end
fatal!(message) click to toggle source

Display an error message and abort.

@param message [String] The error message.

@return [Void]

# File lib/highway/interface.rb, line 56
def fatal!(message)
  FastlaneCore::UI.user_error!(message.to_s)
end
header_success(message) click to toggle source

Display a success header message.

@param message [String] The header message.

@return [Void]

# File lib/highway/interface.rb, line 95
def header_success(message)
  whitespace()
  success("--- #{message}".bold)
end
header_warning(message) click to toggle source

Display a warning header message.

@param message [String] The header message.

@return [Void]

# File lib/highway/interface.rb, line 105
def header_warning(message)
  whitespace()
  warning("--- #{message}".bold)
end
note(message) click to toggle source

Display a note message.

@param message [String] The note message.

@return [Void]

# File lib/highway/interface.rb, line 85
def note(message)
  message.to_s.strip.split("\n").each { |line| FastlaneCore::UI.message(line) }
  @history << message.to_s.strip
end
raw(message) click to toggle source

Display a raw unformatted message.

@param message [String] The raw message.

@return [Void]

# File lib/highway/interface.rb, line 27
def raw(message)
  puts(message.to_s)
  @history << message.to_s
end
success(message) click to toggle source

Display a success message.

@param message [String] The success message.

@return [Void]

# File lib/highway/interface.rb, line 46
def success(message)
  message.to_s.strip.split("\n").each { |line| FastlaneCore::UI.success(line) }
  @history << message.to_s.strip
end
table(title: nil, headings: [], rows:) click to toggle source

Display a table padded with whitespace.

@param title [String] Table title. @param headings [Array<String>] Heading titles. @param rows [Array<String>] Row values.

@return [Void]

# File lib/highway/interface.rb, line 117
def table(title: nil, headings: [], rows:)

  whitespace()

  table = Terminal::Table.new(
    title: title,
    headings: headings,
    rows: FastlaneCore::PrintTable.transform_output(rows)
  )

  raw(table)

  whitespace()

end
warning(message) click to toggle source

Display a warning message.

@param message [String] The warning message.

@return [Void]

# File lib/highway/interface.rb, line 75
def warning(message)
  message.to_s.strip.split("\n").each { |line| FastlaneCore::UI.important(line) }
  @history << message.to_s.strip
end
whitespace() click to toggle source

Display a whitespace, unless it's already displayed.

@return [Void]

# File lib/highway/interface.rb, line 35
def whitespace()
  unless (@history.last || "").end_with?("\n")
    raw("\n")
  end
end