Class: GovukTechDocs::SourceUrls
- Inherits:
-
Object
- Object
- GovukTechDocs::SourceUrls
- Defined in:
- lib/govuk_tech_docs/contribution_banner.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
Instance Method Summary collapse
-
#initialize(current_page, config) ⇒ SourceUrls
constructor
A new instance of SourceUrls.
- #repo_branch ⇒ Object
- #repo_url ⇒ Object
- #report_issue_url ⇒ Object
- #view_source_url ⇒ Object
Constructor Details
#initialize(current_page, config) ⇒ SourceUrls
Returns a new instance of SourceUrls.
12 13 14 15 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 12 def initialize(current_page, config) @current_page = current_page @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 10 def config @config end |
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
10 11 12 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 10 def current_page @current_page end |
Instance Method Details
#repo_branch ⇒ Object
41 42 43 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 41 def repo_branch config[:tech_docs][:github_branch] || "master" # TODO: change this to 'main' in a future breaking release end |
#repo_url ⇒ Object
37 38 39 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 37 def repo_url "https://github.com/#{config[:tech_docs][:github_repo]}" end |
#report_issue_url ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 21 def report_issue_url url = config[:source_urls]&.[](:report_issue_url) params = { body: "Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})", } if url.nil? url = "#{repo_url}/issues/new" params["labels"] = "bug" params["title"] = "Re: '#{current_page.data.title}'" else params["subject"] = "Re: '#{current_page.data.title}'" end "#{url}?#{URI.encode_www_form(params)}" end |
#view_source_url ⇒ Object
17 18 19 |
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 17 def view_source_url override_from_page || source_from_yaml_file || source_from_file end |