Sha256: 90878aa8ef57e8e0d9e55f2861f3c47c20c29f6e8d01c5b54065aa67ece95d17

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Danger
  # Handles reporting messages in the context of Danger, allowing the generation of
  # warnings, errors, and simple messages in a Danger run.
  #
  # @example Reporting a Warning
  #   reporter.report(message: "This is a warning message", type: :warning)
  #
  # @example Reporting an Error
  #   reporter.report(message: "This is an error message", type: :error)
  #
  # @see Automattic/dangermattic
  # @tags tool, util, danger
  #
  class Reporter < Plugin
    # Report a message to be posted by Danger as an error (failing the build), a warning or a simple message.
    #
    # @param message [String] The message to be reported to Danger.
    # @param type [Symbol] The type of report. Possible values:
    #                        - :warning (default): Reports a warning.
    #                        - :error: Reports an error.
    #                        - :message: Reports a simple message.
    #                        - Any other value or nil: Takes no action.
    #
    # @return [void]
    def report(message:, type: :warning)
      case type
      when :error
        failure(message)
      when :warning
        warn(message)
      when :message
        danger.message(message)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
danger-dangermattic-1.2.2 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.2.1 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.2.0 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.1.2 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.0.2 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.0.1 lib/dangermattic/plugins/common/reporter.rb
danger-dangermattic-1.0.0 lib/dangermattic/plugins/common/reporter.rb