Sha256: eea9acf56ac9411df821bce30b23b62901127fdf0775cf70f74f9b689a3bc405

Contents?: true

Size: 1.34 KB

Versions: 57

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true
module CI
  module Queue
    module OutputHelpers
      private

      def step(*args, **kwargs)
        ci_provider.step(*args, **kwargs)
      end

      def reopen_previous_step
        ci_provider.reopen_previous_step
      end

      def close_previous_step
        ci_provider.close_previous_step
      end

      def ci_provider
        @ci_provider ||= if ENV['BUILDKITE']
          BuildkiteOutput
        else
          DefaultOutput
        end
      end

      def red(text)
        colorize(text, 31)
      end

      def green(text)
        colorize(text, 32)
      end

      def yellow(text)
        colorize(text, 33)
      end

      def colorize(text, color_code)
        "\e[#{color_code}m#{text}\e[0m"
      end

      module DefaultOutput
        extend self

        def step(title, collapsed: true)
          puts title
        end

        def reopen_previous_step
          # noop
        end

        def close_previous_step
          # noop
        end
      end

      module BuildkiteOutput
        extend self

        def step(title, collapsed: true)
          prefix = collapsed ? '---' : '+++'
          puts "#{prefix} #{title}"
        end

        def reopen_previous_step
          puts '^^^ +++'
        end

        def close_previous_step
          puts '^^^ ---'
        end
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
ci-queue-0.62.0 lib/ci/queue/output_helpers.rb
ci-queue-0.61.0 lib/ci/queue/output_helpers.rb
ci-queue-0.60.0 lib/ci/queue/output_helpers.rb
ci-queue-0.59.0 lib/ci/queue/output_helpers.rb
ci-queue-0.58.0 lib/ci/queue/output_helpers.rb
ci-queue-0.57.0 lib/ci/queue/output_helpers.rb
ci-queue-0.56.0 lib/ci/queue/output_helpers.rb
ci-queue-0.55.0 lib/ci/queue/output_helpers.rb
ci-queue-0.52.0 lib/ci/queue/output_helpers.rb
ci-queue-0.51.0 lib/ci/queue/output_helpers.rb
ci-queue-0.50.0 lib/ci/queue/output_helpers.rb
ci-queue-0.49.0 lib/ci/queue/output_helpers.rb
ci-queue-0.48.0 lib/ci/queue/output_helpers.rb
ci-queue-0.47.0 lib/ci/queue/output_helpers.rb
ci-queue-0.46.0 lib/ci/queue/output_helpers.rb
ci-queue-0.45.0 lib/ci/queue/output_helpers.rb
ci-queue-0.44.0 lib/ci/queue/output_helpers.rb
ci-queue-0.43.0 lib/ci/queue/output_helpers.rb
ci-queue-0.42.0 lib/ci/queue/output_helpers.rb
ci-queue-0.41.0 lib/ci/queue/output_helpers.rb