diff --git a/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake b/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake index 1ccbd7e7..3b52fd60 100644 --- a/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake +++ b/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake @@ -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"