Class: Y2Packager::ReleaseNotesFetchers::Url
- Defined in:
- library/packages/src/lib/y2packager/release_notes_fetchers/url.rb
Overview
This class reads release notes from the relnotes_url product property
The code was extracted from the old version of the InstDownloadReleaseNotesClient and adapted. See https://github.com/yast/yast-installation/blob/62596684d6de242667a0957765c85712874e77ef/src/lib/installation/clients/inst_download_release_notes.rb
Constant Summary collapse
- CURL_GIVE_UP_RETURN_CODES =
When cURL returns one of those codes, the download won't be retried
{ 5 => "Couldn't resolve proxy.", 6 => "Couldn't resolve host.", 7 => "Failed to connect to host.", 28 => "Operation timeout." }.freeze
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.add_to_blacklist(url) ⇒ Object
Add an URL to the blacklist.
-
.blacklist ⇒ Array<String>
Blacklist of URLs that failed to download and should not be retried.
-
.blacklisted?(url) ⇒ Boolean
Determine whether an URL is blacklisted or not.
-
.clear_blacklist ⇒ Object
Clear products blackist.
-
.disable! ⇒ Object
Disable downloading release notes due to communication errors.
-
.enable! ⇒ Object
Enable downloading release notes.
-
.enabled? ⇒ Boolean
Determine if release notes would be downloaded.
Instance Method Summary collapse
-
#latest_version ⇒ :latest
Return release notes latest version identifier.
-
#release_notes(prefs) ⇒ String?
Get release notes for the given product.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Y2Packager::ReleaseNotesFetchers::Base
Class Method Details
.add_to_blacklist(url) ⇒ Object
Add an URL to the blacklist
63 64 65 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 63 def add_to_blacklist(url) blacklist << url end |
.blacklist ⇒ Array<String>
Blacklist of URLs that failed to download and should not be retried
56 57 58 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 56 def blacklist @blacklist ||= [] end |
.blacklisted?(url) ⇒ Boolean
Determine whether an URL is blacklisted or not
70 71 72 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 70 def blacklisted?(url) blacklist.include?(url) end |
.clear_blacklist ⇒ Object
Clear products blackist
75 76 77 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 75 def clear_blacklist blacklist.clear end |
.disable! ⇒ Object
Disable downloading release notes due to communication errors
39 40 41 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 39 def disable! @enabled = false end |
.enable! ⇒ Object
Enable downloading release notes
This method is intended to be used during testing.
34 35 36 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 34 def enable! @enabled = true end |
.enabled? ⇒ Boolean
Determine if release notes would be downloaded
47 48 49 50 51 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 47 def enabled? return true if @enabled.nil? @enabled end |
Instance Method Details
#latest_version ⇒ :latest
Return release notes latest version identifier
Release notes that lives in relnotes_url are considered always to be the latest version, hence this method always returns :latest.
134 135 136 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 134 def latest_version :latest end |
#release_notes(prefs) ⇒ String?
Get release notes for the given product
Release notes are downloaded and extracted to work directory. When release notes for a language "xx_XX" are not found, it will fallback to "xx".
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 98 def release_notes(prefs) if !self.class.enabled? log.info("Skipping release notes download due to previous download issues") return nil end if self.class.blacklisted?(relnotes_url) log.info("Skipping release notes download for #{product.name} due to previous issues") return nil end if !relnotes_url_valid? log.warn("Skipping release notes download for #{product.name}: '#{relnotes_url}'") return nil end relnotes = fetch_release_notes(prefs) if relnotes log.info "Got release notes for #{product.name} from URL #{relnotes_url} " \ "with #{prefs}" return relnotes end log.warn("Release notes for product #{product.name} not found. " \ "Blacklisting #{relnotes_url}...") self.class.add_to_blacklist(relnotes_url) nil end |