class Schmersion::Message
Constants
- FOOTER_COLON_REGEX
- FOOTER_TICKET_REGEX
- REGEX
Attributes
body[R]
breaking_changes[R]
description[R]
header[R]
pull_request_id[R]
scope[R]
type[R]
Public Class Methods
new(raw_message)
click to toggle source
# File lib/schmersion/message.rb, line 19 def initialize(raw_message) @raw_message = clean(raw_message) parts = @raw_message.split("\n\n").map(&:strip) @header = parts.shift @paragraphs = parts @breaking_changes = [] @footers = [] parse_header parse_footers @body = @paragraphs.join("\n\n") end
Public Instance Methods
breaking_change?()
click to toggle source
# File lib/schmersion/message.rb, line 39 def breaking_change? @breaking_change == true || @breaking_changes.size.positive? end
merge?()
click to toggle source
# File lib/schmersion/message.rb, line 44 def merge? @raw_message.match?(/\AMerge\s+/) end
valid?()
click to toggle source
# File lib/schmersion/message.rb, line 35 def valid? !@type.nil? end
Private Instance Methods
clean(message)
click to toggle source
# File lib/schmersion/message.rb, line 94 def clean(message) message.sub(/.*-----END PGP SIGNATURE-----\n\n/m, '') end
parse_header()
click to toggle source
# File lib/schmersion/message.rb, line 50 def parse_header match = @header.match(REGEX) return unless match @type = match[1] @scope = match[2] @description = match[4].strip @pull_request_id = match[5] @breaking_change = true if match[3] == '!' match end