Sha256: 207de4fd74d76a4a4b5b8d6263da88216ace484bd4f17a695b24f99528ad76df

Contents?: true

Size: 971 Bytes

Versions: 14

Compression:

Stored size: 971 Bytes

Contents

module ShopifyCLI
  module Theme
    module Extension
      module UI
        class HostThemeProgressBar
          GIT_CLONE_PROGRESS_SHARE = 0.2
          SYNC_PROGRESS_SHARE = 0.8

          def initialize(syncer, dir)
            @syncer = syncer
            @dir = dir
          end

          def progress(method, **args)
            @syncer.lock_io!
            CLI::UI::Progress.progress do |bar|
              Git.public_send(:raw_clone, "https://github.com/Shopify/dawn.git", @dir) do |percent|
                bar.tick(set_percent: percent * GIT_CLONE_PROGRESS_SHARE)
              end

              @syncer.public_send(method, **args) do |left, total|
                next if total == 0
                bar.tick(set_percent: (1 - left.to_f / total) * SYNC_PROGRESS_SHARE + GIT_CLONE_PROGRESS_SHARE)
              end

              bar.tick(set_percent: 1)
            end
            @syncer.unlock_io!
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.35.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.34.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.33.1 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.33.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.32.1 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.32.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.31.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.30.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.29.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.28.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.27.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.26.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb
shopify-cli-2.25.0 lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb