Add a rake progress bar
This commit is contained in:
parent
4d29b67939
commit
bcf5f264a2
1 changed files with 25 additions and 0 deletions
|
@ -1,6 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
# from https://coderwall.com/p/ijr6jq/rake-progress-bar
|
||||
class ProgressBar
|
||||
attr_reader :total, :counter
|
||||
def initialize(total, description)
|
||||
@description = description
|
||||
@total = total
|
||||
@counter = 1
|
||||
end
|
||||
|
||||
def increment
|
||||
print_out
|
||||
@counter += 1
|
||||
end
|
||||
|
||||
def print_out
|
||||
complete = sprintf("%#.2f%%", ((@counter.to_f / @total.to_f) * 100))
|
||||
print "\r\e[0K#{@description} #{@counter}/#{@total} (#{complete})"
|
||||
end
|
||||
|
||||
def increment_total(by_amount)
|
||||
@total += by_amount
|
||||
print_out
|
||||
end
|
||||
end
|
||||
|
||||
namespace :houdini_upgrade do
|
||||
Rake::Task["install:migrations"].clear_comments
|
||||
desc "Run houdini upgrade to v2"
|
||||
|
|
Loading…
Reference in a new issue