Class: Mixlib::Install::Backend::Base
- Inherits:
-
Object
- Object
- Mixlib::Install::Backend::Base
- Defined in:
- lib/mixlib/install/backend/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#available_artifacts ⇒ Object
abstract
Returns the list of artifacts from the configured backend based on the configured product_name, product_version and channel.
-
#filter_artifacts(artifacts) ⇒ Object
Filters and returns the available artifacts based on the configured platform filtering options.
-
#info ⇒ Object
See #filter_artifacts.
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
-
#platform_filters_available? ⇒ Boolean
Returns true if platform filters are available, false otherwise.
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
25 26 27 |
# File 'lib/mixlib/install/backend/base.rb', line 25 def initialize() = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/mixlib/install/backend/base.rb', line 23 def end |
Instance Method Details
#available_artifacts ⇒ Object
Subclasses should define this method.
Returns the list of artifacts from the configured backend based on the configured product_name, product_version and channel.
37 38 39 |
# File 'lib/mixlib/install/backend/base.rb', line 37 def available_artifacts raise "Must implement available_artifacts method that returns Array<ArtifactInfo>" end |
#filter_artifacts(artifacts) ⇒ Object
Filters and returns the available artifacts based on the configured platform filtering options.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/mixlib/install/backend/base.rb', line 66 def filter_artifacts(artifacts) return artifacts unless platform_filters_available? # First filter the artifacts based on the platform and architecture artifacts.select! do |a| a.platform == .platform && a.architecture == .architecture end # Now we are going to filter based on platform_version. # We will return the artifact with an exact match if available. # Otherwise we will search for a compatible artifact and return it # if the compat options is set. closest_compatible_artifact = nil artifacts.each do |a| return a if a.platform_version == .platform_version # We skip the artifacts produced for windows since their platform # version is always set to 2008r2 which breaks our `to_f` comparison. next if a.platform == "windows" # Calculate the closest compatible version. # For an artifact to be compatible it needs to be smaller than the # platform_version specified in options. # To find the closest compatible one we keep a max of the compatible # artifacts. if closest_compatible_artifact.nil? || (a.platform_version.to_f > closest_compatible_artifact.platform_version.to_f && a.platform_version.to_f < .platform_version.to_f ) closest_compatible_artifact = a end end # If the compat flag is set and if we have found a compatible artifact # we are going to use it. if .platform_version_compatibility_mode && closest_compatible_artifact return closest_compatible_artifact end # Otherwise, we return an empty array indicating we do not have any matching artifacts return [] end |
#info ⇒ Object
See #filter_artifacts
43 44 45 |
# File 'lib/mixlib/install/backend/base.rb', line 43 def info filter_artifacts(available_artifacts) end |
#platform_filters_available? ⇒ Boolean
Returns true if platform filters are available, false otherwise.
Note that we assume #set_platform_info method is used on the Options class to set the platform options.
54 55 56 |
# File 'lib/mixlib/install/backend/base.rb', line 54 def platform_filters_available? !.platform.nil? end |