Class: GovukTechDocs::SourceUrls

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject (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_pageObject (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_branchObject



35
36
37
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 35

def repo_branch
  config[:tech_docs][:github_branch] || 'master'
end

#repo_urlObject



31
32
33
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 31

def repo_url
  "https://github.com/#{config[:tech_docs][:github_repo]}"
end

#report_issue_urlObject



21
22
23
24
25
26
27
28
29
# File 'lib/govuk_tech_docs/contribution_banner.rb', line 21

def report_issue_url
  url = config[:source_urls]&.[](:report_issue_url)

  if url.nil?
    "#{repo_url}/issues/new?labels=bug&title=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})"
  else
    "#{url}?subject=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})"
  end
end

#view_source_urlObject



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