Module: NewRelic::LatestChanges

Defined in:
lib/new_relic/latest_changes.rb

Class Method Summary collapse

Class Method Details

.default_changelogObject



9
10
11
# File 'lib/new_relic/latest_changes.rb', line 9

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

.read(changelog = default_changelog) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/latest_changes.rb', line 13

def self.read(changelog=default_changelog)
  footer = <<'EOS'
See https://github.com/newrelic/rpm/blob/master/CHANGELOG for a full list of
changes.
EOS

  return footer unless File.exists?(changelog) 

  version_count = 0
  changes = []
  File.read(changelog).each_line do |line|
    if line.match(/##\s+v[\d.]+\s+##/)
      version_count += 1
    end
    break if version_count >= 2
    changes << line.sub(/^  \* /, "* ").chomp
  end

  changes << footer
  change_message =  changes.join("\n")
end