Class: GemDigest::ChangelogFetcher
- Inherits:
-
Object
- Object
- GemDigest::ChangelogFetcher
- Defined in:
- lib/gem_digest/changelog_fetcher.rb
Instance Method Summary collapse
- #fetch_changelog_url(gem_name) ⇒ Object
- #fetch_release_notes(gem_name, from_version, to_version) ⇒ Object
-
#initialize ⇒ ChangelogFetcher
constructor
A new instance of ChangelogFetcher.
Constructor Details
#initialize ⇒ ChangelogFetcher
Returns a new instance of ChangelogFetcher.
9 10 11 |
# File 'lib/gem_digest/changelog_fetcher.rb', line 9 def initialize @cache = {} end |
Instance Method Details
#fetch_changelog_url(gem_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gem_digest/changelog_fetcher.rb', line 13 def fetch_changelog_url(gem_name) return @cache[gem_name] if @cache.key?(gem_name) uri = URI("https://rubygems.org/api/v1/gems/#{gem_name}.json") begin response = Net::HTTP.get_response(uri) return nil unless response.code == "200" gem_info = JSON.parse(response.body) changelog_url = gem_info["changelog_uri"] || gem_info["homepage_uri"] || gem_info["source_code_uri"] @cache[gem_name] = changelog_url changelog_url rescue StandardError => e warn "Warning: Could not fetch changelog for #{gem_name}: #{e.message}" @cache[gem_name] = nil nil end end |
#fetch_release_notes(gem_name, from_version, to_version) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gem_digest/changelog_fetcher.rb', line 36 def fetch_release_notes(gem_name, from_version, to_version) # This is a placeholder for more advanced changelog parsing # In a real implementation, you might parse GitHub releases, CHANGELOG files, etc. changelog_url = fetch_changelog_url(gem_name) return nil unless changelog_url { gem_name: gem_name, from_version: from_version, to_version: to_version, changelog_url: changelog_url, notes: "See changelog for details about changes from #{from_version} to #{to_version}" } end |