Class: RDI::Model::DependencyUserChoice
- Inherits:
-
Object
- Object
- RDI::Model::DependencyUserChoice
- Defined in:
- lib/rdi/Model/DependencyUserChoice.rb
Overview
Class used to store user decisions associated to a dependency
Instance Attribute Summary collapse
-
#AffectingContextModifiers ⇒ Object
readonly
The list of ContextModifiers that could help resolving the Testers list< String >.
-
#DepDesc ⇒ Object
readonly
The corresponding dependency’s description DependencyDescription.
-
#IdxDestination ⇒ Object
readonly
Destination index chosen for this dependency (can be nil if not to be installed) Integer.
-
#IdxInstaller ⇒ Object
readonly
Installer index chosen for this dependency (can be nil if not to be installed) Integer.
-
#Ignore ⇒ Object
readonly
Ignore flag Boolean.
-
#Locate ⇒ Object
readonly
Locate flag Boolean.
-
#OtherLocation ⇒ Object
readonly
The other location Object.
-
#ResolvedTesters ⇒ Object
readonly
The resolved testers (indexes), with their respective ContextModifier name and Location used to resolve them map< Integer, [ String, Object ] >.
Class Method Summary collapse
-
.getAffectingContextModifiers(ioInstaller, iDepDesc) ⇒ Object
Compute the list of AffectingContextModifiers.
Instance Method Summary collapse
-
#==(iOtherDUC) ⇒ Object
Do we equal another user choice ? Used by the regression.
-
#affectContextModifier(iCMName) ⇒ Object
Ask the user to change the context of a given context modifier to resolve this dependency.
-
#initialize(ioInstaller, iViewName, iDepDesc) ⇒ DependencyUserChoice
constructor
Constructor.
-
#selectOtherInstallLocation(iLocationSelectorName) ⇒ Object
Select a different install location for this dependency.
-
#setIgnore ⇒ Object
Set this choice to be “ignore it”.
-
#setInstaller(iIdxInstaller, iIdxDestination) ⇒ Object
Set this choice to be “install it”.
-
#setLocate ⇒ Object
Set this choice to be “locate it”.
Constructor Details
#initialize(ioInstaller, iViewName, iDepDesc) ⇒ DependencyUserChoice
Constructor
Parameters:
-
ioInstaller (Installer): RDI’s installer used to query plugins
-
iViewName (String): Name of the view to use
-
iDepDesc (DependencyDescription): The dependency description to handle
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 51 def initialize(ioInstaller, iViewName, iDepDesc) @Installer, @ViewName, @DepDesc = ioInstaller, iViewName, iDepDesc @Ignore = false @Locate = false @IdxInstaller = 0 @IdxDestination = 0 @ResolvedTesters = {} @OtherLocation = nil @AffectingContextModifiers = DependencyUserChoice::getAffectingContextModifiers(@Installer, @DepDesc) end |
Instance Attribute Details
#AffectingContextModifiers ⇒ Object (readonly)
The list of ContextModifiers that could help resolving the Testers
list< String >
43 44 45 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 43 def AffectingContextModifiers @AffectingContextModifiers end |
#DepDesc ⇒ Object (readonly)
The corresponding dependency’s description
DependencyDescription
15 16 17 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 15 def DepDesc @DepDesc end |
#IdxDestination ⇒ Object (readonly)
Destination index chosen for this dependency (can be nil if not to be installed)
Integer
31 32 33 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 31 def IdxDestination @IdxDestination end |
#IdxInstaller ⇒ Object (readonly)
Installer index chosen for this dependency (can be nil if not to be installed)
Integer
27 28 29 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 27 def IdxInstaller @IdxInstaller end |
#Ignore ⇒ Object (readonly)
Ignore flag
Boolean
19 20 21 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 19 def Ignore @Ignore end |
#Locate ⇒ Object (readonly)
Locate flag
Boolean
23 24 25 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 23 def Locate @Locate end |
#OtherLocation ⇒ Object (readonly)
The other location
Object
39 40 41 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 39 def OtherLocation @OtherLocation end |
#ResolvedTesters ⇒ Object (readonly)
The resolved testers (indexes), with their respective ContextModifier name and Location used to resolve them
map< Integer, [ String, Object ] >
35 36 37 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 35 def ResolvedTesters @ResolvedTesters end |
Class Method Details
.getAffectingContextModifiers(ioInstaller, iDepDesc) ⇒ Object
Compute the list of AffectingContextModifiers
Parameters:
-
ioInstaller (Installer): The installer
-
iDepDesc (DependencyDescription): The dependency description
Return:
-
list<String>: The list of ContextModifiers names
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 69 def self.getAffectingContextModifiers(ioInstaller, iDepDesc) rAffectingContextModifiers = [] # Gather the list of affecting ContextModifiers by parsing every Tester. iDepDesc.Testers.each do |iTesterInfo| iTesterName, iTesterContent = iTesterInfo ioInstaller.accessPlugin('Testers', iTesterName) do |iPlugin| rAffectingContextModifiers = (rAffectingContextModifiers + iPlugin.AffectingContextModifiers).uniq end end return rAffectingContextModifiers end |
Instance Method Details
#==(iOtherDUC) ⇒ Object
Do we equal another user choice ? Used by the regression
Parameters:
-
iOtherDUC (DependencyOtherChoice): The other one
Return:
-
Boolean: Do we equal another user choice ?
186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 186 def ==(iOtherDUC) return ( (@DepDesc == iOtherDUC.DepDesc) and (@Ignore == iOtherDUC.Ignore) and (@Locate == iOtherDUC.Locate) and (@IdxInstaller == iOtherDUC.IdxInstaller) and (@IdxDestination == iOtherDUC.IdxDestination) and (@ResolvedTesters == iOtherDUC.ResolvedTesters) and (@OtherLocation == iOtherDUC.OtherLocation) ) end |
#affectContextModifier(iCMName) ⇒ Object
Ask the user to change the context of a given context modifier to resolve this dependency
Parameters:
-
iCMName (String): Name of the ContextModifier we want to use
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 87 def affectContextModifier(iCMName) @Installer.accessPlugin('ContextModifiers', iCMName) do |ioPlugin| # Get the name of LocationSelector class to use lLocationSelectorName = ioPlugin.LocationSelectorName @Installer.accessPlugin("LocationSelectors_#{@ViewName}", lLocationSelectorName) do |iLSPlugin| # Get the location from the plugin lLocationToTry = iLSPlugin.getNewLocation if (lLocationToTry != nil) # Try adding this new location if not already there if (ioPlugin.isLocationInContext?(lLocationToTry)) logMsg "Location #{lLocationToTry} is already part of #{iCMName}" else # Add it ioPlugin.addLocationToContext(lLocationToTry) # Test Testers that were not already resolved lIdxTester = 0 @DepDesc.Testers.each do |iTesterInfo| if (!@ResolvedTesters.has_key?(lIdxTester)) # Test this one iTesterName, iTesterContent = iTesterInfo @Installer.accessPlugin('Testers', iTesterName) do |iTesterPlugin| # Consider it only if it declares iCMName as an AffectingContextModifier if (iTesterPlugin.AffectingContextModifiers.include?(iCMName)) if (iTesterPlugin.isContentResolved?(iTesterContent)) # Yes, it resolved this one @ResolvedTesters[lIdxTester] = [ iCMName, lLocationToTry ] logMsg "Location #{lLocationToTry} resolves correctly #{iTesterName} - #{iTesterContent}" else logErr "Location #{lLocationToTry} does not resolve #{iTesterName} - #{iTesterContent}" end end end end lIdxTester += 1 end # Remove it ioPlugin.removeLocationFromContext(lLocationToTry) end end end end end |
#selectOtherInstallLocation(iLocationSelectorName) ⇒ Object
Select a different install location for this dependency
Parameters:
-
iLocationSelectorName (String): The location selector name
Return:
-
Boolean: Is the selection valid ?
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 136 def selectOtherInstallLocation(iLocationSelectorName) rSuccess = false @Installer.accessPlugin("LocationSelectors_#{@ViewName}", iLocationSelectorName) do |iPlugin| # Get the location from the plugin lInstallLocation = iPlugin.getNewLocation if (lInstallLocation != nil) @OtherLocation = lInstallLocation rSuccess = true end end return rSuccess end |
#setIgnore ⇒ Object
Set this choice to be “ignore it”
160 161 162 163 164 165 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 160 def setIgnore @Ignore = true @Locate = false @IdxInstaller = nil @IdxDestination = nil end |
#setInstaller(iIdxInstaller, iIdxDestination) ⇒ Object
Set this choice to be “install it”
Parameters:
-
iIdxInstaller (Integer): The Installer’s index
-
iIdxDestination (Integer): The destination’s index
172 173 174 175 176 177 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 172 def setInstaller(iIdxInstaller, iIdxDestination) @Ignore = false @Locate = false @IdxInstaller = iIdxInstaller @IdxDestination = iIdxDestination end |
#setLocate ⇒ Object
Set this choice to be “locate it”
152 153 154 155 156 157 |
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 152 def setLocate @Ignore = false @Locate = true @IdxInstaller = nil @IdxDestination = nil end |