Class: Publisher::Helpers::UrlSectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/allure_report_publisher/lib/helpers/url_section_builder.rb

Overview

Urls section builder

Constant Summary collapse

DESCRIPTION_PATTERN =
/<!-- allure -->[\s\S]+<!-- allurestop -->/
JOBS_PATTERN =
/<!-- jobs -->(?<jobs>[\s\S]+)<!-- jobs -->/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ UrlSectionBuilder

Url section builder

Parameters:

  • report_url (String)
  • report_path (String)
  • build_name (String)
  • sha_url (String)
  • summary_type (String)
  • collapse_summary (String)
  • flaky_warning_status (Boolean)
  • report_title (String)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 19

def initialize(**args)
  @report_url = args[:report_url]
  @report_path = args[:report_path]
  @build_name = args[:build_name]
  @sha_url = args[:sha_url]
  @summary_type = args[:summary_type]
  @summary_table_type = args[:summary_table_type]
  @collapse_summary = args[:collapse_summary]
  @flaky_warning_status = args[:flaky_warning_status]
  @report_title = args[:report_title]
end

Instance Attribute Details

#build_nameObject (readonly)

Returns the value of attribute build_name.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def build_name
  @build_name
end

#collapse_summaryObject (readonly)

Returns the value of attribute collapse_summary.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def collapse_summary
  @collapse_summary
end

#flaky_warning_statusObject (readonly)

Returns the value of attribute flaky_warning_status.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def flaky_warning_status
  @flaky_warning_status
end

#report_pathObject (readonly)

Returns the value of attribute report_path.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def report_path
  @report_path
end

#report_titleObject (readonly)

Returns the value of attribute report_title.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def report_title
  @report_title
end

#report_urlObject (readonly)

Returns the value of attribute report_url.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def report_url
  @report_url
end

#sha_urlObject (readonly)

Returns the value of attribute sha_url.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def sha_url
  @sha_url
end

#summary_table_typeObject (readonly)

Returns the value of attribute summary_table_type.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def summary_table_type
  @summary_table_type
end

#summary_typeObject (readonly)

Returns the value of attribute summary_type.



65
66
67
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 65

def summary_type
  @summary_type
end

Class Method Details

.match?(urls_block) ⇒ Boolean

Matches url section pattern

Parameters:

  • urls_block (String)

Returns:

  • (Boolean)


35
36
37
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 35

def self.match?(urls_block)
  urls_block.match?(DESCRIPTION_PATTERN)
end

Instance Method Details

#comment_body(pr_comment = nil) ⇒ String

Comment body with allure report urls

Parameters:

  • pr_comment (String) (defaults to: nil)

Returns:

  • (String)


58
59
60
61
62
63
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 58

def comment_body(pr_comment = nil)
  return url_section(separator: false) unless pr_comment

  job_entries = jobs_section(pr_comment)
  url_section(job_entries: job_entries, separator: false)
end

#updated_pr_description(pr_description) ⇒ String

PR description with allure report urls

Parameters:

  • pr_description (String)

Returns:

  • (String)


43
44
45
46
47
48
49
50
51
52
# File 'lib/allure_report_publisher/lib/helpers/url_section_builder.rb', line 43

def updated_pr_description(pr_description)
  stripped_description = (pr_description || "").strip

  return url_section(separator: false) if stripped_description == ""
  return "#{pr_description}\n\n#{url_section}" unless pr_description.match?(DESCRIPTION_PATTERN)

  job_entries = jobs_section(pr_description)
  non_empty = stripped_description != pr_description.match(DESCRIPTION_PATTERN)[0]
  pr_description.gsub(DESCRIPTION_PATTERN, url_section(job_entries: job_entries, separator: non_empty))
end