Class: GemChangelogDiff::ChangelogParser

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_changelog_diff/changelog_parser.rb

Constant Summary collapse

CONTENTS_URL =
"https://api.github.com/repos/%<repo>s/contents/%<path>s"
FILENAMES =
%w[CHANGELOG.md CHANGES.md History.md NEWS.md].freeze
VERSION_HEADING =
/^##\s+\[?v?(\d+[^\]\s]+)/

Instance Method Summary collapse

Constructor Details

#initialize(cache: nil) ⇒ ChangelogParser

Returns a new instance of ChangelogParser.



12
13
14
# File 'lib/gem_changelog_diff/changelog_parser.rb', line 12

def initialize(cache: nil)
  @cache = cache
end

Instance Method Details

#entries_between(repo, current_version, newest_version) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gem_changelog_diff/changelog_parser.rb', line 16

def entries_between(repo, current_version, newest_version)
  content = fetch_changelog(repo)
  return [] unless content

  parse_entries(content, current_version, newest_version)
rescue SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
       Errno::ETIMEDOUT, Errno::ECONNRESET,
       Net::OpenTimeout, Net::ReadTimeout,
       OpenSSL::SSL::SSLError => e
  raise NetworkError, "GitHub API request failed: #{e.message}"
end