Class: Highway::Interface
- Inherits:
-
Object
- Object
- Highway::Interface
- Defined in:
- lib/highway/interface.rb
Overview
This class is responsible for interfacing with the user (e.g. displaying error messages), using Fastlane UI mechanism underneath.
Instance Method Summary collapse
-
#error(message) ⇒ Void
Display an error message.
-
#fatal!(message) ⇒ Void
Display an error message and abort.
-
#header_success(message) ⇒ Void
Display a success header message.
-
#header_warning(message) ⇒ Void
Display a warning header message.
-
#initialize ⇒ Interface
constructor
Initialize an instance.
-
#note(message) ⇒ Void
Display a note message.
-
#raw(message) ⇒ Void
Display a raw unformatted message.
-
#success(message) ⇒ Void
Display a success message.
-
#table(title: nil, headings: [], rows:) ⇒ Void
Display a table padded with whitespace.
-
#warning(message) ⇒ Void
Display a warning message.
-
#whitespace ⇒ Void
Display a whitespace, unless it’s already displayed.
Constructor Details
#initialize ⇒ Interface
Initialize an instance.
18 19 20 |
# File 'lib/highway/interface.rb', line 18 def initialize() @history = [] end |
Instance Method Details
#error(message) ⇒ Void
Display an error message.
65 66 67 68 |
# File 'lib/highway/interface.rb', line 65 def error() .to_s.strip.split("\n").each { |line| FastlaneCore::UI.error(line) } @history << .to_s.strip end |
#fatal!(message) ⇒ Void
Display an error message and abort.
56 57 58 |
# File 'lib/highway/interface.rb', line 56 def fatal!() FastlaneCore::UI.user_error!(.to_s) end |
#header_success(message) ⇒ Void
Display a success header message.
95 96 97 98 |
# File 'lib/highway/interface.rb', line 95 def header_success() whitespace() success("--- #{}".bold) end |
#header_warning(message) ⇒ Void
Display a warning header message.
105 106 107 108 |
# File 'lib/highway/interface.rb', line 105 def header_warning() whitespace() warning("--- #{}".bold) end |
#note(message) ⇒ Void
Display a note message.
85 86 87 88 |
# File 'lib/highway/interface.rb', line 85 def note() .to_s.strip.split("\n").each { |line| FastlaneCore::UI.(line) } @history << .to_s.strip end |
#raw(message) ⇒ Void
Display a raw unformatted message.
27 28 29 30 |
# File 'lib/highway/interface.rb', line 27 def raw() puts(.to_s) @history << .to_s end |
#success(message) ⇒ Void
Display a success message.
46 47 48 49 |
# File 'lib/highway/interface.rb', line 46 def success() .to_s.strip.split("\n").each { |line| FastlaneCore::UI.success(line) } @history << .to_s.strip end |
#table(title: nil, headings: [], rows:) ⇒ Void
Display a table padded with whitespace.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# 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) ⇒ Void
Display a warning message.
75 76 77 78 |
# File 'lib/highway/interface.rb', line 75 def warning() .to_s.strip.split("\n").each { |line| FastlaneCore::UI.important(line) } @history << .to_s.strip end |
#whitespace ⇒ Void
Display a whitespace, unless it’s already displayed.
35 36 37 38 39 |
# File 'lib/highway/interface.rb', line 35 def whitespace() unless (@history.last || "").end_with?("\n") raw("\n") end end |