Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Commit

Permalink
Log spinner via Logging instead of directly.
Browse files Browse the repository at this point in the history
That way it can be disabled during the specs; currently the spinner
prints during the specs.

It's usually invisible because the spinner prints backspaces over
itself, but when the output device doesn't backspace (like an editor's
console), they show up.
  • Loading branch information
benhoskings committed Mar 7, 2016
1 parent 01774b4 commit e9fd4a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/babushka/helpers/log_helpers.rb
Expand Up @@ -191,6 +191,10 @@ def self.log_table headings, rows

private

def self.print message
print_log(message, true, :stdout)
end

def self.print_log message, printable, as
# This is disabled in the specs.
print_log!(message, printable, as)
Expand Down
6 changes: 3 additions & 3 deletions lib/babushka/shell.rb
Expand Up @@ -43,7 +43,7 @@ def ok?
def run &block
@stdout, @stderr = '', ''
@result = invoke
print "#{" " * (@progress.length + 1)}#{"\b" * (@progress.length + 1)}" unless @progress.nil?
Logging.print "#{" " * (@progress.length + 1)}#{"\b" * (@progress.length + 1)}" unless @progress.nil?

if block_given?
yield(self)
Expand Down Expand Up @@ -101,9 +101,9 @@ def read_from io, buf, log_as = nil
buf << output

if @should_spin
print " #{%w[| / - \\][@spinner_offset = ((@spinner_offset + 1) % 4)]}\b\b"
Logging.print " #{%w[| / - \\][@spinner_offset = ((@spinner_offset + 1) % 4)]}\b\b"
elsif opts[:progress] && (@progress = output[opts[:progress]])
print " #{@progress}#{"\b" * (@progress.length + 1)}"
Logging.print " #{@progress}#{"\b" * (@progress.length + 1)}"
end
end
end
Expand Down

0 comments on commit e9fd4a4

Please sign in to comment.