Class: Y2Packager::LicensesFetchers::Base

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
library/packages/src/lib/y2packager/licenses_fetchers/base.rb

Overview

Base class for licenses fetchers

Direct Known Subclasses

Archive, Libzypp

Constant Summary collapse

DEFAULT_LANG =
"en_US".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_name, _options = {}) ⇒ Base

Constructor

Parameters:

  • product_name (String)

    Product for which to get licenses



31
32
33
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 31

def initialize(product_name, _options = {})
  @product_name = product_name
end

Instance Attribute Details

#product_nameString (readonly)

Returns Product name to get licenses for.

Returns:

  • (String)

    Product name to get licenses for



26
27
28
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 26

def product_name
  @product_name
end

Instance Method Details

#confirmation_required?Boolean

Determine whether the license should be accepted or not

Returns:

  • (Boolean)

    true if license acceptance is required



66
67
68
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 66

def confirmation_required?
  true
end

#content(lang) ⇒ String?

Return the license content

Parameters:

  • lang (String)

    Language

Returns:

  • (String, nil)

    Product's license; nil if no license was found



47
48
49
50
51
52
53
54
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 47

def content(lang)
  # FIXME: not #default_content at some place?
  if default_lang?(lang) && @default_content
    return @default_content&.empty? ? nil : @default_content
  end

  license_content_for(lang)
end

#found?Booelan

Check if this is a valid fecher based on the existence of license content for default language

Returns:

  • (Booelan)

    true if there is license content for the default language; false otherwise



38
39
40
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 38

def found?
  !default_content.empty?
end

#localesArray<String>

Return available language codes for the license of the product

Returns:

  • (Array<String>)

    Language codes ("de_DE", "en_US", etc.)



59
60
61
# File 'library/packages/src/lib/y2packager/licenses_fetchers/base.rb', line 59

def locales
  []
end