Class: Bundleup::Logger
- Inherits:
-
Object
- Object
- Bundleup::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/bundleup/logger.rb
Instance Method Summary collapse
- #attention(message) ⇒ Object
- #clear_line ⇒ Object
- #confirm?(question) ⇒ Boolean
- #error(message) ⇒ Object
-
#initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr) ⇒ Logger
constructor
A new instance of Logger.
- #ok(message) ⇒ Object
- #while_spinning(message, &block) ⇒ Object
Constructor Details
#initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 |
# File 'lib/bundleup/logger.rb', line 9 def initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr) @stdin = stdin @stdout = stdout @stderr = stderr @spinner = %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏].cycle end |
Instance Method Details
#attention(message) ⇒ Object
24 25 26 |
# File 'lib/bundleup/logger.rb', line 24 def attention() puts Colors.yellow() end |
#clear_line ⇒ Object
33 34 35 36 |
# File 'lib/bundleup/logger.rb', line 33 def clear_line print "\r".ljust(console_width - 1) print "\r" end |
#confirm?(question) ⇒ Boolean
28 29 30 31 |
# File 'lib/bundleup/logger.rb', line 28 def confirm?(question) print Colors.yellow(question.sub(/\??\z/, " [Yn]? ")) gets =~ /^($|y)/i end |
#error(message) ⇒ Object
20 21 22 |
# File 'lib/bundleup/logger.rb', line 20 def error() stderr.puts Colors.red("ERROR: #{}") end |
#ok(message) ⇒ Object
16 17 18 |
# File 'lib/bundleup/logger.rb', line 16 def ok() puts Colors.green("✔ #{}") end |
#while_spinning(message, &block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/bundleup/logger.rb', line 38 def while_spinning(, &block) thread = Thread.new(&block) thread.report_on_exception = false = .ljust(console_width - 2) print "\r#{Colors.blue([spinner.next, ].join(' '))}" until wait_for_exit(thread, 0.1) thread.value end |