Sha256: fc3271cd4e933828afdb3df99133183df8d6767c0ff8a7c23da7598a368776bd

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Jiminy
  module Reporting
    require_relative "reporting/n_plus_one"
    require_relative "reporting/yaml_file_comment_presenter"
    require_relative "reporting/ci_providers"
    require_relative "reporting/reporters"

    TEMPLATES_DIR = File.expand_path("templates/reporting", __dir__).freeze

    COMMENT_HEADER = ERB.new(File.read(File.join(TEMPLATES_DIR, "comment_header.md.erb"))).result.freeze

    LINE_SEPARATOR = "\n"

    module_function

    def report!(*yaml_files, **options)
      return if yaml_files.empty?

      comment_content = yaml_files.map do |yaml_file|
        YAMLFileCommentPresenter.new(source_filepath: yaml_file, pr_number: options[:pr_number]).to_s
      end.join(LINE_SEPARATOR)

      return if comment_content.strip.empty?

      if options[:dry_run]
        Reporters::DryRunReporter.new(header: COMMENT_HEADER, body: comment_content).report!
      else
        Reporters::GithubReporter.new(header: COMMENT_HEADER, body: comment_content,
          pr_number: options[:pr_number]).report!
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jiminy-0.4.0 lib/jiminy/reporting.rb
jiminy-0.3.0 lib/jiminy/reporting.rb
jiminy-0.2.0 lib/jiminy/reporting.rb
jiminy-0.1.1 lib/jiminy/reporting.rb