Skip to content

Commit 9e3c755

Browse files
committed
Display a progress bar
Some of these tasks may take a while, the ruby progress bar library makes it easy to get a sense of progress. I've not shown the progress bar in tests as it messes the test output.
1 parent db5809f commit 9e3c755

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ gem 'puma', '~> 7.2'
4242
gem 'rack_content_type_default', '~> 1.1'
4343
gem 'rack-cors'
4444
gem 'rails', '~> 7.1'
45+
gem 'ruby-progressbar', '~> 1.13', require: false
4546
gem 'sentry-rails'
4647
gem 'statesman'
4748

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ DEPENDENCIES
635635
rubocop-rspec_rails
636636
ruby-lsp
637637
ruby-lsp-rspec (~> 0.1.29)
638+
ruby-progressbar (~> 1.13)
638639
selenium-webdriver
639640
sentry-rails
640641
shoulda-matchers (~> 7.0)

lib/scratch_asset_importer.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ def initialize(asset_names, asset_base_url)
1515
end
1616

1717
def import
18+
bar = ProgressBar.create(format: '%t: |%B| %c of %C %E', total: asset_names.count) if show_progress?
19+
1820
asset_names.each do |asset_name|
21+
bar.increment if show_progress?
1922
import_asset(asset_name)
2023
end
2124
end
@@ -37,4 +40,8 @@ def connection
3740
faraday.response :raise_error
3841
end
3942
end
43+
44+
def show_progress?
45+
!Rails.env.test?
46+
end
4047
end

0 commit comments

Comments
 (0)