Class: ReleaseHx::RHYML::Change
- Inherits:
-
Object
- Object
- ReleaseHx::RHYML::Change
- Defined in:
- lib/releasehx/rhyml/change.rb
Overview
Represents a single Change within a Release, such as a bug fix, feature, or enhancement.
The Change class encapsulates all metadata associated with an individual modification,
including its classification (type), descriptive content (summary, notes),
organizational data (tags, parts), and contributor information.
Changes are always associated with a parent Release object.
Instance Attribute Summary collapse
-
#auths ⇒ Object
readonly
Returns the value of attribute auths.
-
#chid ⇒ Object
readonly
Returns the value of attribute chid.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#lead ⇒ Object
readonly
Returns the value of attribute lead.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
-
#release ⇒ Object
Returns the value of attribute release.
-
#summ ⇒ Object
readonly
Returns the value of attribute summ.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tick ⇒ Object
readonly
Returns the value of attribute tick.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
-
#vrsn ⇒ Object
readonly
Returns the value of attribute vrsn.
Instance Method Summary collapse
-
#breaking? ⇒ Boolean
True if the Change is a breaking change.
-
#deprecation? ⇒ Boolean
True if the Change includes a deprecation.
-
#experimental? ⇒ Boolean
True if the Change is experimental.
-
#highlight? ⇒ Boolean
True if the Change is tagged as a highlight.
-
#initialize(attrs = {}, release:) ⇒ Change
constructor
Initializes a new Change object from attribute hash and parent Release.
-
#removal? ⇒ Boolean
True if the Change includes a removal.
-
#tag?(tag_name) ⇒ Boolean
Checks if a given tag is associated with the Change.
-
#to_h ⇒ Hash
Produces a comprehensive hash representation of the Change.
Constructor Details
#initialize(attrs = {}, release:) ⇒ Change
Initializes a new Change object from attribute hash and parent Release.
Processes the provided attributes to populate Change properties, handling
multiple possible field names (e.g., 'summ', 'summary', 'title') and
normalizing complex attributes like authors and links.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/releasehx/rhyml/change.rb', line 24 def initialize attrs = {}, release: raise ArgumentError, 'attrs must be a Hash' unless attrs.is_a? Hash @release = release @vrsn = @release.code @chid = attrs['chid'] @tick = attrs_value(attrs, %w[tick ticketid]) @hash = attrs['hash'] @type = attrs['type'] @summ = attrs_value(attrs, %w[summ summary title]) @head = attrs['head'] @note = attrs['note'] @tags = attrs['tags'] || [] @lead = attrs_value(attrs, %w[lead contributor auth]) @auths = normalize_auths(attrs['auths']) @links = normalize_links(attrs['links']) # Handle 'part' vs 'parts'; mutually exclusive attributes part = attrs['part'] parts = attrs['parts'] raise ArgumentError, "Change cannot have both 'part' and 'parts'" if part && parts @parts = if parts Array(parts).map(&:to_s) elsif part [part.to_s] else [] end ReleaseHx.logger.debug "Initialized Change: #{@tick} – #{@summ}" end |
Instance Attribute Details
#auths ⇒ Object (readonly)
Returns the value of attribute auths.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def auths @auths end |
#chid ⇒ Object (readonly)
Returns the value of attribute chid.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def chid @chid end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def hash @hash end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def head @head end |
#lead ⇒ Object (readonly)
Returns the value of attribute lead.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def lead @lead end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def links @links end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def note @note end |
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def parts @parts end |
#release ⇒ Object
Returns the value of attribute release.
12 13 14 |
# File 'lib/releasehx/rhyml/change.rb', line 12 def release @release end |
#summ ⇒ Object (readonly)
Returns the value of attribute summ.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def summ @summ end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def @tags end |
#tick ⇒ Object (readonly)
Returns the value of attribute tick.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def tick @tick end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/releasehx/rhyml/change.rb', line 12 def version @version end |
#vrsn ⇒ Object (readonly)
Returns the value of attribute vrsn.
13 14 15 |
# File 'lib/releasehx/rhyml/change.rb', line 13 def vrsn @vrsn end |
Instance Method Details
#breaking? ⇒ Boolean
Returns True if the Change is a breaking change.
89 90 |
# File 'lib/releasehx/rhyml/change.rb', line 89 def breaking? = .include?('breaking') # @return [Boolean] True if the Change is experimental. |
#deprecation? ⇒ Boolean
Returns True if the Change includes a deprecation.
93 94 |
# File 'lib/releasehx/rhyml/change.rb', line 93 def deprecation? = .include?('deprecation') # @return [Boolean] True if the Change includes a removal. |
#experimental? ⇒ Boolean
Returns True if the Change is experimental.
91 92 |
# File 'lib/releasehx/rhyml/change.rb', line 91 def experimental? = .include?('experimental') # @return [Boolean] True if the Change includes a deprecation. |
#highlight? ⇒ Boolean
Returns True if the Change is tagged as a highlight.
87 88 |
# File 'lib/releasehx/rhyml/change.rb', line 87 def highlight? = .include?('highlight') # @return [Boolean] True if the Change is a breaking change. |
#removal? ⇒ Boolean
Returns True if the Change includes a removal.
95 |
# File 'lib/releasehx/rhyml/change.rb', line 95 def removal? = .include?('removal') |
#tag?(tag_name) ⇒ Boolean
Checks if a given tag is associated with the Change.
Performs flexible tag matching, checking for the tag as provided,
as a string, and as a symbol to handle different input types.
104 105 106 |
# File 'lib/releasehx/rhyml/change.rb', line 104 def tag? tag_name .include?(tag_name) || .include?(tag_name.to_s) || .include?(tag_name.to_sym) end |
#to_h ⇒ Hash
Produces a comprehensive hash representation of the Change.
Includes all public attributes plus computed boolean properties
for common Change classifications (highlight, breaking, etc.).
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/releasehx/rhyml/change.rb', line 63 def to_h { 'vrsn' => vrsn, 'chid' => chid, 'tick' => tick, 'hash' => hash, 'type' => type, 'parts' => parts, 'summ' => summ, 'head' => head, 'note' => note, 'tags' => , 'lead' => lead, 'auths' => auths, 'links' => links, 'deprecation' => deprecation?, 'removal' => removal?, 'highlight' => highlight?, 'breaking' => breaking?, 'experimental' => experimental? } end |