Module: Y2Packager::ProductLicenseMixin

Included in:
Product
Defined in:
library/packages/src/lib/y2packager/product_license_mixin.rb

Overview

This module is used for sharing the license related methods for several types of products.

Constant Summary collapse

DEFAULT_LICENSE_LANG =

[String] Default license language.

"en_US".freeze

Instance Method Summary collapse

Instance Method Details

#licenseProductLicense?

Return the license to confirm

Parameters:

  • lang (String)

    Language

Returns:

  • (ProductLicense, nil)

    Product's license; nil if the license was not found.



23
24
25
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 23

def license
  @license ||= ProductLicense.find(name)
end

#license?Boolean

Determines whether the product has a license

Parameters:

  • lang (String)

    Language

Returns:

  • (Boolean)

    true if the product has a license



41
42
43
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 41

def license?
  !!license
end

#license_confirmation=(confirmed) ⇒ Object

Set license confirmation for the product

Parameters:

  • confirmed (Boolean)

    determines whether the license should be accepted or not



57
58
59
60
61
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 57

def license_confirmation=(confirmed)
  return unless license

  confirmed ? license.accept! : license.reject!
end

#license_confirmation_required?Boolean

Determine whether the license should be accepted or not

Returns:

  • (Boolean)

    true if the license acceptance is required



48
49
50
51
52
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 48

def license_confirmation_required?
  return false unless license?

  license.confirmation_required?
end

#license_confirmed?Boolean

Determine whether the license is confirmed

Returns:

  • (Boolean)

    true if the license was confirmed (or acceptance was not needed)



66
67
68
69
70
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 66

def license_confirmed?
  return false unless license

  license.accepted? || !license_confirmation_required?
end

#license_content(lang) ⇒ String

Return the license text to be confirmed

Parameters:

  • lang (String)

    Language

Returns:

  • (String)

    Product's license; empty string ("") if no license was found.



31
32
33
34
35
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 31

def license_content(lang)
  return "" unless license?

  license.content_for(lang)
end

#license_localesArray<String>

Return available locales for product's license

Returns:

  • (Array<String>)

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



78
79
80
# File 'library/packages/src/lib/y2packager/product_license_mixin.rb', line 78

def license_locales
  license.locales
end