Sha256: b04794e25777b0a1a7d53853a10daa8678fa06560e5d47bdd37ed6e15447666a

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module GovukTechDocs
  class PageReview
    attr_reader :page

    def initialize(page, config = {})
      @page = page
      @config = config
    end

    def review_by
      return unless last_reviewed_on

      @review_by ||= Chronic.parse(
        "in #{page.data.review_in}",
        now: last_reviewed_on.to_time
      ).to_date
    end

    def under_review?
      page.data.review_in.present?
    end

    def last_reviewed_on
      page.data.last_reviewed_on
    end

    def owner_slack
      page.data.owner_slack || default_owner_slack
    end

    def owner_slack_url
      return "" unless owner_slack_workspace
      # Slack URLs don't have the # (channels) or @ (usernames)
      slack_identifier = owner_slack.to_s.delete('#').delete('@')
      "https://#{owner_slack_workspace}.slack.com/messages/#{slack_identifier}"
    end

    def show_expiry?
      @config[:tech_docs].fetch(:show_expiry, true)
    end

  private

    def default_owner_slack
      @config[:tech_docs][:default_owner_slack]
    end

    def owner_slack_workspace
      @config[:tech_docs][:owner_slack_workspace]
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
govuk_tech_docs-1.9.0.pre.rc2 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-1.9.0.pre.gfe lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-1.8.3 lib/govuk_tech_docs/page_review.rb
dss_tech_docs-0.1.2 lib/govuk_tech_docs/page_review.rb
dss_tech_docs-0.1.1 lib/govuk_tech_docs/page_review.rb
dss_tech_docs-0.1.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-1.8.2 lib/govuk_tech_docs/page_review.rb