Sha256: 98d68a7c2886c4de55cf52ce34e65edb9566f1155a0997a9656ecee0725bf145

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Decidim
  module BackportsReporter
    # Abstract class for the different formats
    class Report
      attr_reader :report, :last_version_number

      def initialize(report:, last_version_number:)
        @report = report
        @last_version_number = last_version_number
      end

      def call = output_report

      private

      def penultimate_version_number
        major, minor = last_version_number.split(".")

        "#{major}.#{minor.to_i - 1}"
      end

      def output_report
        output = output_head
        report.each do |line|
          output += output_line(line)
        end
        output
      end

      def output_head = raise "Called abstract method: output_head"

      def output_line(_line) = raise "Called abstract method: output_line"

      def extract_backport_pull_request_for_version(related_issues, version)
        related_issues = related_issues.select do |pull_request|
          pull_request[:title].start_with?("Backport") && pull_request[:title].include?(version)
        end
        return if related_issues.empty?

        related_issues.first
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-0.28.4 lib/decidim/backports_reporter/report.rb
decidim-0.28.3 lib/decidim/backports_reporter/report.rb
decidim-0.28.2 lib/decidim/backports_reporter/report.rb
decidim-0.28.1 lib/decidim/backports_reporter/report.rb
decidim-0.28.0 lib/decidim/backports_reporter/report.rb
decidim-0.28.0.rc5 lib/decidim/backports_reporter/report.rb
decidim-0.28.0.rc4 lib/decidim/backports_reporter/report.rb