Sha256: eefb1fcbf96f3dffbafd82332fe641768e91cf858a36df348ff38c0b544bb57b

Contents?: true

Size: 657 Bytes

Versions: 91

Compression:

Stored size: 657 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?
          @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

91 entries across 91 versions & 1 rubygems

Version Path
codeclimate-0.24.1 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.24.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.23.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.22.3 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.22.2 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.22.1 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.22.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.21.4 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.21.3 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.21.2 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.21.1 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.21.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.20.2 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.20.1 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.20.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.19.2 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.19.1 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.19.0 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.18.6 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.18.5 lib/cc/analyzer/formatters/spinner.rb