Sha256: 89ba8f49099a8e9b383f0c4610250787093f62fe39b7913766785ceb4571f5ff

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative './utils/feature_flag_consts'

module Dri
  class FeatureFlagReport
    include Dri::Utils::FeatureFlagConsts

    attr_reader :header, :labels, :prod, :staging, :staging_ref, :preprod

    def initialize
      @header = '## Feature Flag Changes'
      @labels = %w[Summary Changed(UTC) URL]
      @prod = []
      @staging = []
      @staging_ref = []
      @preprod = []
    end

    def add_change(feature_flag)
      summary = feature_flag.title

      changed_on = feature_flag.description[/(?<=Changed on \(in UTC\): ).+?(?=\n)/].delete('`')
      url = feature_flag.web_url

      feature_flag_data = [summary, changed_on, url]

      labels = feature_flag.labels
      host_label = labels.select { |label| /^host::/.match(label) }.join('')

      case host_label
      when PRODUCTION
        @prod << feature_flag_data
      when STAGING
        @staging << feature_flag_data
      when STAGING_REF
        @staging_ref << feature_flag_data
      when PREPROD
        @preprod << feature_flag_data
      end
    end

    def get_all_flag_changes
      { production: @prod, staging: @staging, staging_ref: @staging_ref, preprod: @preprod }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dri-0.7.0 lib/dri/feature_flag_report.rb
dri-0.6.1 lib/dri/feature_flag_report.rb
dri-0.6.0 lib/dri/feature_flag_report.rb
dri-0.5.1 lib/dri/feature_flag_report.rb
dri-0.5.0 lib/dri/feature_flag_report.rb