Class: GovukTechDocs::PageReview
- Inherits:
-
Object
- Object
- GovukTechDocs::PageReview
- Defined in:
- lib/govuk_tech_docs/page_review.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(page, config = {}) ⇒ PageReview
constructor
A new instance of PageReview.
- #last_reviewed_on ⇒ Object
- #owner_slack ⇒ Object
- #owner_slack_url ⇒ Object
- #review_by ⇒ Object
- #show_expiry? ⇒ Boolean
- #show_review_banner? ⇒ Boolean
- #under_review? ⇒ Boolean
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
#page ⇒ Object (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_on ⇒ Object
23 24 25 |
# File 'lib/govuk_tech_docs/page_review.rb', line 23 def last_reviewed_on page.data.last_reviewed_on end |
#owner_slack ⇒ Object
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_url ⇒ Object
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_by ⇒ Object
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
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
43 44 45 |
# File 'lib/govuk_tech_docs/page_review.rb', line 43 def @config[:tech_docs].fetch(:show_review_banner, true) end |
#under_review? ⇒ Boolean
19 20 21 |
# File 'lib/govuk_tech_docs/page_review.rb', line 19 def under_review? page.data.review_in.present? end |