Class: Gitlab::Release::Changelog::Entries

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/release/changelog/entries.rb

Overview

This class is a collection wrapper of changelog items, useful to generate easily changelog as String.

Instance Method Summary collapse

Constructor Details

#initializeEntries

Returns a new instance of Entries.



8
9
10
11
# File 'lib/gitlab/release/changelog/entries.rb', line 8

def initialize
  # @type [Array] elements
  @elements = []
end

Instance Method Details

#push(element) ⇒ Object

Add a new Entry element.

Parameters:



18
19
20
# File 'lib/gitlab/release/changelog/entries.rb', line 18

def push(element)
  @elements.push(element)
end

#to_sString

Print the changelog without any reference.

Returns:

  • (String)


27
28
29
# File 'lib/gitlab/release/changelog/entries.rb', line 27

def to_s
  internal_to_s_with_reference(false)
end

#to_s_with_referenceString

Print the changelog with relative reference.

Returns:

  • (String)


36
37
38
# File 'lib/gitlab/release/changelog/entries.rb', line 36

def to_s_with_reference
  internal_to_s_with_reference(true)
end

#write_in_file(path, appending = false, with_reference = true) ⇒ Object

Write the changelog content as String in a file.

Parameters:

  • path (String)

    Required. path The file path. You can specify a series of file paths with regex.

  • appending (Boolean) (defaults to: false)

    Optional. Append the changelog contents at the bottom of the file. Default: false

  • with_reference (Boolean) (defaults to: true)

    Optional. Generate the changelog with MRs and Issues reference. Default true



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/gitlab/release/changelog/entries.rb', line 47

def write_in_file(path, appending = false, with_reference = true)
  # @type [String] changelog_string
  changelog_string = internal_to_s_with_reference(with_reference)

  searched_paths = Dir.glob(path)
  if !searched_paths.empty?
    searched_paths.each do |single_path|
      internal_write_on_file(single_path, changelog_string, appending)
    end
  else
    internal_write_on_file(path, changelog_string, appending)
  end
end