Class: Schmersion::Message
- Inherits:
-
Object
- Object
- Schmersion::Message
- Defined in:
- lib/schmersion/message.rb
Constant Summary collapse
- REGEX =
/^([\w-]+)(?:\(([\w-]+)\))?(!)?:\s(.*?)(?:\(#(\d+)\))?$/.freeze
- FOOTER_COLON_REGEX =
/^([\w-]+:|BREAKING CHANGE:)\s*(.*)$/.freeze
- FOOTER_TICKET_REGEX =
/^([\w-]+)\s+(#.*)$/.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#breaking_changes ⇒ Object
readonly
Returns the value of attribute breaking_changes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#footers ⇒ Object
readonly
Returns the value of attribute footers.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#pull_request_id ⇒ Object
readonly
Returns the value of attribute pull_request_id.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #breaking_change? ⇒ Boolean
-
#initialize(raw_message) ⇒ Message
constructor
A new instance of Message.
- #merge? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(raw_message) ⇒ Message
Returns a new instance of Message.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/schmersion/message.rb', line 19 def initialize() @raw_message = clean() parts = @raw_message.split("\n\n").map(&:strip) @header = parts.shift @paragraphs = parts @breaking_changes = [] @footers = [] parse_header @body = @paragraphs.join("\n\n") end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
15 16 17 |
# File 'lib/schmersion/message.rb', line 15 def body @body end |
#breaking_changes ⇒ Object (readonly)
Returns the value of attribute breaking_changes.
17 18 19 |
# File 'lib/schmersion/message.rb', line 17 def breaking_changes @breaking_changes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
14 15 16 |
# File 'lib/schmersion/message.rb', line 14 def description @description end |
#footers ⇒ Object (readonly)
Returns the value of attribute footers.
11 12 13 |
# File 'lib/schmersion/message.rb', line 11 def @footers end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
10 11 12 |
# File 'lib/schmersion/message.rb', line 10 def header @header end |
#pull_request_id ⇒ Object (readonly)
Returns the value of attribute pull_request_id.
16 17 18 |
# File 'lib/schmersion/message.rb', line 16 def pull_request_id @pull_request_id end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
13 14 15 |
# File 'lib/schmersion/message.rb', line 13 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/schmersion/message.rb', line 12 def type @type end |
Instance Method Details
#breaking_change? ⇒ Boolean
39 40 41 42 |
# File 'lib/schmersion/message.rb', line 39 def breaking_change? @breaking_change == true || @breaking_changes.size.positive? end |
#merge? ⇒ Boolean
44 45 46 |
# File 'lib/schmersion/message.rb', line 44 def merge? @raw_message.match?(/\AMerge\s+/) end |
#valid? ⇒ Boolean
35 36 37 |
# File 'lib/schmersion/message.rb', line 35 def valid? !@type.nil? end |