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) ⇒ Object
Constructor Details
#initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr) ⇒ Logger
Returns a new instance of Logger.
10 11 12 13 14 15 |
# File 'lib/bundleup/logger.rb', line 10 def initialize(stdin: $stdin, stdout: $stdout, stderr: $stderr) @stdin = stdin @stdout = stdout @stderr = stderr @spinner = %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏].cycle end |
Instance Method Details
#attention(message) ⇒ Object
25 26 27 |
# File 'lib/bundleup/logger.rb', line 25 def attention() puts Colors.yellow() end |
#clear_line ⇒ Object
34 35 36 37 |
# File 'lib/bundleup/logger.rb', line 34 def clear_line print "\r".ljust(console_width - 1) print "\r" end |
#confirm?(question) ⇒ Boolean
29 30 31 32 |
# File 'lib/bundleup/logger.rb', line 29 def confirm?(question) print Colors.yellow(question.sub(/\??\z/, " [Yn]? ")) gets =~ /^($|y)/i end |
#error(message) ⇒ Object
21 22 23 |
# File 'lib/bundleup/logger.rb', line 21 def error() stderr.puts Colors.red("ERROR: #{message}") end |
#ok(message) ⇒ Object
17 18 19 |
# File 'lib/bundleup/logger.rb', line 17 def ok() puts Colors.green("✔ #{message}") end |
#while_spinning(message) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/bundleup/logger.rb', line 39 def while_spinning(, &) thread = Thread.new(&) thread.report_on_exception = false = .ljust(console_width - 2) print "\r#{Colors.blue([spinner.next, message].join(' '))}" until wait_for_exit(thread, 0.1) thread.value end |