Class: Y2Packager::LicensesFetchers::Archive
- Defined in:
- library/packages/src/lib/y2packager/licenses_fetchers/archive.rb
Overview
Base class for licenses fetchers based on some kind of license archive.
It takes care of looking up the licenses in the unpacked archive and manages a temporary cache directory.
The actual unpacking and provisioning of the archive file itself must be done in a derived class.
Constant Summary collapse
- NO_ACCEPTANCE_FILE =
Acceptance is not needed if the file exists
"no-acceptance-needed".freeze
- FALLBACK_LICENSE_FILE =
Fallback license file
"LICENSE.TXT".freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.finalize(dir) ⇒ Object
Explicit destructor to clean up temporary dir.
Instance Method Summary collapse
-
#confirmation_required? ⇒ Boolean
Determine whether the license should be accepted or not.
-
#locales ⇒ Array<String>
Return available locales for product's license.
Methods inherited from Base
#content, #found?, #initialize
Constructor Details
This class inherits a constructor from Y2Packager::LicensesFetchers::Base
Class Method Details
.finalize(dir) ⇒ Object
Explicit destructor to clean up temporary dir
66 67 68 |
# File 'library/packages/src/lib/y2packager/licenses_fetchers/archive.rb', line 66 def self.finalize(dir) proc { FileUtils.remove_entry_secure(dir) } end |
Instance Method Details
#confirmation_required? ⇒ Boolean
Determine whether the license should be accepted or not
57 58 59 60 61 |
# File 'library/packages/src/lib/y2packager/licenses_fetchers/archive.rb', line 57 def confirmation_required? unpack_archive find_path_for(archive_dir, NO_ACCEPTANCE_FILE).nil? end |
#locales ⇒ Array<String>
Return available locales for product's license
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'library/packages/src/lib/y2packager/licenses_fetchers/archive.rb', line 38 def locales return [] if !archive_exists? @locales ||= begin unpack_archive license_files = find_case_insensitive(archive_dir, "LICENSE.*.TXT") # NOTE: despite the use of the case-insensitive flag, the captured group will be # returned as it is. languages = license_files.map { |path| path[/LICENSE.(\w*).TXT/i, 1] } languages << DEFAULT_LANG languages.compact.uniq end end |