Class: Danger::Changelog::ChangelogEntryLine
- Inherits:
-
ChangelogLine
- Object
- ChangelogLine
- Danger::Changelog::ChangelogEntryLine
- Defined in:
- lib/changelog/changelog_line/changelog_entry_line.rb
Overview
A CHANGELOG.md line represents the change entry.
Instance Attribute Summary
Attributes inherited from ChangelogLine
Class Method Summary collapse
-
.example(github) ⇒ Object
provide an example of a CHANGELOG line based on a commit message.
-
.starts_with_star?(line) ⇒ Boolean
checks whether line starts with *.
- .validates_as_changelog_line?(line) ⇒ Boolean
-
.with_author_link?(line) ⇒ Boolean
checks whether line contains a MARKDOWN link to an author.
-
.with_changelog_description?(line) ⇒ Boolean
checks whether line contains a capitalized Text, treated as a description.
-
.with_pr_link?(line) ⇒ Boolean
checks whether line contains a MARKDOWN link to a PR.
Instance Method Summary collapse
Methods inherited from ChangelogLine
Constructor Details
This class inherits a constructor from Danger::Changelog::ChangelogLine
Class Method Details
.example(github) ⇒ Object
provide an example of a CHANGELOG line based on a commit message
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 23 def self.example(github) pr_number = github.pr_json['number'] pr_url = github.pr_json['html_url'] pr_title = github.pr_title .sub(/[?.!,;]?$/, '') .capitalize = github. = "https://github.com/#{github.}" "* [##{pr_number}](#{pr_url}): #{pr_title} - [@#{}](#{})." end |
.starts_with_star?(line) ⇒ Boolean
checks whether line starts with *
35 36 37 38 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 35 def self.starts_with_star?(line) return true if line =~ /^\*\s/ false end |
.validates_as_changelog_line?(line) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 13 def self.validates_as_changelog_line?(line) matched_rules_count = 0 matched_rules_count += 1 if starts_with_star?(line) matched_rules_count += 1 if with_pr_link?(line) matched_rules_count += 1 if with_changelog_description?(line) matched_rules_count += 1 if (line) matched_rules_count >= 2 end |
.with_author_link?(line) ⇒ Boolean
checks whether line contains a MARKDOWN link to an author
53 54 55 56 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 53 def self.(line) return true if line =~ %r{\[\@[\w\d\-\_]+\]\(http[s]?:\/\/github\.com\/.*[\w\d\-\_]+[\/]?\)} false end |
.with_changelog_description?(line) ⇒ Boolean
checks whether line contains a capitalized Text, treated as a description
47 48 49 50 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 47 def self.with_changelog_description?(line) return true if line =~ /[\`[:upper:]].*/ false end |
.with_pr_link?(line) ⇒ Boolean
checks whether line contains a MARKDOWN link to a PR
41 42 43 44 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 41 def self.with_pr_link?(line) return true if line =~ %r{\[\#\d+\]\(http[s]?:\/\/github\.com\/.*\d+[\/]?\)} false end |
Instance Method Details
#valid? ⇒ Boolean
7 8 9 10 11 |
# File 'lib/changelog/changelog_line/changelog_entry_line.rb', line 7 def valid? return true if line =~ %r{^\*\s[\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$} return true if line =~ %r{^\*\s\[\#\d+\]\(https:\/\/github\.com\/.*\d+\)\: [\`[:upper:]].*[^.,] \- \[\@[\w\d\-\_]+\]\(https:\/\/github\.com\/.*[\w\d\-\_]+\).$} false end |