RDI 0.1.0.20091020

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/AUTHORS +3 -0
  2. data/ChangeLog +46 -0
  3. data/Credits +21 -0
  4. data/LICENSE +31 -0
  5. data/README +18 -0
  6. data/TODO +17 -0
  7. data/lib/rdi/Installer.rb +678 -0
  8. data/lib/rdi/Model/ContextModifier.rb +20 -0
  9. data/lib/rdi/Model/DependencyDescription.rb +154 -0
  10. data/lib/rdi/Model/DependencyUserChoice.rb +202 -0
  11. data/lib/rdi/Model/Installer.rb +24 -0
  12. data/lib/rdi/Model/LocationSelector.rb +16 -0
  13. data/lib/rdi/Model/ProgressView.rb +16 -0
  14. data/lib/rdi/Model/Tester.rb +20 -0
  15. data/lib/rdi/Model/View.rb +16 -0
  16. data/lib/rdi/Plugins/ContextModifiers/GemPath.desc.rb +13 -0
  17. data/lib/rdi/Plugins/ContextModifiers/GemPath.rb +106 -0
  18. data/lib/rdi/Plugins/ContextModifiers/LibraryPath.rb +74 -0
  19. data/lib/rdi/Plugins/ContextModifiers/RubyLoadPath.rb +76 -0
  20. data/lib/rdi/Plugins/ContextModifiers/SystemPath.rb +74 -0
  21. data/lib/rdi/Plugins/GemCommon.rb +127 -0
  22. data/lib/rdi/Plugins/Installers/Download.rb +72 -0
  23. data/lib/rdi/Plugins/Installers/DownloadAndInstall.desc.rb +11 -0
  24. data/lib/rdi/Plugins/Installers/DownloadAndInstall.rb +54 -0
  25. data/lib/rdi/Plugins/Installers/Gem.desc.rb +13 -0
  26. data/lib/rdi/Plugins/Installers/Gem.rb +67 -0
  27. data/lib/rdi/Plugins/Installers/Icons/Download.png +0 -0
  28. data/lib/rdi/Plugins/Installers/Icons/DownloadAndInstall.png +0 -0
  29. data/lib/rdi/Plugins/Installers/Icons/Gem.png +0 -0
  30. data/lib/rdi/Plugins/Installers/Yum.rb +52 -0
  31. data/lib/rdi/Plugins/ProgressViews/SimpleWxGUI.desc.rb +13 -0
  32. data/lib/rdi/Plugins/ProgressViews/SimpleWxGUI.rb +58 -0
  33. data/lib/rdi/Plugins/ProgressViews/Text.rb +68 -0
  34. data/lib/rdi/Plugins/RubyGemsDepDesc.rb +41 -0
  35. data/lib/rdi/Plugins/Testers/Binaries.rb +56 -0
  36. data/lib/rdi/Plugins/Testers/DynamicLibraries.rb +56 -0
  37. data/lib/rdi/Plugins/Testers/RubyRequires.rb +76 -0
  38. data/lib/rdi/Plugins/Views/SimpleWxGUI/DependenciesLoaderDialog.rb +147 -0
  39. data/lib/rdi/Plugins/Views/SimpleWxGUI/DependencyPanel.rb +301 -0
  40. data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/Dependency.png +0 -0
  41. data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/Ignore.png +0 -0
  42. data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/ValidKO.png +0 -0
  43. data/lib/rdi/Plugins/Views/SimpleWxGUI/Icons/ValidOK.png +0 -0
  44. data/lib/rdi/Plugins/Views/SimpleWxGUI/LocationSelectors/Directory.desc.rb +13 -0
  45. data/lib/rdi/Plugins/Views/SimpleWxGUI/LocationSelectors/Directory.rb +45 -0
  46. data/lib/rdi/Plugins/Views/SimpleWxGUI.desc.rb +13 -0
  47. data/lib/rdi/Plugins/Views/SimpleWxGUI.rb +60 -0
  48. data/lib/rdi/Plugins/Views/Text/LocationSelectors/Directory.rb +44 -0
  49. data/lib/rdi/Plugins/Views/Text.rb +257 -0
  50. data/lib/rdi/Plugins/WxCommon.rb +69 -0
  51. data/lib/rdi/Plugins/WxRubyDepDesc.rb +36 -0
  52. data/lib/rdi/rdi.rb +8 -0
  53. data/test/Common.rb +796 -0
  54. data/test/Flows/BasicFlows.rb +114 -0
  55. data/test/Flows/UIFlows.rb +460 -0
  56. data/test/Plugins/ContextModifiers/GemPath.rb +44 -0
  57. data/test/Plugins/ContextModifiers/LibraryPath.rb +36 -0
  58. data/test/Plugins/ContextModifiers/RubyLoadPath.rb +36 -0
  59. data/test/Plugins/ContextModifiers/SystemPath.rb +36 -0
  60. data/test/Plugins/Installers/Download.rb +65 -0
  61. data/test/Plugins/Installers/DownloadAndInstall.rb +73 -0
  62. data/test/Plugins/Installers/Gem.rb +79 -0
  63. data/test/Plugins/LocationSelectors/Directory.rb +34 -0
  64. data/test/Plugins/Testers/Binaries.rb +46 -0
  65. data/test/Plugins/Testers/DynamicLibraries.rb +46 -0
  66. data/test/Plugins/Testers/RubyRequires.rb +48 -0
  67. data/test/Plugins/Views/SimpleWxGUI.rb +190 -0
  68. data/test/Plugins/Views/Text.rb +112 -0
  69. data/test/Plugins/WxEnv.rb +58 -0
  70. data/test/Plugins/WxEnvApp.rb +53 -0
  71. data/test/Repository/Binaries/DummyBinary +1 -0
  72. data/test/Repository/Libraries/DummyLibrary.so +1 -0
  73. data/test/Repository/RubyGems/DummyGem-0.0.1.20090828.gem +0 -0
  74. data/test/Repository/RubyGems/GemsSources/DummyGem/DummyGem.gemspec.rb +23 -0
  75. data/test/Repository/RubyGems/GemsSources/DummyGem/lib/DummyGemMain.rb +5 -0
  76. data/test/Repository/RubyLibraries/DummyRubyLib.rb +1 -0
  77. data/test/run.rb +23 -0
  78. metadata +145 -0
@@ -0,0 +1,154 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ # Class storing information about a dependency
11
+ class DependencyDescription
12
+
13
+ # ID of the description
14
+ # String
15
+ attr_reader :ID
16
+
17
+ # List of the testers that must be resolved to ensure this dependency (list of couples [ TesterName, TesterContent ])
18
+ # list< [ String, Object ] >
19
+ attr_reader :Testers
20
+
21
+ # List of the possible installers
22
+ # list< [ String, Object, list< [ String, Object ] > ] >
23
+ # list< [ InstallerName, InstallerContent, list< [ ContextModifierName, ContextModifierContent ] > ] >
24
+ attr_reader :Installers
25
+
26
+ # Constructor
27
+ #
28
+ # Parameters:
29
+ # * *iID* (_String_): ID of this description. This can be used for example to further associate context modifiers to previously installed dependencies
30
+ def initialize(iID)
31
+ @ID = iID
32
+ @Testers = []
33
+ @Installers = []
34
+ end
35
+
36
+ # Add given testers and installers lists
37
+ #
38
+ # Parameters:
39
+ # * *iTesters* (<em>list<TesterInfo></em>): List of Testers
40
+ # * *iInstallers* (<em>list<InstallerInfo></em>): List of Installers
41
+ # Return:
42
+ # * _DependencyDescription_: self, useful to concatenate such method calls
43
+ def addTestersAndInstallers(iTesters, iInstallers)
44
+ iTesters.each do |iTesterInfo|
45
+ addTesterInfo(iTesterInfo)
46
+ end
47
+ iInstallers.each do |iInstallerInfo|
48
+ addInstallerInfo(iInstallerInfo)
49
+ end
50
+
51
+ return self
52
+ end
53
+
54
+ # Add a complete description.
55
+ # Here are the formats authorized:
56
+ # * { :Testers => list< TesterInfo >, :Installers => list< InstallerInfo > }
57
+ # * [ list< TesterInfo >, list< InstallerInfo > ]
58
+ #
59
+ # Parameters:
60
+ # * *iDescription* (_Object_): The description
61
+ # Return:
62
+ # * _DependencyDescription_: self, useful to concatenate such method calls
63
+ def addDescription(iDescription)
64
+ if (iDescription.is_a?(Array))
65
+ addTestersAndInstallers(iDescription[0], iDescription[1])
66
+ elsif (iDescription.is_a?(Hash))
67
+ addTestersAndInstallers(iDescription[:Testers], iDescription[:Installers])
68
+ else
69
+ logBug "Invalid Description: #{iDescription.inspect}."
70
+ end
71
+
72
+ return self
73
+ end
74
+
75
+ # Add a tester info
76
+ # Here are the following formats accepted for each Tester info:
77
+ # * [ String, Object ]
78
+ # * { :Type => String, :Content => Object }
79
+ #
80
+ # Parameters:
81
+ # * *iTesterInfo* (_Object_): The tester info
82
+ # Return:
83
+ # * _DependencyDescription_: self, useful to concatenate such method calls
84
+ def addTesterInfo(iTesterInfo)
85
+ if (iTesterInfo.is_a?(Array))
86
+ @Testers << iTesterInfo
87
+ elsif (iTesterInfo.is_a?(Hash))
88
+ @Testers << [ iTesterInfo[:Type], iTesterInfo[:Content] ]
89
+ else
90
+ logBug "Invalid TesterInfo: #{iTesterInfo.inspect}."
91
+ end
92
+
93
+ return self
94
+ end
95
+
96
+ # Add an installer info
97
+ # Here are the following formats accepted for each Installer info:
98
+ # * [ String, Object, list< ContextModifierInfo > ]
99
+ # * [ :Type => String, :Content => Object, :ContextModifiers => list< ContextModifierInfo > ]
100
+ #
101
+ # Parameters:
102
+ # * *iInstallerInfo* (_Object_): The installer info
103
+ # Return:
104
+ # * _DependencyDescription_: self, useful to concatenate such method calls
105
+ def addInstallerInfo(iInstallerInfo)
106
+ if (iInstallerInfo.is_a?(Array))
107
+ lNewInstallerInfo = [ iInstallerInfo[0], iInstallerInfo[1], [] ]
108
+ iInstallerInfo[2].each do |iContextModifierInfo|
109
+ lNewInstallerInfo[2] << getContextModifierInfo(iContextModifierInfo)
110
+ end
111
+ @Installers << lNewInstallerInfo
112
+ elsif (iInstallerInfo.is_a?(Hash))
113
+ lNewInstallerInfo = [ iInstallerInfo[:Type], iInstallerInfo[:Content], [] ]
114
+ iInstallerInfo[:ContextModifiers].each do |iContextModifierInfo|
115
+ lNewInstallerInfo[2] << getContextModifierInfo(iContextModifierInfo)
116
+ end
117
+ @Installers << lNewInstallerInfo
118
+ else
119
+ logBug "Invalid InstallerInfo: #{iInstallerInfo.inspect}."
120
+ end
121
+
122
+ return self
123
+ end
124
+
125
+ private
126
+
127
+ # Get the corresponding context modifier info
128
+ # Here are the following formats accepted for each ContextModifier info:
129
+ # * [ String, Object ]
130
+ # * { :Type => String, :Content => Object }
131
+ #
132
+ # Parameters:
133
+ # * *iContextModifierInfo* (_Object_): The context modifier info
134
+ # Return:
135
+ # * _Object_: The resulting context modifier info as stored internally
136
+ def getContextModifierInfo(iContextModifierInfo)
137
+ rContextModifierInfo = nil
138
+
139
+ if (iContextModifierInfo.is_a?(Array))
140
+ rContextModifierInfo = iContextModifierInfo
141
+ elsif (iContextModifierInfo.is_a?(Hash))
142
+ rContextModifierInfo = [ iContextModifierInfo[:Type], iContextModifierInfo[:Content] ]
143
+ else
144
+ logBug "Invalid ContextModifierInfo: #{iContextModifierInfo.inspect}."
145
+ end
146
+
147
+ return rContextModifierInfo
148
+ end
149
+
150
+ end
151
+
152
+ end
153
+
154
+ end
@@ -0,0 +1,202 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ # Class used to store user decisions associated to a dependency
11
+ class DependencyUserChoice
12
+
13
+ # The corresponding dependency's description
14
+ # DependencyDescription
15
+ attr_reader :DepDesc
16
+
17
+ # Ignore flag
18
+ # Boolean
19
+ attr_reader :Ignore
20
+
21
+ # Locate flag
22
+ # Boolean
23
+ attr_reader :Locate
24
+
25
+ # Installer index chosen for this dependency (can be nil if not to be installed)
26
+ # Integer
27
+ attr_reader :IdxInstaller
28
+
29
+ # Destination index chosen for this dependency (can be nil if not to be installed)
30
+ # Integer
31
+ attr_reader :IdxDestination
32
+
33
+ # The resolved testers (indexes), with their respective ContextModifier name and Location used to resolve them
34
+ # map< Integer, [ String, Object ] >
35
+ attr_reader :ResolvedTesters
36
+
37
+ # The other location
38
+ # Object
39
+ attr_reader :OtherLocation
40
+
41
+ # The list of ContextModifiers that could help resolving the Testers
42
+ # list< String >
43
+ attr_reader :AffectingContextModifiers
44
+
45
+ # Constructor
46
+ #
47
+ # Parameters:
48
+ # * *ioInstaller* (_Installer_): RDI's installer used to query plugins
49
+ # * *iViewName* (_String_): Name of the view to use
50
+ # * *iDepDesc* (_DependencyDescription_): The dependency description to handle
51
+ def initialize(ioInstaller, iViewName, iDepDesc)
52
+ @Installer, @ViewName, @DepDesc = ioInstaller, iViewName, iDepDesc
53
+ @Ignore = false
54
+ @Locate = false
55
+ @IdxInstaller = 0
56
+ @IdxDestination = 0
57
+ @ResolvedTesters = {}
58
+ @OtherLocation = nil
59
+ @AffectingContextModifiers = DependencyUserChoice::getAffectingContextModifiers(@Installer, @DepDesc)
60
+ end
61
+
62
+ # Compute the list of AffectingContextModifiers
63
+ #
64
+ # Parameters:
65
+ # * *ioInstaller* (_Installer_): The installer
66
+ # * *iDepDesc* (_DependencyDescription_): The dependency description
67
+ # Return:
68
+ # * <em>list<String></em>: The list of ContextModifiers names
69
+ def self.getAffectingContextModifiers(ioInstaller, iDepDesc)
70
+ rAffectingContextModifiers = []
71
+
72
+ # Gather the list of affecting ContextModifiers by parsing every Tester.
73
+ iDepDesc.Testers.each do |iTesterInfo|
74
+ iTesterName, iTesterContent = iTesterInfo
75
+ ioInstaller.accessPlugin('Testers', iTesterName) do |iPlugin|
76
+ rAffectingContextModifiers = (rAffectingContextModifiers + iPlugin.AffectingContextModifiers).uniq
77
+ end
78
+ end
79
+
80
+ return rAffectingContextModifiers
81
+ end
82
+
83
+ # Ask the user to change the context of a given context modifier to resolve this dependency
84
+ #
85
+ # Parameters:
86
+ # * *iCMName* (_String_): Name of the ContextModifier we want to use
87
+ def affectContextModifier(iCMName)
88
+ @Installer.accessPlugin('ContextModifiers', iCMName) do |ioPlugin|
89
+ # Get the name of LocationSelector class to use
90
+ lLocationSelectorName = ioPlugin.LocationSelectorName
91
+ @Installer.accessPlugin("LocationSelectors_#{@ViewName}", lLocationSelectorName) do |iLSPlugin|
92
+ # Get the location from the plugin
93
+ lLocationToTry = iLSPlugin.getNewLocation
94
+ if (lLocationToTry != nil)
95
+ # Try adding this new location if not already there
96
+ if (ioPlugin.isLocationInContext?(lLocationToTry))
97
+ logMsg "Location #{lLocationToTry} is already part of #{iCMName}"
98
+ else
99
+ # Add it
100
+ ioPlugin.addLocationToContext(lLocationToTry)
101
+ # Test Testers that were not already resolved
102
+ lIdxTester = 0
103
+ @DepDesc.Testers.each do |iTesterInfo|
104
+ if (!@ResolvedTesters.has_key?(lIdxTester))
105
+ # Test this one
106
+ iTesterName, iTesterContent = iTesterInfo
107
+ @Installer.accessPlugin('Testers', iTesterName) do |iTesterPlugin|
108
+ # Consider it only if it declares iCMName as an AffectingContextModifier
109
+ if (iTesterPlugin.AffectingContextModifiers.include?(iCMName))
110
+ if (iTesterPlugin.isContentResolved?(iTesterContent))
111
+ # Yes, it resolved this one
112
+ @ResolvedTesters[lIdxTester] = [ iCMName, lLocationToTry ]
113
+ logMsg "Location #{lLocationToTry} resolves correctly #{iTesterName} - #{iTesterContent}"
114
+ else
115
+ logErr "Location #{lLocationToTry} does not resolve #{iTesterName} - #{iTesterContent}"
116
+ end
117
+ end
118
+ end
119
+ end
120
+ lIdxTester += 1
121
+ end
122
+ # Remove it
123
+ ioPlugin.removeLocationFromContext(lLocationToTry)
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ # Select a different install location for this dependency
131
+ #
132
+ # Parameters:
133
+ # * *iLocationSelectorName* (_String_): The location selector name
134
+ # Return:
135
+ # * _Boolean_: Is the selection valid ?
136
+ def selectOtherInstallLocation(iLocationSelectorName)
137
+ rSuccess = false
138
+
139
+ @Installer.accessPlugin("LocationSelectors_#{@ViewName}", iLocationSelectorName) do |iPlugin|
140
+ # Get the location from the plugin
141
+ lInstallLocation = iPlugin.getNewLocation
142
+ if (lInstallLocation != nil)
143
+ @OtherLocation = lInstallLocation
144
+ rSuccess = true
145
+ end
146
+ end
147
+
148
+ return rSuccess
149
+ end
150
+
151
+ # Set this choice to be "locate it"
152
+ def setLocate
153
+ @Ignore = false
154
+ @Locate = true
155
+ @IdxInstaller = nil
156
+ @IdxDestination = nil
157
+ end
158
+
159
+ # Set this choice to be "ignore it"
160
+ def setIgnore
161
+ @Ignore = true
162
+ @Locate = false
163
+ @IdxInstaller = nil
164
+ @IdxDestination = nil
165
+ end
166
+
167
+ # Set this choice to be "install it"
168
+ #
169
+ # Parameters:
170
+ # * *iIdxInstaller* (_Integer_): The Installer's index
171
+ # * *iIdxDestination* (_Integer_): The destination's index
172
+ def setInstaller(iIdxInstaller, iIdxDestination)
173
+ @Ignore = false
174
+ @Locate = false
175
+ @IdxInstaller = iIdxInstaller
176
+ @IdxDestination = iIdxDestination
177
+ end
178
+
179
+ # Do we equal another user choice ?
180
+ # Used by the regression
181
+ #
182
+ # Parameters:
183
+ # * *iOtherDUC* (_DependencyOtherChoice_): The other one
184
+ # Return:
185
+ # * _Boolean_: Do we equal another user choice ?
186
+ def ==(iOtherDUC)
187
+ return (
188
+ (@DepDesc == iOtherDUC.DepDesc) and
189
+ (@Ignore == iOtherDUC.Ignore) and
190
+ (@Locate == iOtherDUC.Locate) and
191
+ (@IdxInstaller == iOtherDUC.IdxInstaller) and
192
+ (@IdxDestination == iOtherDUC.IdxDestination) and
193
+ (@ResolvedTesters == iOtherDUC.ResolvedTesters) and
194
+ (@OtherLocation == iOtherDUC.OtherLocation)
195
+ )
196
+ end
197
+
198
+ end
199
+
200
+ end
201
+
202
+ end
@@ -0,0 +1,24 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ class Installer
11
+
12
+ # The Installer
13
+ # Installer
14
+ attr_accessor :Installer
15
+
16
+ # The list of possible destinations, and the directories they point to
17
+ # map< Integer, String >
18
+ attr_accessor :PossibleDestinations
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,16 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ class LocationSelector
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ class ProgressView
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,20 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ class Tester
11
+
12
+ # The list of affecting context modifier names
13
+ # list< String >
14
+ attr_accessor :AffectingContextModifiers
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,16 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ module RDI
7
+
8
+ module Model
9
+
10
+ class View
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,13 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ require 'rdi/Plugins/RubyGemsDepDesc'
7
+
8
+ {
9
+ :Dependencies => [
10
+ # RubyGems
11
+ ::RDI::getRubyGemsDepDesc
12
+ ]
13
+ }
@@ -0,0 +1,106 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ require 'rdi/Model/ContextModifier'
7
+ require 'rdi/Plugins/GemCommon'
8
+
9
+ module RDI
10
+
11
+ module ContextModifiers
12
+
13
+ class GemPath < RDI::Model::ContextModifier
14
+
15
+ # To get the complete list of loadable paths through RubyGems:
16
+ # > Gem.all_loaded_paths
17
+ # C:/Program Files/ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.1/lib
18
+ # C:/Program Files/ruby/lib/ruby/gems/1.8/gems/win32-sapi-0.1.3-mswin32/lib
19
+ # C:/Program Files/ruby/lib/ruby/gems/1.8/gems/win32-sound-0.4.0/lib
20
+ # C:/Program Files/ruby/lib/ruby/gems/1.8/gems/windows-pr-0.5.3/lib
21
+ # E:/Documents and Settings/Muriel Salvan/toto/gems/crated-0.2.1/lib
22
+ #
23
+ # Find if a file is accessible
24
+ # > Gem.find_files('crate')
25
+ #
26
+ # To add a new Gems repository:
27
+ # > Gem.path << 'E:/Documents and Settings/Muriel Salvan/toto'
28
+ #
29
+ # To remove a Gems repository:
30
+ # > Gem.clear_paths
31
+ # Then re-add others than the one we want to remove
32
+
33
+ # Get the name of classes that provide selection facility for locations
34
+ #
35
+ # Return:
36
+ # * _String_: The name of the LocationSelector class
37
+ def getLocationSelectorName
38
+ return 'Directory'
39
+ end
40
+
41
+ # Transform a given content based on an installation environment.
42
+ # This is called to pass some specific installation parameters to a more generic content (useful for installation directories for example)
43
+ #
44
+ # Parameters:
45
+ # * *iLocation* (_Object_): Location to transform
46
+ # * *iInstallEnv* (<em>map<Symbol,Object></em>): The installation environment that called this context modification
47
+ # Return:
48
+ # * _Object_: The location transformed with the installation environment
49
+ def transformContentWithInstallEnv(iLocation, iInstallEnv)
50
+ rNewLocation = iLocation
51
+
52
+ lInstallDir = iInstallEnv[:InstallDir]
53
+ if (lInstallDir != nil)
54
+ rNewLocation = iLocation.gsub(/%INSTALLDIR%/, lInstallDir)
55
+ end
56
+
57
+ return rNewLocation
58
+ end
59
+
60
+ # Is a given location present in the context ?
61
+ #
62
+ # Parameters:
63
+ # * *iLocation* (_Object_): Location to add
64
+ # Return:
65
+ # * _Boolean_: Is the location already present ?
66
+ def isLocationInContext?(iLocation)
67
+ # * *iLocation* (_String_): Directory
68
+ return Gem.path.include?(iLocation)
69
+ end
70
+
71
+ # Add a given location to the context
72
+ #
73
+ # Parameters:
74
+ # * *iLocation* (_Object_): Location to add
75
+ def addLocationToContext(iLocation)
76
+ # * *iLocation* (_String_): Directory
77
+ Gem.path << iLocation
78
+ # TODO (RubyGems): Make the extra source_index modification useless. Adding to path should reflect changes internally.
79
+ Gem.source_index.spec_dirs << "#{iLocation}/specifications"
80
+ Gem.refresh
81
+ end
82
+
83
+ # Remove a given location from the context
84
+ #
85
+ # Parameters:
86
+ # * *iLocation* (_Object_): Location to remove
87
+ def removeLocationFromContext(iLocation)
88
+ # * *iLocation* (_String_): Directory
89
+ lLastPaths = Gem.path.clone
90
+ Gem.clear_paths
91
+ lLastPaths.each do |iLastDir|
92
+ if ((iLastDir != iLocation) and
93
+ (!Gem.path.include?(iLastDir)))
94
+ Gem.path << iLastDir
95
+ # TODO (RubyGems): Make the extra source_index modification useless. Adding to path should reflect changes internally.
96
+ Gem.source_index.spec_dirs << "#{iLastDir}/specifications"
97
+ end
98
+ end
99
+ Gem.refresh
100
+ end
101
+
102
+ end
103
+
104
+ end
105
+
106
+ end
@@ -0,0 +1,74 @@
1
+ #--
2
+ # Copyright (c) 2009 Muriel Salvan (murielsalvan@users.sourceforge.net)
3
+ # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ #++
5
+
6
+ require 'rdi/Model/ContextModifier'
7
+
8
+ module RDI
9
+
10
+ module ContextModifiers
11
+
12
+ class LibraryPath < RDI::Model::ContextModifier
13
+
14
+ # Get the name of classes that provide selection facility for locations
15
+ #
16
+ # Return:
17
+ # * _String_: The name of the LocationSelector class
18
+ def getLocationSelectorName
19
+ return 'Directory'
20
+ end
21
+
22
+ # Transform a given content based on an installation environment.
23
+ # This is called to pass some specific installation parameters to a more generic content (useful for installation directories for example)
24
+ #
25
+ # Parameters:
26
+ # * *iLocation* (_Object_): Location to transform
27
+ # * *iInstallEnv* (<em>map<Symbol,Object></em>): The installation environment that called this context modification
28
+ # Return:
29
+ # * _Object_: The location transformed with the installation environment
30
+ def transformContentWithInstallEnv(iLocation, iInstallEnv)
31
+ rNewLocation = iLocation
32
+
33
+ lInstallDir = iInstallEnv[:InstallDir]
34
+ if (lInstallDir != nil)
35
+ rNewLocation = iLocation.gsub(/%INSTALLDIR%/, lInstallDir)
36
+ end
37
+
38
+ return rNewLocation
39
+ end
40
+
41
+ # Is a given location present in the context ?
42
+ #
43
+ # Parameters:
44
+ # * *iLocation* (_Object_): Location to add
45
+ # Return:
46
+ # * _Boolean_: Is the location already present ?
47
+ def isLocationInContext?(iLocation)
48
+ # * *iLocation* (_String_): Directory
49
+ return $rUtilAnts_Platform_Info.getSystemLibsPath.include?(iLocation)
50
+ end
51
+
52
+ # Add a given location to the context
53
+ #
54
+ # Parameters:
55
+ # * *iLocation* (_Object_): Location to add
56
+ def addLocationToContext(iLocation)
57
+ # * *iLocation* (_String_): Directory
58
+ $rUtilAnts_Platform_Info.setSystemLibsPath($rUtilAnts_Platform_Info.getSystemLibsPath + [ iLocation ])
59
+ end
60
+
61
+ # Remove a given location from the context
62
+ #
63
+ # Parameters:
64
+ # * *iLocation* (_Object_): Location to remove
65
+ def removeLocationFromContext(iLocation)
66
+ # * *iLocation* (_String_): Directory
67
+ $rUtilAnts_Platform_Info.setSystemLibsPath($rUtilAnts_Platform_Info.getSystemLibsPath - [ iLocation ])
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
74
+ end