-
-
Notifications
You must be signed in to change notification settings - Fork 49
Feature: add in custom bar character and delimiters #45
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
base: master
Are you sure you want to change the base?
Changes from all commits
d257339
f9642de
9c0fbf0
3f69fd9
98553fa
edd0534
834baa1
a7cfd33
32323ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,4 @@ | |
| end | ||
| end | ||
| end | ||
|
|
||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,5 +46,4 @@ | |
|
|
||
| it { should == '[ 0/4242]' } | ||
| end | ||
|
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,8 +43,4 @@ | |
|
|
||
| it { should == '[02:00:00]' } | ||
| end | ||
|
|
||
| end | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,4 @@ | |
|
|
||
| it { should == '[ 50.00%]' } | ||
| end | ||
|
|
||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) | ||
|
|
||
| describe 'ProgressBar bar output with custom characters' do | ||
| before do | ||
| Timecop.freeze Time.utc(2010, 3, 10, 0, 0, 0) | ||
| @progress_bar = ProgressBar.new(100, bar: '█', delimiters: '▕▏') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, there is kind of a test for multibyte characters I guess. Why are there two separate spec files?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasnt certain the |
||
| @progress_bar.stub(:terminal_width) { 60 } | ||
| Timecop.freeze Time.utc(2010, 3, 10, 0, 0, 10) # 10 seconds later | ||
| end | ||
|
|
||
| subject { @progress_bar.to_s } | ||
|
|
||
| describe 'at count=0' do | ||
| before do | ||
| @progress_bar.count = 0 | ||
| end | ||
|
|
||
| it { should == '▕ ▏ [ 0/100] [ 0%] [00:10] [00:00] [ 0.00/s]' } | ||
| end | ||
|
|
||
| describe 'at count=50' do | ||
| before do | ||
| @progress_bar.count = 50 | ||
| end | ||
|
|
||
| it { should == '▕███████ ▏ [ 50/100] [ 50%] [00:10] [00:10] [ 5.00/s]' } | ||
| end | ||
|
|
||
| describe 'at count=100' do | ||
| before do | ||
| @progress_bar.count = 100 | ||
| end | ||
|
|
||
| it { should == '▕██████████████▏ [100/100] [100%] [00:10] [00:00] [ 10.00/s]' } | ||
| end | ||
|
|
||
| describe 'at count=105' do | ||
| before do | ||
| @progress_bar.count = 105 | ||
| end | ||
|
|
||
| it { should == '▕██████████████▏ [100/100] [100%] [00:10] [00:00] [ 10.00/s]' } | ||
| end | ||
|
|
||
| describe 'at count=100 with a multi-sequence emoji' do | ||
| before do | ||
| @progress_bar.count = 100 | ||
| @progress_bar.bar = "🏴☠️" | ||
| end | ||
|
|
||
| it { should == '▕🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️🏴☠️▏ [100/100] [100%] [00:10] [00:00] [ 10.00/s]' } | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,4 @@ | |
|
|
||
| it { should == "[##############] [100/100] [100%] [00:10] [00:00] [ 10.00/s]" } | ||
| end | ||
|
|
||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,10 +54,4 @@ | |
|
|
||
| it { should == '[ 2.10/s]' } | ||
| end | ||
|
|
||
| end | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
I had to remove the character limit because lots of new emojis are multi-sequence characters. This isn't supported everywhere but in modern terminals it is. I dont see a reason to limit this functionality and its up to the developer using this Gem to make sure the character doesnt mess up for their use case if they select a multi-character sequence