Sha256: cb84a21df0424f13a8e3b565c2c07c92fe4fd4f947780e3bd13d9c3313994e1b

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

# typed: true
# frozen_string_literal: true

require "benchmark"

require "packwerk/inflector"
require "packwerk/output_styles"

module Packwerk
  module Formatters
    class ProgressFormatter
      def initialize(out, style: OutputStyles::Plain)
        @out = out
        @style = style
      end

      def started(target_files)
        files_size = target_files.size
        files_string = Inflector.default.pluralize("file", files_size)
        @out.puts("📦 Packwerk is inspecting #{files_size} #{files_string}")
      end

      def started_validation
        @out.puts("📦 Packwerk is running validation...")

        execution_time = Benchmark.realtime { yield }
        finished(execution_time)

        @out.puts("✅ Packages are valid. Use `packwerk check` to run static checks.")
      end

      def mark_as_inspected
        @out.print(".")
      end

      def mark_as_failed
        @out.print("#{@style.error}E#{@style.reset}")
      end

      def finished(execution_time)
        @out.puts
        @out.puts("📦 Finished in #{execution_time.round(2)} seconds")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
packwerk-1.1.1 lib/packwerk/formatters/progress_formatter.rb
packwerk-1.1.0 lib/packwerk/formatters/progress_formatter.rb
packwerk-1.0.2 lib/packwerk/formatters/progress_formatter.rb
packwerk-1.0.1 lib/packwerk/formatters/progress_formatter.rb
packwerk-1.0.0 lib/packwerk/formatters/progress_formatter.rb