Sha256: 41d4771119b8a30d7fb664436d6585b9ff138be3012b03e6bc6b4a1f80f49489

Contents?: true

Size: 662 Bytes

Versions: 33

Compression:

Stored size: 662 Bytes

Contents

require 'ruby-progressbar'

module Squib

  # :nodoc:
  # @api private
  class DoNothing
    def increment
    end

    def finish
    end
  end

  # A facade that handles (or doesn't) the progress bar on the console
  #
  # :nodoc:
  # @api private
  class Progress
    attr_accessor :enabled

    def initialize(enabled)
      @enabled = enabled
    end

    def start(title='', total=100, &block)
      if @enabled
        @bar = ProgressBar.create(title: title, total: total, format: '%t <%B> %p%% %a')
        yield(@bar)
        @bar.finish
      else
        yield(Squib::DoNothing.new)
      end
    end
  end


end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
squib-0.18.0 lib/squib/progress.rb
squib-0.17.2 lib/squib/progress.rb
squib-0.17.1 lib/squib/progress.rb
squib-0.17.0 lib/squib/progress.rb
squib-0.16.0 lib/squib/progress.rb
squib-0.16.0.pre.preview2 lib/squib/progress.rb
squib-0.16.0.pre.preview1 lib/squib/progress.rb
squib-0.15.3 lib/squib/progress.rb
squib-0.15.0 lib/squib/progress.rb
squib-0.14.3.pre1 lib/squib/progress.rb
squib-0.14.1 lib/squib/progress.rb
squib-0.14.0 lib/squib/progress.rb
squib-0.14.beta1 lib/squib/progress.rb
squib-0.13.4 lib/squib/progress.rb
squib-0.13.3 lib/squib/progress.rb
squib-0.13.2 lib/squib/progress.rb
squib-0.13.1 lib/squib/progress.rb
squib-0.13.0 lib/squib/progress.rb
squib-0.12.0 lib/squib/progress.rb
squib-0.11.0 lib/squib/progress.rb