Class: GovukTechDocs::PageReview

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_tech_docs/page_review.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, config = {}) ⇒ PageReview

Returns a new instance of PageReview.



5
6
7
8
# File 'lib/govuk_tech_docs/page_review.rb', line 5

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

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/govuk_tech_docs/page_review.rb', line 3

def page
  @page
end

Instance Method Details

#last_reviewed_onObject



23
24
25
# File 'lib/govuk_tech_docs/page_review.rb', line 23

def last_reviewed_on
  page.data.last_reviewed_on
end

#owner_slackObject



27
28
29
# File 'lib/govuk_tech_docs/page_review.rb', line 27

def owner_slack
  page.data.owner_slack || default_owner_slack
end

#owner_slack_urlObject



31
32
33
34
35
36
37
# File 'lib/govuk_tech_docs/page_review.rb', line 31

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

#review_byObject



10
11
12
13
14
15
16
17
# File 'lib/govuk_tech_docs/page_review.rb', line 10

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

#show_expiry?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/govuk_tech_docs/page_review.rb', line 39

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

#show_review_banner?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/govuk_tech_docs/page_review.rb', line 43

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

#under_review?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/govuk_tech_docs/page_review.rb', line 19

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