Class: ReleaseHx::RHYML::Change

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • attrs (Hash) (defaults to: {})
    A hash of attributes for the Change.
  • release (Release)
    The required parent Release object.

Raises:

  • (ArgumentError)
    If attrs is not a Hash or if both 'part' and 'parts' are provided.


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

#authsObject (readonly)

Returns the value of attribute auths.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def auths
  @auths
end

#chidObject (readonly)

Returns the value of attribute chid.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def chid
  @chid
end

#hashObject (readonly)

Returns the value of attribute hash.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def hash
  @hash
end

#headObject (readonly)

Returns the value of attribute head.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def head
  @head
end

#leadObject (readonly)

Returns the value of attribute lead.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def lead
  @lead
end
Returns the value of attribute links.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def links
  @links
end

#noteObject (readonly)

Returns the value of attribute note.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def note
  @note
end

#partsObject (readonly)

Returns the value of attribute parts.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def parts
  @parts
end

#releaseObject

Returns the value of attribute release.


12
13
14
# File 'lib/releasehx/rhyml/change.rb', line 12

def release
  @release
end

#summObject (readonly)

Returns the value of attribute summ.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def summ
  @summ
end

#tagsObject (readonly)

Returns the value of attribute tags.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def tags
  @tags
end

#tickObject (readonly)

Returns the value of attribute tick.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def tick
  @tick
end

#typeObject (readonly)

Returns the value of attribute type.


13
14
15
# File 'lib/releasehx/rhyml/change.rb', line 13

def type
  @type
end

#versionObject

Returns the value of attribute version.


12
13
14
# File 'lib/releasehx/rhyml/change.rb', line 12

def version
  @version
end

#vrsnObject (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.

Returns:

  • (Boolean)
    True if the Change is a breaking change.


89
90
# File 'lib/releasehx/rhyml/change.rb', line 89

def breaking?     = tags.include?('breaking')
# @return [Boolean] True if the Change is experimental.

#deprecation?Boolean

Returns True if the Change includes a deprecation.

Returns:

  • (Boolean)
    True if the Change includes a deprecation.


93
94
# File 'lib/releasehx/rhyml/change.rb', line 93

def deprecation?  = tags.include?('deprecation')
# @return [Boolean] True if the Change includes a removal.

#experimental?Boolean

Returns True if the Change is experimental.

Returns:

  • (Boolean)
    True if the Change is experimental.


91
92
# File 'lib/releasehx/rhyml/change.rb', line 91

def experimental? = tags.include?('experimental')
# @return [Boolean] True if the Change includes a deprecation.

#highlight?Boolean

Returns True if the Change is tagged as a highlight.

Returns:

  • (Boolean)
    True if the Change is tagged as a highlight.


87
88
# File 'lib/releasehx/rhyml/change.rb', line 87

def highlight? = tags.include?('highlight')
# @return [Boolean] True if the Change is a breaking change.

#removal?Boolean

Returns True if the Change includes a removal.

Returns:

  • (Boolean)
    True if the Change includes a removal.


95
# File 'lib/releasehx/rhyml/change.rb', line 95

def removal?      = tags.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.

Parameters:

  • tag_name (String, Symbol)
    The name of the tag to check.

Returns:

  • (Boolean)
    True if the tag exists in any form.


104
105
106
# File 'lib/releasehx/rhyml/change.rb', line 104

def tag? tag_name
  tags.include?(tag_name) || tags.include?(tag_name.to_s) || tags.include?(tag_name.to_sym)
end

#to_hHash

Produces a comprehensive hash representation of the Change. Includes all public attributes plus computed boolean properties for common Change classifications (highlight, breaking, etc.).

Returns:

  • (Hash)
    A hash containing all public attributes of the Change.


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' => tags,
    'lead' => lead,
    'auths' => auths,
    'links' => links,
    'deprecation' => deprecation?,
    'removal' => removal?,
    'highlight' => highlight?,
    'breaking' => breaking?,
    'experimental' => experimental?
  }
end