Sha256: 2b20f8c47e1e6f7ec8b99a61bc8daf3896f07a1b8fc326a1130abdcb29a38570

Contents?: true

Size: 1.19 KB

Versions: 29

Compression:

Stored size: 1.19 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

    def show_review_banner?
      @config[:tech_docs].fetch(:show_review_banner, 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

29 entries across 29 versions & 1 rubygems

Version Path
govuk_tech_docs-4.1.1 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-4.1.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-4.0.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.5.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.4.5 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.4.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.3.1 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.3.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.2.1 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.2.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.1.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.0.1 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-3.0.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.4.3 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.4.2 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.4.1 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.4.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.3.0 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.2.2 lib/govuk_tech_docs/page_review.rb
govuk_tech_docs-2.2.1 lib/govuk_tech_docs/page_review.rb