Sha256: 1878ed65ff745b80aa242598149fb720c8edd70d89af7f858a1d3d406a03ac8e

Contents?: true

Size: 672 Bytes

Versions: 174

Compression:

Stored size: 672 Bytes

Contents

module CC
  module Analyzer
    module Formatters
      class Spinner
        def initialize(text)
          @spinner = TTY::Spinner.new(text)
        end

        def start
          return unless $stdout.tty? && !CLI.debug?
          @thread = Thread.new do
            loop do
              @spinning = true
              spinner.spin
              sleep 0.075
            end
          end
        end

        def stop(text = "Done!")
          if @spinning
            spinner.stop(text)
            print("\n")
            @thread.kill
          end
          @spinning = false
        end

        private

        attr_reader :spinner
      end
    end
  end
end

Version data entries

174 entries across 174 versions & 2 rubygems

Version Path
codeclimate-0.85.27 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.85.26 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.85.25 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.85.24 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.54 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.53 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.52 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.51 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.50 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.49 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.48 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.47 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.46 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.45 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.44 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.43 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.42 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.41 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.40 lib/cc/analyzer/formatters/spinner.rb
codeclimate-fede-0.85.39 lib/cc/analyzer/formatters/spinner.rb