Sha256: f3c66e3585215e08dd571b144bb50109f364af560b1f66ca77a68ff6f6a4f35d

Contents?: true

Size: 1.74 KB

Versions: 31

Compression:

Stored size: 1.74 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

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

    FOOTER = <<'EOS'
    See https://github.com/newrelic/rpm/blob/master/CHANGELOG for a full list of
    changes.
EOS

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

      changes.join("\n")
    end

    # 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)
    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 line.match(/^\s*\*.*/)
          if line.match(/\(#{patch_level}\)/)
            # 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

    def self.extract_latest_changes(contents)
      changes = []
      version_count = 0
      contents.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
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
newrelic_rpm-3.17.1.326 lib/new_relic/latest_changes.rb
newrelic_rpm-3.17.0.325 lib/new_relic/latest_changes.rb
newrelic_rpm-3.16.3.323 lib/new_relic/latest_changes.rb
newrelic_rpm-3.16.2.321 lib/new_relic/latest_changes.rb
newrelic_rpm-3.16.1.320 lib/new_relic/latest_changes.rb
newrelic_rpm-3.16.0.318 lib/new_relic/latest_changes.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/latest_changes.rb
newrelic_rpm-3.15.2.317 lib/new_relic/latest_changes.rb
newrelic_rpm-3.15.1.316 lib/new_relic/latest_changes.rb
newrelic_rpm-3.15.0.314 lib/new_relic/latest_changes.rb
newrelic_rpm-3.14.3.313 lib/new_relic/latest_changes.rb
newrelic_rpm-3.14.2.312 lib/new_relic/latest_changes.rb
newrelic_rpm-3.14.1.311 lib/new_relic/latest_changes.rb
newrelic_rpm-3.14.0.305 lib/new_relic/latest_changes.rb
newrelic_rpm-3.13.2.302 lib/new_relic/latest_changes.rb
newrelic_rpm-3.13.1.300 lib/new_relic/latest_changes.rb
newrelic_rpm-3.13.0.299 lib/new_relic/latest_changes.rb
newrelic_rpm-3.12.1.298 lib/new_relic/latest_changes.rb
newrelic_rpm-3.12.0.288 lib/new_relic/latest_changes.rb
newrelic_rpm-3.11.2.286 lib/new_relic/latest_changes.rb