New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade TTY::Cursor and add top level spinner option #15
Conversation
lib/tty/spinner/multi.rb
Outdated
@@ -116,6 +141,7 @@ def success | |||
# | |||
# @api public | |||
def error | |||
@master_spinner.error if @master_spinner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use safe navigation (&.) instead of checking if an object exists before calling the method.
lib/tty/spinner/multi.rb
Outdated
@@ -108,6 +132,7 @@ def stop | |||
# | |||
# @api public | |||
def success | |||
@master_spinner.success if @master_spinner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use safe navigation (&.) instead of checking if an object exists before calling the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only added in ruby 2.3.0
lib/tty/spinner/multi.rb
Outdated
@@ -64,11 +76,23 @@ def count_line_offset(index) | |||
if spinner.spinning? || spinner.success? || | |||
spinner.error? || spinner.done? | |||
acc += 1 | |||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant else-clause.
examples/multi_with_inset.rb
Outdated
sp3.error | ||
|
||
spinners.error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 trailing blank lines detected.
@@ -0,0 +1,27 @@ | |||
# encoding: utf-8 | |||
|
|||
require 'tty-spinner' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -0,0 +1,27 @@ | |||
# encoding: utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.
1 similar comment
|
||
expect { spinners.auto_spin }.not_to raise_exception | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty line detected at block body end.
end | ||
|
||
it "doesn't raise exception" do | ||
spinners = TTY::Spinner::Multi.new(output: output, message: "Top level spinner") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
RSpec.describe TTY::Spinner::Multi, '#auto_spin' do | ||
let(:output) { StringIO.new('', 'w+') } | ||
|
||
it "raises and exception when #auto_spin is called without a top level spinner" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
end | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#auto_spin' do | ||
let(:output) { StringIO.new('', 'w+') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
end | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#auto_spin' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
spinner = spinners.register "" | ||
|
||
expect(spinners.line_inset(spinner)).to eq('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
# | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#line_inset' do | ||
let(:output) { StringIO.new('', 'w+') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
# coding: utf-8 | ||
# | ||
|
||
RSpec.describe TTY::Spinner::Multi, '#line_inset' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -0,0 +1,57 @@ | |||
# coding: utf-8 | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line after magic comments.
@@ -0,0 +1,57 @@ | |||
# coding: utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.
4 similar comments
@piotrmurach this is ready to go post tty-cursor release yesterday. |
@austb this is great addition! Thanks for working on it. Going forward, before next release of the library, I think it would be good to first raise some GitHub issues so that we can agree on what we're working on etc... I try to maintain consistency between apis of tty packages and document everything as I'm going along developing library and GitHub issues would definitely help. Therefore it would be good to:
Again, thank you for giving tty-spinner such great ideas! |
Terminal.app does not respect ANSI cursor save and restore sequences so
instead this commit moves the cursor explicitly with up and down
commands to ensure compatibility.
I was initially put on this track by this Github issue
I added this example to test
The above example in tmux (on Terminal.app)
The above example in Terminal.app directly