Class: Windoo::PatchManager
- Inherits:
-
BaseClasses::ArrayManager
- Object
- BaseClasses::ArrayManager
- Windoo::PatchManager
- Defined in:
- lib/windoo/objects/patch_manager.rb
Overview
An ArrayManager for dealing with the Patches of a SoftwareTitle
An instance of this is returned by SoftwareTitle#patches
Constant Summary collapse
Constants inherited from BaseClasses::ArrayManager
BaseClasses::ArrayManager::PP_OMITTED_INST_VARS
Instance Attribute Summary
Attributes inherited from BaseClasses::ArrayManager
Instance Method Summary collapse
-
#add_patch(version:, minimumOperatingSystem:, releaseDate: nil, reboot: nil, standalone: nil, absoluteOrderId: 0) ⇒ Integer
Add a Patch to this SoftwareTitle.
-
#all_enabled ⇒ Array<Windoo::Patch] An array of the currently enabled patches
Array<Windoo::Patch] An array of the currently enabled patches.
-
#all_versions ⇒ Hash {Integer => String}
The Versions for this title.
-
#delete_all_patches ⇒ void
Delete all the patches.
-
#delete_patch(patchId) ⇒ Integer
Delete a Patch from this SoftwareTitle.
-
#move_patch(patchId, absoluteOrderId:) ⇒ Integer
Change the position of an existing patch in the array This just calls update_patch, with absoluteOrderId as the only attribute.
-
#patch(ident) ⇒ Windoo::Patch
get a patch by id or version.
-
#patchIds_to_versions ⇒ Hash {Integer => String}
The Patch IDs => Version installed by the patch.
-
#update_patch(patchId, **attribs) ⇒ Integer
Update a Patch in this SoftwareTitle.
-
#versions_to_patchIds ⇒ Hash {Integer => String}
The Versions => Patch ID installed by the patch.
Methods inherited from BaseClasses::ArrayManager
#[], #each, #empty?, #find, #find_by_attr, #first, #index, #initialize, #last, #pretty_print_instance_variables, #size, #to_a
Constructor Details
This class inherits a constructor from Windoo::BaseClasses::ArrayManager
Instance Method Details
#add_patch(version:, minimumOperatingSystem:, releaseDate: nil, reboot: nil, standalone: nil, absoluteOrderId: 0) ⇒ Integer
Add a Patch to this SoftwareTitle. NOTE: patches cannot be enabled when added, you must call ‘enable’ on them after creating any necessary sub-objects.
Patches must be ordered from newest to oldest, and are indexed zero-based, like Ruby Arrays.
By default, patches are added at the front, index 0,meaning the are the newest.
To make the new patch appear later in the order, provide a zero-based integer as ‘absoluteOrderId’ (0, the first in the order, is the default). So to add this new patch as older than the first and second, use
absoluteOrderId: 2
All others will be adjusted automatically.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/windoo/objects/patch_manager.rb', line 107 def add_patch(version:, minimumOperatingSystem:, releaseDate: nil, reboot: nil, standalone: nil, absoluteOrderId: 0) new_patch = Windoo::Patch.create( cnx: container.cnx, container: container, version: version, minimumOperatingSystem: , releaseDate: releaseDate, reboot: reboot, standalone: standalone, absoluteOrderId: absoluteOrderId ) # call the method from our superclass to add it to the array add_member new_patch, index: absoluteOrderId update_local_absoluteOrderIds new_patch.patchId end |
#all_enabled ⇒ Array<Windoo::Patch] An array of the currently enabled patches
Returns Array<Windoo::Patch] An array of the currently enabled patches.
28 29 30 |
# File 'lib/windoo/objects/patch_manager.rb', line 28 def all_enabled @managed_array.select(&:enabled?) end |
#all_versions ⇒ Hash {Integer => String}
Returns The Versions for this title.
49 50 51 |
# File 'lib/windoo/objects/patch_manager.rb', line 49 def all_versions @managed_array.map(&:version) end |
#delete_all_patches ⇒ void
This method returns an undefined value.
Delete all the patches
215 216 217 218 219 220 |
# File 'lib/windoo/objects/patch_manager.rb', line 215 def delete_all_patches delete_all_members # titles without a patch are not valid # so must be disabled @container.disable end |
#delete_patch(patchId) ⇒ Integer
Delete a Patch from this SoftwareTitle
When deleting a Patch via this method, it is deleted from the server immediately, there is no need to #save the SoftwareTitle
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/windoo/objects/patch_manager.rb', line 199 def delete_patch(patchId) patch = delete_member(patchId) # titles without a patch are not valid # so must be disabled patch.softwareTitle.disable if empty? update_local_absoluteOrderIds patchId end |
#move_patch(patchId, absoluteOrderId:) ⇒ Integer
Change the position of an existing patch in the array This just calls update_patch, with absoluteOrderId as the only attribute.
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/windoo/objects/patch_manager.rb', line 176 def move_patch(patchId, absoluteOrderId:) # Can't move it beyond the end of the array.... max_idx = @managed_array.size - 1 absoluteOrderId = max_idx if absoluteOrderId > max_idx # ... or before the beginning absoluteOrderId = 0 if absoluteOrderId.negative? update_patch patchId, absoluteOrderId: absoluteOrderId absoluteOrderId end |
#patch(ident) ⇒ Windoo::Patch
get a patch by id or version
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/windoo/objects/patch_manager.rb', line 59 def patch(ident) case ident when Integer find_by_attr(:patchId, ident) when String find_by_attr(:version, ident) else raise ArgumentError, 'ident must be an Integer patchId, or a String Version' end end |
#patchIds_to_versions ⇒ Hash {Integer => String}
Returns The Patch IDs => Version installed by the patch.
35 36 37 |
# File 'lib/windoo/objects/patch_manager.rb', line 35 def patchIds_to_versions @managed_array.map { |p| [p.patchId, p.version] }.to_h end |
#update_patch(patchId, **attribs) ⇒ Integer
Update a Patch in this SoftwareTitle. Do not use this to update absoluteOrderId, instead use #move_patch
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/windoo/objects/patch_manager.rb', line 148 def update_patch(patchId, **attribs) # TODO: use this to undo if we changed # the absoluteOrderId but something about the # API transaction failed @managed_array.index { |p| p.patchId == patchId } patch = update_member(patchId, **attribs) if attribs[:absoluteOrderId] move_member patch, index: patch.absoluteOrderId update_local_absoluteOrderIds end patch.patchId end |
#versions_to_patchIds ⇒ Hash {Integer => String}
Returns The Versions => Patch ID installed by the patch.
42 43 44 |
# File 'lib/windoo/objects/patch_manager.rb', line 42 def versions_to_patchIds @managed_array.map { |p| [p.version, p.patchId] }.to_h end |