Sha256: a04187e5f7560940e47e5c8c4db18c6da484b68ca82e4d5821fa8d68f281521a

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true

require 'active_support/all'

# Calculates the next patch release date. Patch releases are scheduled
# twice a month based on the monthly release:
#
# - On the second Wednesday of the month (the week before the monthly release)
# - On the fourth Wednesday of the month (the week after the monthly release)
class PatchDateCalculator
  def initialize
    @next_release_date = ReleaseVersions.upcoming_release_date
  end

  def execute
    next_patch_date.strftime('%Y-%m-%d')
  end

  private

  attr_reader :next_release_date

  def next_patch_date
    if current_date >= prev_wednesday
      next_wednesday
    else
      prev_wednesday
    end
  end

  def current_date
    Date.today
  end

  def prev_wednesday
    next_release_date.prev_week(:wednesday)
  end

  def next_wednesday
    next_release_date.next_week(:wednesday)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab-releases-1.0.1 lib/gitlab_releases/patch_date_calculator.rb
gitlab-releases-1.0.0 lib/gitlab_releases/patch_date_calculator.rb
gitlab-releases-0.2.9 lib/gitlab_releases/patch_date_calculator.rb
gitlab-releases-0.2.7 lib/gitlab_releases/patch_date_calculator.rb