Module: NewRelic::LatestChanges

Defined in:
lib/new_relic/latest_changes.rb

Constant Summary collapse

<<EOS
    See https://github.com/newrelic/newrelic-ruby-agent/blob/main/CHANGELOG.md for a full list of
    changes.
EOS

Class Method Summary collapse

Class Method Details

.default_changelogObject



7
8
9
# File 'lib/new_relic/latest_changes.rb', line 7

def self.default_changelog
  File.join(File.dirname(__FILE__), '..', '..', 'CHANGELOG.md')
end

.extract_latest_changes(contents) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/new_relic/latest_changes.rb', line 51

def self.extract_latest_changes(contents)
  changes = []
  version_count = 0
  contents.each_line do |line|
    if /##\s+v[\d.]+/.match?(line)
      version_count += 1
    end
    break if version_count >= 2

    changes << line.sub(/^  \* /, '* ').chomp
  end
  changes
end

.read(changelog = default_changelog) ⇒ Object



16
17
18
19
20
21
# File 'lib/new_relic/latest_changes.rb', line 16

def self.read(changelog = default_changelog)
  changes = extract_latest_changes(File.read(changelog))
  changes << FOOTER

  changes.join("\n")
end

.read_patch(patch_level, changelog = default_changelog) ⇒ Object

Patches are expected to have the format of our normal item, with the precise version number included in the line in parens. For example:

  • This is a patch item (3.7.1.188)



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/new_relic/latest_changes.rb', line 27

def self.read_patch(patch_level, changelog = default_changelog)
  latest = extract_latest_changes(File.read(changelog))
  changes = ["## v#{patch_level}", '']

  current_item = nil
  latest.each do |line|
    if /^\s*\*.*/.match?(line)
      if /\(#{patch_level}\)/.match?(line)
        # Found a patch level item, so start tracking the lines!
        current_item = line
      else
        # Found an item that isn't our patch level, so don't grab it
        current_item = nil
      end
    end

    if current_item
      changes << line
    end
  end

  changes.join("\n")
end