development 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +59 -82
- data/lib/development/configuration_interface.rb +123 -0
- data/lib/development/directory/directory_interface.rb +165 -0
- data/lib/development/directory.rb +9 -0
- data/lib/development/gem/gem_interface.rb +191 -0
- data/lib/development/gem.rb +9 -0
- data/lib/development/gemset/gemset_interface.rb +314 -0
- data/lib/development/gemset.rb +9 -0
- data/lib/development.rb +428 -783
- data/lib/namespaces.rb +9 -0
- data/lib/requires.rb +23 -0
- data/lib/setup.rb +15 -0
- data/spec/development/directory_spec.rb +75 -0
- data/spec/development/gem_spec.rb +63 -0
- data/spec/development/gemset_spec.rb +105 -0
- data/spec/development_spec.rb +142 -277
- data/spec/{require_mock → mock/require_mock}/lib/require_mock.rb +0 -0
- data/spec/mock/require_mock-submock/lib/require_mock/submock.rb +3 -0
- data/spec/{require_mock2 → mock/require_mock2}/lib/require_mock2.rb +0 -0
- data/spec/mock/require_mock3/lib/require_mock3.rb +4 -0
- data/spec/mock/require_mock4/lib/require_mock4.rb +4 -0
- metadata +20 -19
- data/lib/development/exception/expression_error/unknown_directory_name.rb +0 -14
- data/lib/development/exception/expression_error/unknown_gem_or_gemset_name.rb +0 -14
- data/lib/development/exception/expression_error.rb +0 -18
- data/lib/development/exception/malformed_expression/malformed_enable_disable_expression.rb +0 -15
- data/lib/development/exception/malformed_expression/malformed_gemset_expression.rb +0 -15
- data/lib/development/exception/malformed_expression/malformed_general_directory_expression.rb +0 -15
- data/lib/development/exception/malformed_expression/malformed_location_expression.rb +0 -15
- data/lib/development/exception/malformed_expression/malformed_named_directory_expression.rb +0 -15
- data/lib/development/exception/malformed_expression/malformed_remove_general_directory_expression.rb +0 -15
- data/lib/development/exception/malformed_expression.rb +0 -16
- data/spec/mock_gem/lib/mock_gem.rb +0 -4
- data/spec/mock_gem-subgem/lib/mock_gem/subgem.rb +0 -4
- data/spec/mock_gem-subgem2/lib/mock_gem/subgem2.rb +0 -4
- data/spec/mock_gem2/lib/mock_gem2.rb +0 -4
- data/spec/other_require_mock/lib/other_require_mock.rb +0 -4
data/lib/development.rb
CHANGED
@@ -1,949 +1,619 @@
|
|
1
1
|
|
2
|
+
# namespaces that have to be declared ahead of time for proper load order
|
3
|
+
require_relative './namespaces'
|
4
|
+
|
5
|
+
# source file requires
|
6
|
+
require_relative './requires.rb'
|
7
|
+
|
2
8
|
###
|
3
9
|
# Singleton that manages configurations and requires.
|
4
10
|
#
|
5
11
|
module ::Development
|
6
|
-
|
7
|
-
#############
|
8
|
-
# loaded? #
|
9
|
-
#############
|
10
12
|
|
11
13
|
###
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @param gem_name
|
15
|
-
#
|
16
|
-
# Name of gem.
|
17
|
-
#
|
18
|
-
# @return [true,false] Whether gem was loaded via Development.
|
14
|
+
# Name of configuration file: .development.rb.
|
19
15
|
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
####################
|
27
|
-
# self.directory #
|
28
|
-
####################
|
16
|
+
ConfigurationFileName = '.development.rb'
|
17
|
+
|
18
|
+
#####################
|
19
|
+
# self.initialize #
|
20
|
+
#####################
|
29
21
|
|
30
22
|
###
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# @param directory_name
|
23
|
+
# Initialize internal tracking variables.
|
34
24
|
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# @return [String] Directory path associated with directory name.
|
25
|
+
# @return [Development] Self.
|
38
26
|
#
|
39
|
-
def self.
|
27
|
+
def self.initialize
|
40
28
|
|
41
|
-
|
29
|
+
@enable_for_all = false
|
42
30
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#############################
|
48
|
-
|
49
|
-
###
|
50
|
-
# Get Array of paths that will be used for general loading purposes if a specific gem path is not given.
|
51
|
-
#
|
52
|
-
# @return [Array<String>] Paths to be used for general loading purposes.
|
53
|
-
#
|
54
|
-
def self.general_load_paths
|
31
|
+
@directories = { }
|
32
|
+
|
33
|
+
@gems = { }
|
34
|
+
@gemsets = { }
|
55
35
|
|
56
|
-
|
36
|
+
@general_load_paths = [ ]
|
37
|
+
|
38
|
+
@loaded_gems = { }
|
57
39
|
|
40
|
+
return self
|
41
|
+
|
58
42
|
end
|
59
43
|
|
60
|
-
|
61
|
-
# self.
|
62
|
-
|
44
|
+
################
|
45
|
+
# self.clear #
|
46
|
+
################
|
63
47
|
|
64
48
|
###
|
65
|
-
#
|
49
|
+
# Reset internal tracking variables.
|
66
50
|
#
|
67
|
-
# @return [
|
51
|
+
# @return [Development] Self.
|
68
52
|
#
|
69
|
-
def self.
|
53
|
+
def self.clear
|
54
|
+
|
55
|
+
@enable_for_all = false
|
70
56
|
|
71
|
-
|
57
|
+
@directories.clear
|
72
58
|
|
73
|
-
|
59
|
+
@gems.clear
|
60
|
+
@gemsets.clear
|
74
61
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
###
|
80
|
-
# Query whether Development is set to search in general paths for any gem, even if not explicitly enabled.
|
81
|
-
#
|
82
|
-
# @return [true,false] Whether general gem search is enabled.
|
83
|
-
#
|
84
|
-
def self.enabled_for_all?
|
62
|
+
@general_load_paths.clear
|
63
|
+
|
64
|
+
@loaded_gems.clear
|
85
65
|
|
86
|
-
return
|
66
|
+
return self
|
87
67
|
|
88
68
|
end
|
89
69
|
|
90
|
-
|
91
|
-
# self.
|
92
|
-
|
70
|
+
##############
|
71
|
+
# self.gem #
|
72
|
+
##############
|
93
73
|
|
94
74
|
###
|
95
|
-
#
|
75
|
+
# Define a gem or retrieve defined gem.
|
96
76
|
#
|
97
|
-
# @
|
77
|
+
# @param name
|
98
78
|
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
########################
|
106
|
-
# self.disabled_gems #
|
107
|
-
########################
|
108
|
-
|
109
|
-
###
|
110
|
-
# Get gems that have been explicitly disabled.
|
79
|
+
# Name of gem.
|
80
|
+
#
|
81
|
+
# @param directory_or_path
|
111
82
|
#
|
112
|
-
#
|
83
|
+
# Development::Directory or String describing path.
|
113
84
|
#
|
114
|
-
|
85
|
+
# @return [::Development::Gem]
|
86
|
+
#
|
87
|
+
def self.gem( name, directory_or_path = nil )
|
115
88
|
|
116
|
-
|
89
|
+
gem_require_name = name.to_s.gsub( '/', '-' )
|
117
90
|
|
118
|
-
|
91
|
+
name = gem_require_name.to_sym
|
92
|
+
|
93
|
+
if gem_instance = @gems[ name ]
|
94
|
+
if directory_or_path
|
95
|
+
gem_instance.set_directory( directory_or_path )
|
96
|
+
end
|
97
|
+
else
|
98
|
+
@gems[ name ] = gem_instance = Gem.new( name, directory_or_path )
|
99
|
+
end
|
100
|
+
|
101
|
+
return gem_instance
|
119
102
|
|
103
|
+
end
|
104
|
+
|
120
105
|
##################
|
121
|
-
# self.
|
106
|
+
# self.get_gem #
|
122
107
|
##################
|
123
108
|
|
124
109
|
###
|
125
|
-
#
|
110
|
+
# Retrieve defined gem.
|
126
111
|
#
|
127
|
-
# @
|
112
|
+
# @param name
|
128
113
|
#
|
129
|
-
|
114
|
+
# Name of gem.
|
115
|
+
#
|
116
|
+
# @return [::Development::Gem]
|
117
|
+
#
|
118
|
+
def self.get_gem( name )
|
130
119
|
|
131
|
-
return @
|
120
|
+
return @gems[ name.to_sym ]
|
132
121
|
|
133
122
|
end
|
134
|
-
|
135
|
-
|
136
|
-
# self.
|
137
|
-
|
123
|
+
|
124
|
+
###############
|
125
|
+
# self.gems #
|
126
|
+
###############
|
138
127
|
|
139
128
|
###
|
140
|
-
#
|
129
|
+
# Get hash of gems.
|
141
130
|
#
|
142
|
-
# @return [Hash{Symbol=>Array
|
131
|
+
# @return [Hash{Symbol=>Array<::Development::Gem>}] Hash of gemsets and their gem or gemset members.
|
143
132
|
#
|
144
|
-
def self.
|
133
|
+
def self.gems
|
145
134
|
|
146
|
-
return @
|
135
|
+
return @gems
|
147
136
|
|
148
137
|
end
|
149
138
|
|
150
|
-
|
151
|
-
# self.
|
152
|
-
|
139
|
+
#################
|
140
|
+
# self.gemset #
|
141
|
+
#################
|
153
142
|
|
154
143
|
###
|
155
|
-
#
|
144
|
+
# Define a gem or retrieve defined gem.
|
145
|
+
#
|
146
|
+
# @overload self.gemset( name, gem_or_gemset, ... )
|
156
147
|
#
|
157
|
-
#
|
148
|
+
# @param name
|
149
|
+
#
|
150
|
+
# Name of gemset.
|
158
151
|
#
|
159
|
-
#
|
152
|
+
# @param gem_or_gemset
|
160
153
|
#
|
161
|
-
#
|
154
|
+
# Gem or Gemset name or instance.
|
162
155
|
#
|
163
|
-
|
156
|
+
# @return [::Development::Gemset]
|
157
|
+
#
|
158
|
+
def self.gemset( name, *gems_or_gemsets )
|
159
|
+
|
160
|
+
name = name.to_sym
|
161
|
+
|
162
|
+
unless gemset_instance = @gemsets[ name ]
|
163
|
+
@gemsets[ name ] = gemset_instance = Gemset.new( name )
|
164
|
+
end
|
164
165
|
|
165
|
-
|
166
|
+
gemset_instance.add( *gems_or_gemsets )
|
167
|
+
|
168
|
+
return gemset_instance
|
166
169
|
|
167
170
|
end
|
168
171
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
+
#####################
|
173
|
+
# self.get_gemset #
|
174
|
+
#####################
|
172
175
|
|
173
176
|
###
|
174
|
-
#
|
177
|
+
# Retrieve defined gemset.
|
175
178
|
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
module Exception
|
179
|
-
end
|
180
|
-
|
181
|
-
###
|
182
|
-
# Name of configuration file: .development.
|
179
|
+
# @param name
|
183
180
|
#
|
184
|
-
|
185
|
-
|
186
|
-
@enabled_gems = { }
|
187
|
-
@disabled_gems = { }
|
188
|
-
|
189
|
-
@gemsets = { }
|
190
|
-
@gem_locations = { }
|
191
|
-
|
192
|
-
@general_load_paths = [ ]
|
193
|
-
|
194
|
-
@loaded_gems = { }
|
195
|
-
|
196
|
-
@named_directories = { }
|
197
|
-
@locations = { }
|
198
|
-
|
199
|
-
@enable_for_all = false
|
200
|
-
|
201
|
-
################
|
202
|
-
# self.clear #
|
203
|
-
################
|
204
|
-
|
205
|
-
###
|
206
|
-
# Reset internal tracking variables.
|
181
|
+
# Name of gemset.
|
207
182
|
#
|
208
|
-
# @return [Development]
|
183
|
+
# @return [::Development::Gemset]
|
209
184
|
#
|
210
|
-
def self.
|
185
|
+
def self.get_gemset( name )
|
211
186
|
|
212
|
-
@
|
213
|
-
@disabled_gems.clear
|
214
|
-
@gemsets.clear
|
215
|
-
@gem_locations.clear
|
216
|
-
@general_load_paths.clear
|
217
|
-
@loaded_gems.clear
|
218
|
-
@named_directories.clear
|
219
|
-
@locations.clear
|
220
|
-
@enable_for_all = false
|
221
|
-
|
222
|
-
return self
|
187
|
+
return @gemsets[ name.to_sym ]
|
223
188
|
|
224
189
|
end
|
225
190
|
|
226
|
-
|
227
|
-
# self.
|
228
|
-
|
191
|
+
##################
|
192
|
+
# self.gemsets #
|
193
|
+
##################
|
229
194
|
|
230
195
|
###
|
231
|
-
#
|
232
|
-
# Looks first in project directory, second in home directory.
|
233
|
-
# If configuration file is not found in project directory, Development will not load.
|
196
|
+
# Get hash of gemsets and their gem or gemset members.
|
234
197
|
#
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
expression_string = ''
|
239
|
-
|
240
|
-
configuration_file_path = ::File.expand_path( path )
|
241
|
-
|
242
|
-
@line_number = 0
|
243
|
-
|
244
|
-
::File.open( configuration_file_path ).each_with_index do |this_line, this_line_number|
|
198
|
+
# @return [Hash{Symbol=>Array<::Development::Gemset>}] Hash of gemsets and their gem or gemset members.
|
199
|
+
#
|
200
|
+
def self.gemsets
|
245
201
|
|
246
|
-
|
247
|
-
while parse_configuration_file_line( expression_string, this_line )
|
248
|
-
|
249
|
-
# process expression_string
|
250
|
-
parse_configuration_expression( expression_string )
|
251
|
-
|
252
|
-
# reset expression_string
|
253
|
-
expression_string.clear
|
254
|
-
|
255
|
-
# update line number where expression begins
|
256
|
-
@line_number = this_line_number
|
257
|
-
unless this_line.empty?
|
258
|
-
@line_number += 1
|
259
|
-
end
|
260
|
-
|
261
|
-
# loop will cause start with this_line, which told parse_configuration_file_line
|
262
|
-
# that we were done, and which is therefore not yet processed
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
end
|
267
|
-
|
268
|
-
parse_configuration_expression( expression_string )
|
202
|
+
return @gemsets
|
269
203
|
|
270
204
|
end
|
271
|
-
|
272
|
-
|
273
|
-
# self.
|
274
|
-
|
205
|
+
|
206
|
+
####################
|
207
|
+
# self.directory #
|
208
|
+
####################
|
275
209
|
|
276
210
|
###
|
277
|
-
#
|
278
|
-
#
|
279
|
-
# @param expression_string
|
280
|
-
#
|
281
|
-
# Configuration expression that spans one or more lines in configuration file.
|
211
|
+
# Return path for directory name.
|
282
212
|
#
|
283
|
-
# @
|
213
|
+
# @overload self.directory( name, path, gem_or_gemset, ... )
|
284
214
|
#
|
285
|
-
#
|
215
|
+
# @param directory_name
|
216
|
+
#
|
217
|
+
# Name of named directory.
|
218
|
+
#
|
219
|
+
# @param path_parts
|
220
|
+
#
|
221
|
+
# The first can be a Symbol naming a directory; any can be String describing directory path.
|
286
222
|
#
|
287
|
-
# @return [
|
288
|
-
# True means configuration_file_line was not processed.
|
223
|
+
# @return [::Development::Directory] Directory.
|
289
224
|
#
|
290
|
-
def self.
|
291
|
-
|
292
|
-
expression_complete = false
|
293
|
-
|
294
|
-
# if we begin with a comment we can throw away the line
|
295
|
-
if configuration_file_line[ 0 ] == '#'
|
296
|
-
|
297
|
-
# nothing to do - we just ignore the line
|
298
|
-
|
299
|
-
# if we begin with whitespace we have a continuation
|
300
|
-
elsif configuration_file_line[ 0 ] =~ /\s/
|
301
|
-
|
302
|
-
configuration_file_line.strip!
|
303
|
-
|
304
|
-
expression_complete = parse_configuration_file_line( expression_string, configuration_file_line, true )
|
225
|
+
def self.directory( name, *path_parts )
|
305
226
|
|
306
|
-
|
307
|
-
|
308
|
-
unless expression_string.empty?
|
309
|
-
unless configuration_file_line.empty?
|
310
|
-
expression_string << ' '
|
311
|
-
end
|
312
|
-
end
|
313
|
-
expression_string << configuration_file_line.strip
|
227
|
+
name = name.to_sym
|
314
228
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
# otherwise we reached the next line of the configuration file
|
229
|
+
if directory_instance = @directories[ name ]
|
230
|
+
unless path_parts.empty?
|
231
|
+
directory_instance.set_path( *path_parts )
|
232
|
+
end
|
320
233
|
else
|
321
|
-
|
322
|
-
|
323
|
-
|
234
|
+
if path_parts.empty?
|
235
|
+
raise ::ArgumentError, 'Path required to create directory :' << name.to_s + '.'
|
236
|
+
end
|
237
|
+
@directories[ name ] = directory_instance = Directory.new( name, *path_parts )
|
324
238
|
end
|
325
|
-
|
326
|
-
return expression_complete
|
327
|
-
|
328
|
-
end
|
329
|
-
|
330
|
-
#########################################
|
331
|
-
# self.parse_configuration_expression #
|
332
|
-
#########################################
|
333
|
-
|
334
|
-
###
|
335
|
-
# Parse single configuration expression built up from one or more actual configuration file lines.
|
336
|
-
#
|
337
|
-
# @param expression_string
|
338
|
-
#
|
339
|
-
# String describing configuration directive.
|
340
|
-
#
|
341
|
-
# @return [Object] self.
|
342
|
-
#
|
343
|
-
def self.parse_configuration_expression( expression_string )
|
344
|
-
|
345
|
-
case expression_string[ 0 ]
|
346
|
-
|
347
|
-
# + - named directory expression
|
348
|
-
when '+'
|
349
|
-
|
350
|
-
# either a directory definition or a general directory directive
|
351
|
-
# directory definitions are multiplart, whereas general directory definitions are one part
|
352
|
-
parse_named_directory_expression( expression_string )
|
353
|
-
|
354
|
-
# - - remove general path
|
355
|
-
when '-'
|
356
|
-
|
357
|
-
parse_remove_general_load_path_expression( expression_string )
|
358
|
-
|
359
|
-
# = - gemset expression
|
360
|
-
when '='
|
361
|
-
|
362
|
-
parse_gemset_expression( expression_string )
|
363
|
-
|
364
|
-
# @ - location expression
|
365
|
-
when '@'
|
366
|
-
|
367
|
-
parse_general_directory_or_location_expression( expression_string )
|
368
239
|
|
369
|
-
|
370
|
-
when '!'
|
371
|
-
|
372
|
-
parse_enable_disable_expression( expression_string )
|
373
|
-
|
374
|
-
# general path expression
|
375
|
-
else
|
376
|
-
|
377
|
-
parse_general_load_path_expression( expression_string )
|
378
|
-
|
379
|
-
end
|
380
|
-
|
381
|
-
return self
|
240
|
+
return directory_instance
|
382
241
|
|
383
242
|
end
|
384
243
|
|
385
|
-
|
386
|
-
# self.
|
387
|
-
|
244
|
+
########################
|
245
|
+
# self.get_directory #
|
246
|
+
########################
|
388
247
|
|
389
248
|
###
|
390
|
-
#
|
249
|
+
# Return directory with name.
|
391
250
|
#
|
392
|
-
# @param
|
251
|
+
# @param name
|
393
252
|
#
|
394
|
-
#
|
253
|
+
# Name of directory to return.
|
395
254
|
#
|
396
|
-
# @return [
|
255
|
+
# @return [::Development::Directory] Directory.
|
397
256
|
#
|
398
|
-
def self.
|
399
|
-
|
400
|
-
# if we have multiple parts
|
401
|
-
if whitespace_index = expression_string =~ /\s/
|
402
|
-
|
403
|
-
parse_location_expression( expression_string )
|
257
|
+
def self.get_directory( name )
|
404
258
|
|
405
|
-
|
406
|
-
else
|
407
|
-
|
408
|
-
parse_general_load_path_expression( expression_string )
|
409
|
-
|
410
|
-
end
|
411
|
-
|
412
|
-
return self
|
259
|
+
return @directories[ name.to_sym ]
|
413
260
|
|
414
261
|
end
|
415
|
-
|
416
|
-
|
417
|
-
# self.
|
418
|
-
|
262
|
+
|
263
|
+
######################
|
264
|
+
# self.directories #
|
265
|
+
######################
|
419
266
|
|
420
267
|
###
|
421
|
-
#
|
422
|
-
#
|
423
|
-
# @param expression_string
|
424
|
-
#
|
425
|
-
# String describing named directory expression.
|
268
|
+
# Get Hash of named directory names to paths.
|
426
269
|
#
|
427
|
-
# @return [
|
270
|
+
# @return [Hash{Symbol=>::Development::Directory}]
|
428
271
|
#
|
429
|
-
def self.
|
430
|
-
|
431
|
-
# +directory_name path
|
272
|
+
def self.directories
|
432
273
|
|
433
|
-
|
434
|
-
raise Exception::MalformedExpression::
|
435
|
-
MalformedNamedDirectoryExpression.new( expression_string, @line_number )
|
436
|
-
end
|
274
|
+
return @directories
|
437
275
|
|
438
|
-
|
439
|
-
slice_length = expression_string.length - whitespace_index
|
440
|
-
path = expression_string.slice( whitespace_index + 1, slice_length ).strip
|
276
|
+
end
|
441
277
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
278
|
+
############################
|
279
|
+
# self.general_load_path #
|
280
|
+
############################
|
281
|
+
|
282
|
+
###
|
283
|
+
# Define general load path.
|
284
|
+
#
|
285
|
+
# @param path
|
286
|
+
#
|
287
|
+
# String describing directory path.
|
288
|
+
#
|
289
|
+
# @return [::Development] Self.
|
290
|
+
#
|
291
|
+
def self.general_load_path( path )
|
449
292
|
|
450
|
-
@
|
293
|
+
@general_load_paths.push( ::File.expand_path( path ) )
|
451
294
|
|
452
295
|
return self
|
453
296
|
|
454
297
|
end
|
455
298
|
|
456
|
-
|
457
|
-
# self.
|
458
|
-
|
299
|
+
###################################
|
300
|
+
# self.remove_general_load_path #
|
301
|
+
###################################
|
459
302
|
|
460
303
|
###
|
461
|
-
#
|
462
|
-
#
|
463
|
-
# @param
|
464
|
-
#
|
465
|
-
# String describing
|
304
|
+
# Remove general load path.
|
305
|
+
#
|
306
|
+
# @param path
|
307
|
+
#
|
308
|
+
# String describing directory path.
|
466
309
|
#
|
467
|
-
# @return [
|
310
|
+
# @return [::Development] Self.
|
468
311
|
#
|
469
|
-
def self.
|
470
|
-
|
471
|
-
# =gemset gem_or_set_name[,] ...
|
472
|
-
# =gemset +gem_or_set_name[,] ...
|
473
|
-
# =gemset -gem_or_set_name[,] ...
|
474
|
-
|
475
|
-
gemset_name = parse_base_action_from_expression_string( expression_string )
|
476
|
-
|
477
|
-
gemset = create_gemset( gemset_name )
|
312
|
+
def self.remove_general_load_path( path )
|
478
313
|
|
479
|
-
|
314
|
+
@general_load_paths.delete( ::File.expand_path( path ) )
|
480
315
|
|
481
316
|
return self
|
482
317
|
|
483
318
|
end
|
484
|
-
|
485
|
-
|
486
|
-
# self.
|
487
|
-
|
319
|
+
|
320
|
+
#############################
|
321
|
+
# self.general_load_paths #
|
322
|
+
#############################
|
488
323
|
|
489
324
|
###
|
490
|
-
#
|
325
|
+
# Get Array of paths that will be used for general loading purposes if a specific gem path is not given.
|
491
326
|
#
|
492
|
-
# @
|
327
|
+
# @return [Array<String>] Paths to be used for general loading purposes.
|
493
328
|
#
|
494
|
-
|
329
|
+
def self.general_load_paths
|
330
|
+
|
331
|
+
return @general_load_paths
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
###########################
|
336
|
+
# self.enabled_for_all? #
|
337
|
+
###########################
|
338
|
+
|
339
|
+
###
|
340
|
+
# Query whether Development is set to search in general paths for any gem, even if not explicitly enabled.
|
495
341
|
#
|
496
|
-
# @return [
|
342
|
+
# @return [true,false] Whether general gem search is enabled.
|
497
343
|
#
|
498
|
-
def self.
|
499
|
-
|
500
|
-
base_action = nil
|
501
|
-
|
502
|
-
# get rid of =
|
503
|
-
expression_string.slice!( 0, 1 )
|
504
|
-
|
505
|
-
if whitespace_index = expression_string =~ /\s/
|
506
|
-
base_action = expression_string.slice!( 0, whitespace_index )
|
507
|
-
else
|
508
|
-
base_action = expression_string.dup
|
509
|
-
expression_string.clear
|
510
|
-
end
|
344
|
+
def self.enabled_for_all?
|
511
345
|
|
512
|
-
|
513
|
-
|
514
|
-
return base_action
|
346
|
+
return @enable_for_all
|
515
347
|
|
516
348
|
end
|
517
|
-
|
518
|
-
|
519
|
-
# self.
|
520
|
-
|
349
|
+
|
350
|
+
##################
|
351
|
+
# self.enable! #
|
352
|
+
##################
|
521
353
|
|
522
354
|
###
|
523
|
-
#
|
524
|
-
#
|
525
|
-
# @param hash
|
526
|
-
#
|
527
|
-
# Hash to add parsed data to.
|
355
|
+
# Enable gems.
|
528
356
|
#
|
529
|
-
# @
|
357
|
+
# @overload enable!
|
530
358
|
#
|
531
|
-
#
|
359
|
+
# @overload enable( gem_or_gemset, ... )
|
532
360
|
#
|
533
|
-
#
|
361
|
+
# @param gem_or_gemset
|
534
362
|
#
|
535
|
-
#
|
363
|
+
# Gem or Gemset instance or name to enable.
|
536
364
|
#
|
537
|
-
# @return [Development] Self.
|
365
|
+
# @return [::Development] Self.
|
538
366
|
#
|
539
|
-
def self.
|
367
|
+
def self.enable!( *gem_or_gemset_names )
|
368
|
+
|
369
|
+
if gem_or_gemset_names.empty?
|
540
370
|
|
541
|
-
|
542
|
-
|
543
|
-
|
371
|
+
@enable_for_all = true
|
372
|
+
@gems.each do |this_gem_name, this_gem|
|
373
|
+
this_gem.enable!
|
374
|
+
end
|
375
|
+
@gemsets.each do |this_gemset_name, this_gemset|
|
376
|
+
this_gemset.enable!
|
377
|
+
end
|
378
|
+
|
379
|
+
else
|
380
|
+
|
381
|
+
gem_or_gemset_names.each do |this_gemset_or_gem_name|
|
382
|
+
if this_gemset_or_gem_name.is_a?( ::Hash )
|
383
|
+
this_gemset_or_gem_name.each do |this_gem, this_path|
|
384
|
+
gem_instance = gem( this_gem )
|
385
|
+
gem_instance.set_directory( this_path )
|
386
|
+
gem_instance.enable!
|
387
|
+
end
|
388
|
+
else
|
389
|
+
this_gem_or_gemset_reference_name = this_gemset_or_gem_name.to_s.gsub( '/', '-' ).to_sym
|
390
|
+
if gem_instance = @gems[ this_gem_or_gemset_reference_name ]
|
391
|
+
gem_instance.enable!
|
392
|
+
end
|
393
|
+
if gemset_instance = @gemsets[ this_gem_or_gemset_reference_name ]
|
394
|
+
gemset_instance.enable!
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
544
398
|
|
545
|
-
|
546
|
-
parse_gem_name_from_expression_string( hash, expression_string, expression_string.length, require_exist )
|
399
|
+
end
|
547
400
|
|
548
401
|
return self
|
549
402
|
|
550
403
|
end
|
551
404
|
|
552
|
-
|
553
|
-
# self.
|
554
|
-
|
555
|
-
|
405
|
+
###################
|
406
|
+
# self.disable! #
|
407
|
+
###################
|
408
|
+
|
556
409
|
###
|
557
|
-
#
|
558
|
-
#
|
559
|
-
# @param hash
|
410
|
+
# Disable gems.
|
560
411
|
#
|
561
|
-
#
|
412
|
+
# @overload disable!
|
562
413
|
#
|
563
|
-
# @
|
414
|
+
# @overload disable( gem_or_gemset, ... )
|
564
415
|
#
|
565
|
-
#
|
416
|
+
# @param gem_or_gemset
|
566
417
|
#
|
567
|
-
#
|
418
|
+
# Gem or Gemset instance or name to disable.
|
568
419
|
#
|
569
|
-
#
|
570
|
-
#
|
571
|
-
# @param slice_to_index
|
572
|
-
#
|
573
|
-
# Index to slice expression string to.
|
574
|
-
#
|
575
|
-
# @param require_exist [true,false]
|
576
|
-
#
|
577
|
-
# Raise exception if gems do not exist.
|
420
|
+
# @return [::Development] Self.
|
578
421
|
#
|
579
|
-
|
580
|
-
#
|
581
|
-
def self.parse_gem_name_from_expression_string( hash, expression_string, slice_to_index, require_exist = false )
|
582
|
-
|
583
|
-
gem_name = expression_string.slice!( 0, slice_to_index )
|
422
|
+
def self.disable!( *gem_or_gemset_names )
|
584
423
|
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
424
|
+
if gem_or_gemset_names.empty?
|
425
|
+
|
426
|
+
@enable_for_all = false
|
427
|
+
@gems.each do |this_gem_name, this_gem|
|
428
|
+
this_gem.disable!
|
590
429
|
end
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
case gem_name[ 0 ]
|
595
|
-
when '+'
|
596
|
-
gem_name.slice!( 0, 1 )
|
597
|
-
when '-'
|
598
|
-
gem_name.slice!( 0, 1 )
|
599
|
-
hash.delete( gem_name.to_sym )
|
600
|
-
should_add = false
|
601
|
-
else
|
430
|
+
@gemsets.each do |this_gemset_name, this_gemset|
|
431
|
+
this_gemset.disable!
|
602
432
|
end
|
603
433
|
|
604
|
-
|
605
|
-
# we really just need one or the other consistently
|
606
|
-
gem_name.gsub!( '/', '-' )
|
607
|
-
|
608
|
-
gem_name = gem_name.to_sym
|
434
|
+
else
|
609
435
|
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
436
|
+
gem_or_gemset_names.each do |this_gemset_or_gem_name|
|
437
|
+
this_gem_or_gemset_reference_name = this_gemset_or_gem_name.to_s.gsub( '/', '-' ).to_sym
|
438
|
+
if gem_instance = @gems[ this_gem_or_gemset_reference_name ]
|
439
|
+
gem_instance.disable!
|
440
|
+
end
|
441
|
+
if gemset_instance = @gemsets[ this_gem_or_gemset_reference_name ]
|
442
|
+
gemset_instance.disable!
|
615
443
|
end
|
616
444
|
end
|
617
445
|
|
618
|
-
if should_add
|
619
|
-
hash[ gem_name ] = true
|
620
|
-
end
|
621
|
-
|
622
|
-
expression_string.strip!
|
623
|
-
|
624
446
|
end
|
625
|
-
|
626
|
-
return gem_name
|
627
|
-
|
628
|
-
end
|
629
447
|
|
630
|
-
|
631
|
-
# self.create_gemset #
|
632
|
-
########################
|
633
|
-
|
634
|
-
###
|
635
|
-
# Create gemset with name.
|
636
|
-
#
|
637
|
-
# @param gemset_name
|
638
|
-
#
|
639
|
-
# Name of gemset.
|
640
|
-
#
|
641
|
-
# @return [Array] Gemset.
|
642
|
-
#
|
643
|
-
def self.create_gemset( gemset_name )
|
448
|
+
return self
|
644
449
|
|
645
|
-
gemset_name = gemset_name.to_sym
|
646
|
-
|
647
|
-
unless gemset = @gemsets[ gemset_name ]
|
648
|
-
@gemsets[ gemset_name ] = gemset = { }
|
649
|
-
end
|
650
|
-
|
651
|
-
return gemset
|
652
|
-
|
653
450
|
end
|
654
|
-
|
655
|
-
#################
|
656
|
-
# self.gemset #
|
657
|
-
#################
|
658
451
|
|
452
|
+
#############
|
453
|
+
# loaded? #
|
454
|
+
#############
|
455
|
+
|
659
456
|
###
|
660
|
-
#
|
457
|
+
# Query whether gem was loaded via Development rather than standard require.
|
661
458
|
#
|
662
|
-
# @param
|
459
|
+
# @param gem_name
|
663
460
|
#
|
664
|
-
# Name of
|
461
|
+
# Name of gem.
|
665
462
|
#
|
666
|
-
# @return [
|
463
|
+
# @return [true,false] Whether gem was loaded via Development.
|
667
464
|
#
|
668
|
-
def
|
669
|
-
|
670
|
-
gemset_members = nil
|
465
|
+
def loaded?( gem_name )
|
671
466
|
|
672
|
-
|
673
|
-
gemset_members = gemset.keys
|
674
|
-
end
|
467
|
+
gem_require_name = gem_name.to_s.gsub( '/', '-' )
|
675
468
|
|
676
|
-
return
|
469
|
+
return @loaded_gems.has_key?( gem_require_name.to_sym )
|
677
470
|
|
678
471
|
end
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
472
|
+
|
473
|
+
######################################################################################################################
|
474
|
+
private ##########################################################################################################
|
475
|
+
######################################################################################################################
|
683
476
|
|
477
|
+
initialize
|
478
|
+
|
479
|
+
##################
|
480
|
+
# self.require #
|
481
|
+
##################
|
482
|
+
|
684
483
|
###
|
685
|
-
#
|
484
|
+
# Filters requires to match configuration specifications for loading development paths instead of production gems.
|
686
485
|
#
|
687
|
-
# @param
|
486
|
+
# @param gem_name_or_path
|
688
487
|
#
|
689
|
-
#
|
488
|
+
# Gem name or path to file passed to {::Object#require}.
|
690
489
|
#
|
691
|
-
# @return [
|
490
|
+
# @return [true,false] Whether Development handled gem_name_or_path (true) or processing should continue (false).
|
692
491
|
#
|
693
|
-
def self.
|
694
|
-
|
695
|
-
# @directory_name gem_or_set_name[,] ...
|
696
|
-
|
697
|
-
directory_name = parse_base_action_from_expression_string( expression_string )
|
698
|
-
|
699
|
-
directory_name = directory_name.to_sym
|
700
|
-
|
701
|
-
unless @named_directories.has_key?( directory_name )
|
702
|
-
raise Exception::MalformedExpression::UnknownDirectoryName.new( directory_name, @line_number )
|
703
|
-
end
|
704
|
-
|
705
|
-
unless directory_members = @locations[ directory_name ]
|
706
|
-
@locations[ directory_name ] = directory_members = { }
|
707
|
-
end
|
708
|
-
|
709
|
-
parse_gem_names_from_expression_string( directory_members, expression_string )
|
710
|
-
|
711
|
-
directory_members.each do |this_gem_or_gemset, true_value|
|
712
|
-
if gemset = @gemsets[ this_gem_or_gemset ]
|
713
|
-
gemset.each do |this_gem, true_value|
|
714
|
-
@gem_locations[ this_gem ] = directory_name
|
715
|
-
end
|
716
|
-
else
|
717
|
-
@gem_locations[ this_gem_or_gemset ] = directory_name
|
718
|
-
end
|
719
|
-
end
|
720
|
-
|
721
|
-
return self
|
492
|
+
def self.require( gem_name_or_path )
|
722
493
|
|
723
|
-
|
494
|
+
did_load = nil
|
724
495
|
|
725
|
-
|
726
|
-
|
727
|
-
##########################################
|
496
|
+
# if our path ends with an extension we are not requiring a gem and thus not responsible for managing it
|
497
|
+
if ::File.extname( gem_name_or_path ).empty?
|
728
498
|
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
#
|
734
|
-
# String describing enable/disable expression.
|
735
|
-
#
|
736
|
-
# @return [Object] Self.
|
737
|
-
#
|
738
|
-
def self.parse_enable_disable_expression( expression_string )
|
739
|
-
|
740
|
-
# !enable
|
741
|
-
# !disable
|
742
|
-
# !enable gem_or_set_name[,] ...
|
743
|
-
# !disable gem_or_set_name[,] ...
|
744
|
-
|
745
|
-
# enable or disable
|
746
|
-
enable_or_disable = parse_base_action_from_expression_string( expression_string )
|
747
|
-
|
748
|
-
gems = nil
|
749
|
-
unless expression_string.empty?
|
750
|
-
gems = { }
|
751
|
-
parse_gem_names_from_expression_string( gems, expression_string )
|
752
|
-
end
|
753
|
-
|
754
|
-
case enable_or_disable = enable_or_disable.to_sym
|
499
|
+
gem_directory_name = gem_name_or_path.to_s.gsub( '/', '-' )
|
500
|
+
gem_require_name = gem_name_or_path.to_s.gsub( '-', '/' )
|
501
|
+
|
502
|
+
gem_reference_name = gem_directory_name.to_sym
|
755
503
|
|
756
|
-
|
504
|
+
if @loaded_gems.has_key?( gem_reference_name )
|
757
505
|
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
end
|
771
|
-
else
|
772
|
-
@disabled_gems.delete_if do |this_gem, true_value|
|
773
|
-
@enabled_gems[ this_gem ] = true
|
774
|
-
true
|
506
|
+
did_load = false
|
507
|
+
|
508
|
+
else
|
509
|
+
|
510
|
+
# look for gem name in enabled gems/gemsets
|
511
|
+
if gem_instance = @gems[ gem_reference_name ]
|
512
|
+
|
513
|
+
if gem_instance.enabled?
|
514
|
+
load_gem_instance( gem_instance, gem_directory_name, gem_require_name )
|
515
|
+
did_load = true
|
516
|
+
elsif @enable_for_all && ! gem_instance.disabled?
|
517
|
+
did_load = attempt_load_from_general_load_paths( gem_directory_name, gem_require_name )
|
775
518
|
end
|
776
|
-
|
519
|
+
|
520
|
+
# otherwise see if we perform general loading
|
777
521
|
end
|
778
522
|
|
779
|
-
|
780
|
-
|
781
|
-
if gems
|
782
|
-
gems.each do |this_gem_or_gemset, true_value|
|
783
|
-
if gemset = @gemsets[ this_gem_or_gemset ]
|
784
|
-
gemset.each do |this_gem, true_value|
|
785
|
-
@disabled_gems[ this_gem ] = true
|
786
|
-
@enabled_gems.delete( this_gem )
|
787
|
-
end
|
788
|
-
else
|
789
|
-
this_gem = this_gem_or_gemset
|
790
|
-
@disabled_gems[ this_gem ] = true
|
791
|
-
@enabled_gems.delete( this_gem )
|
792
|
-
end
|
793
|
-
end
|
794
|
-
else
|
795
|
-
@enabled_gems.delete_if do |this_gem, true_value|
|
796
|
-
@disabled_gems[ this_gem ] = true
|
797
|
-
true
|
798
|
-
end
|
799
|
-
@enable_for_all = false
|
523
|
+
if ! did_load and @enable_for_all
|
524
|
+
attempt_load_from_general_load_paths( gem_directory_name, gem_require_name )
|
800
525
|
end
|
801
526
|
|
527
|
+
end
|
528
|
+
|
802
529
|
end
|
803
530
|
|
804
|
-
|
805
|
-
|
806
|
-
return self
|
531
|
+
return did_load
|
807
532
|
|
808
533
|
end
|
809
|
-
|
810
|
-
|
811
|
-
# self.
|
812
|
-
|
813
|
-
|
534
|
+
|
535
|
+
############################
|
536
|
+
# self.load_gem_instance #
|
537
|
+
############################
|
538
|
+
|
814
539
|
###
|
815
|
-
#
|
540
|
+
# Load gem using configuration information provides by gem instance.
|
816
541
|
#
|
817
|
-
# @param
|
542
|
+
# @param gem_instance
|
818
543
|
#
|
819
|
-
#
|
544
|
+
# Gem instance.
|
820
545
|
#
|
821
|
-
# @
|
546
|
+
# @param gem_directory_name
|
822
547
|
#
|
823
|
-
|
824
|
-
|
825
|
-
# path/to/directory, ~/path/to/directory, /path/to/directory
|
826
|
-
# +directory_name/path/from/directory
|
827
|
-
|
828
|
-
case expression_string[ 0 ]
|
829
|
-
|
830
|
-
when '@'
|
831
|
-
|
832
|
-
path_parts = expression_string.split( '/' )
|
833
|
-
named_directory = path_parts.shift
|
834
|
-
named_directory.slice!( 0, 1 )
|
835
|
-
named_directory = named_directory.to_sym
|
836
|
-
expression_string = ::File.expand_path( ::File.join( directory( named_directory ), path_parts ) )
|
837
|
-
|
838
|
-
end
|
839
|
-
|
840
|
-
@general_load_paths.push( ::File.expand_path( expression_string ) )
|
841
|
-
|
842
|
-
return self
|
843
|
-
|
844
|
-
end
|
845
|
-
|
846
|
-
####################################################
|
847
|
-
# self.parse_remove_general_load_path_expression #
|
848
|
-
####################################################
|
849
|
-
|
850
|
-
###
|
851
|
-
# Parse expression string that has been determined as a remove-general-directory expression.
|
548
|
+
# Gem directory in hyphenated gem-subgem format.
|
852
549
|
#
|
853
|
-
# @param
|
550
|
+
# @param gem_require_name
|
854
551
|
#
|
855
|
-
#
|
552
|
+
# Gem name in slashed gem/subgem format.
|
856
553
|
#
|
857
|
-
# @return [
|
554
|
+
# @return [::Development] Self.
|
858
555
|
#
|
859
|
-
def self.
|
556
|
+
def self.load_gem_instance( gem_instance, gem_directory_name, gem_require_name )
|
860
557
|
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
558
|
+
gem_location = gem_instance.directory.path
|
559
|
+
|
560
|
+
if path_is_gem_directory?( gem_location, gem_require_name )
|
561
|
+
# already set
|
562
|
+
elsif path_contains_gem_directory?( gem_location, gem_directory_name, gem_require_name )
|
563
|
+
gem_location = ::File.join( gem_location, gem_directory_name )
|
564
|
+
end
|
866
565
|
|
867
|
-
|
566
|
+
load_gem_in_path( gem_location, gem_directory_name )
|
567
|
+
@loaded_gems[ gem_require_name.to_sym ] = true
|
868
568
|
|
869
569
|
return self
|
870
570
|
|
871
571
|
end
|
872
|
-
|
873
|
-
|
874
|
-
# self.
|
875
|
-
|
572
|
+
|
573
|
+
###############################################
|
574
|
+
# self.attempt_load_from_general_load_paths #
|
575
|
+
###############################################
|
876
576
|
|
877
577
|
###
|
878
|
-
#
|
578
|
+
# Attempt to load gem from general load paths if any are provided.
|
879
579
|
#
|
880
|
-
# @param
|
580
|
+
# @param gem_directory_name
|
881
581
|
#
|
882
|
-
# Gem
|
582
|
+
# Gem directory in hyphenated gem-subgem format.
|
883
583
|
#
|
884
|
-
# @
|
584
|
+
# @param gem_require_name
|
885
585
|
#
|
886
|
-
|
586
|
+
# Gem name in slashed gem/subgem format.
|
587
|
+
#
|
588
|
+
# @return [::Development] Self.
|
589
|
+
#
|
590
|
+
def self.attempt_load_from_general_load_paths( gem_directory_name, gem_require_name )
|
887
591
|
|
888
|
-
|
592
|
+
gem_require_name = gem_directory_name.to_sym
|
593
|
+
|
594
|
+
did_load = false
|
595
|
+
|
596
|
+
# look in each path for gem - use first to match
|
597
|
+
@general_load_paths.each do |this_load_path|
|
889
598
|
|
890
|
-
|
891
|
-
if ::File.extname( gem_name_or_path ).empty?
|
599
|
+
if path_is_gem_directory?( this_load_path, gem_require_name )
|
892
600
|
|
893
|
-
|
601
|
+
load_gem_in_path( this_load_path, gem_directory_name )
|
602
|
+
@loaded_gems[ gem_require_name ] = true
|
603
|
+
did_load = true
|
604
|
+
break
|
894
605
|
|
895
|
-
|
896
|
-
did_load = false
|
897
|
-
else
|
898
|
-
# ensure we have 'gem-subname' rather than 'gem/subname'
|
899
|
-
# we really just need one or the other consistently
|
900
|
-
gem_name = gem_name.gsub( '/', '-' )
|
901
|
-
gem_directory_name = gem_name.gsub( '/', '-' )
|
606
|
+
elsif path_contains_gem_directory?( this_load_path, gem_directory_name, gem_require_name )
|
902
607
|
|
903
|
-
|
904
|
-
if @enabled_gems.include?( gem_name.to_sym ) or
|
905
|
-
@enable_for_all && ! @disabled_gems.include?( gem_name.to_sym )
|
906
|
-
|
907
|
-
if directory_name = @gem_locations[ gem_name.to_sym ]
|
908
|
-
|
909
|
-
load_path = directory( directory_name )
|
910
|
-
|
911
|
-
if gem_name_in_load_path?( load_path, gem_directory_name )
|
912
|
-
|
913
|
-
load_gem_in_path( load_path, gem_directory_name )
|
914
|
-
@loaded_gems[ gem_name.to_sym ] = true
|
915
|
-
did_load = true
|
916
|
-
|
917
|
-
elsif gem_name_at_load_path?( load_path, gem_directory_name )
|
918
|
-
|
919
|
-
load_gem_at_path( load_path, gem_directory_name )
|
920
|
-
@loaded_gems[ gem_name.to_sym ] = true
|
921
|
-
did_load = true
|
922
|
-
|
923
|
-
end
|
924
|
-
|
925
|
-
end
|
926
|
-
|
927
|
-
unless did_load
|
928
|
-
|
929
|
-
# look in each path for gem - use first to match
|
930
|
-
@general_load_paths.each do |this_load_path|
|
608
|
+
gem_location = ::File.join( this_load_path, gem_directory_name )
|
931
609
|
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
did_load = true
|
937
|
-
end
|
610
|
+
load_gem_in_path( gem_location, gem_directory_name )
|
611
|
+
@loaded_gems[ gem_require_name ] = true
|
612
|
+
did_load = true
|
613
|
+
break
|
938
614
|
|
939
|
-
end
|
940
|
-
|
941
|
-
end
|
942
|
-
|
943
|
-
end
|
944
|
-
|
945
615
|
end
|
946
|
-
|
616
|
+
|
947
617
|
end
|
948
618
|
|
949
619
|
return did_load
|
@@ -951,7 +621,7 @@ module ::Development
|
|
951
621
|
end
|
952
622
|
|
953
623
|
#################################
|
954
|
-
# self.
|
624
|
+
# self.path_is_gem_directory? #
|
955
625
|
#################################
|
956
626
|
|
957
627
|
###
|
@@ -961,33 +631,29 @@ module ::Development
|
|
961
631
|
#
|
962
632
|
# Path where gem directory might be located.
|
963
633
|
#
|
964
|
-
# @param
|
634
|
+
# @param gem_require_name
|
965
635
|
#
|
966
636
|
# Name of gem. Assumes gem-subname is used rather than gem/subname.
|
967
637
|
#
|
968
638
|
# @return [true,false] Whether gem name is present.
|
969
639
|
#
|
970
|
-
def self.
|
640
|
+
def self.path_is_gem_directory?( load_path, gem_require_name )
|
971
641
|
|
972
642
|
exists_at_load_path = false
|
973
643
|
|
974
|
-
|
975
|
-
|
976
|
-
gem_require_file = ::File.join( gem_path, 'lib', gem_name ) + '.rb'
|
977
|
-
|
644
|
+
gem_require_file = ::File.join( load_path, 'lib', gem_require_name ) + '.rb'
|
645
|
+
|
978
646
|
if ::File.exist?( ::File.expand_path( gem_require_file ) )
|
979
|
-
|
980
647
|
exists_at_load_path = true
|
981
|
-
|
982
648
|
end
|
983
649
|
|
984
650
|
return exists_at_load_path
|
985
651
|
|
986
652
|
end
|
987
653
|
|
988
|
-
|
989
|
-
# self.
|
990
|
-
|
654
|
+
#######################################
|
655
|
+
# self.path_contains_gem_directory? #
|
656
|
+
#######################################
|
991
657
|
|
992
658
|
###
|
993
659
|
# Query whether gem name is present at load path, meaning load path specifies the directory holding gem directory.
|
@@ -1000,17 +666,20 @@ module ::Development
|
|
1000
666
|
#
|
1001
667
|
# Name of gem. Assumes gem-subname is used rather than gem/subname.
|
1002
668
|
#
|
669
|
+
# @param gem_require_name
|
670
|
+
#
|
671
|
+
# Name of gem. Assumes gem/subname is used rather than gem-subname.
|
672
|
+
#
|
1003
673
|
# @return [true,false] Whether gem name is present.
|
1004
674
|
#
|
1005
|
-
def self.
|
675
|
+
def self.path_contains_gem_directory?( load_path, gem_directory_name, gem_require_name )
|
1006
676
|
|
1007
677
|
exists_at_load_path = false
|
1008
678
|
|
1009
|
-
gem_name = gem_directory_name.gsub( '-', '/' )
|
1010
679
|
gem_path = ::File.join( load_path, gem_directory_name )
|
1011
680
|
|
1012
|
-
gem_require_file = ::File.join( gem_path, 'lib',
|
1013
|
-
|
681
|
+
gem_require_file = ::File.join( gem_path, 'lib', gem_require_name ) + '.rb'
|
682
|
+
|
1014
683
|
if ::Dir.exist?( ::File.expand_path( gem_path ) ) and
|
1015
684
|
::File.exist?( ::File.expand_path( gem_require_file ) )
|
1016
685
|
|
@@ -1039,69 +708,45 @@ module ::Development
|
|
1039
708
|
#
|
1040
709
|
# @return [true,false] Whether gem name is present.
|
1041
710
|
#
|
1042
|
-
def self.load_gem_in_path(
|
711
|
+
def self.load_gem_in_path( load_path, gem_directory_name )
|
1043
712
|
|
1044
|
-
|
1045
|
-
|
1046
|
-
gem_require_file = ::File.join( gem_path, 'lib', gem_name ) + '.rb'
|
713
|
+
gem_require_file = ::File.join( load_path, 'lib', gem_directory_name ) + '.rb'
|
1047
714
|
require_relative( ::File.expand_path( gem_require_file ) )
|
1048
715
|
|
1049
716
|
end
|
1050
|
-
|
1051
|
-
|
1052
|
-
# self.
|
1053
|
-
|
717
|
+
|
718
|
+
##################################
|
719
|
+
# self.load_configuration_file #
|
720
|
+
##################################
|
1054
721
|
|
1055
722
|
###
|
1056
|
-
# Load
|
1057
|
-
#
|
1058
|
-
# @param load_path
|
723
|
+
# Load Development configuration file.
|
1059
724
|
#
|
1060
|
-
#
|
1061
|
-
#
|
1062
|
-
# @param gem_directory_name
|
725
|
+
# @param path
|
1063
726
|
#
|
1064
|
-
#
|
727
|
+
# Location of configuration file.
|
1065
728
|
#
|
1066
|
-
# @return [
|
729
|
+
# @return [::Development] Self.
|
1067
730
|
#
|
1068
|
-
def self.
|
1069
|
-
|
1070
|
-
gem_name = gem_directory_name.gsub( '-', '/' )
|
1071
|
-
gem_path = ::File.join( load_path, gem_directory_name )
|
731
|
+
def self.load_configuration_file( path )
|
1072
732
|
|
1073
|
-
|
733
|
+
absolute_path = ::File.expand_path( path )
|
1074
734
|
|
1075
|
-
|
735
|
+
if ::File.exists?( absolute_path )
|
736
|
+
::Development::ConfigurationInterface.module_eval do
|
737
|
+
alias_method :gem, :gem_method
|
738
|
+
end
|
739
|
+
load( absolute_path )
|
740
|
+
::Development::ConfigurationInterface.module_eval do
|
741
|
+
remove_method :gem
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
745
|
+
return self
|
1076
746
|
|
1077
747
|
end
|
1078
748
|
|
1079
749
|
end
|
1080
750
|
|
1081
|
-
|
1082
|
-
|
1083
|
-
require_relative 'development/exception/expression_error.rb'
|
1084
|
-
require_relative 'development/exception/expression_error/unknown_directory_name.rb'
|
1085
|
-
require_relative 'development/exception/expression_error/unknown_gem_or_gemset_name.rb'
|
1086
|
-
|
1087
|
-
require_relative 'development/exception/malformed_expression.rb'
|
1088
|
-
require_relative 'development/exception/malformed_expression/malformed_named_directory_expression.rb'
|
1089
|
-
require_relative 'development/exception/malformed_expression/malformed_gemset_expression.rb'
|
1090
|
-
require_relative 'development/exception/malformed_expression/malformed_location_expression.rb'
|
1091
|
-
require_relative 'development/exception/malformed_expression/malformed_enable_disable_expression.rb'
|
1092
|
-
require_relative 'development/exception/malformed_expression/malformed_general_directory_expression.rb'
|
1093
|
-
require_relative 'development/exception/malformed_expression/malformed_remove_general_directory_expression.rb'
|
1094
|
-
|
1095
|
-
###
|
1096
|
-
# Object is enabled with Development require functionality.
|
1097
|
-
#
|
1098
|
-
class ::Object
|
1099
|
-
include ::Development::Require
|
1100
|
-
extend ::Development::Require
|
1101
|
-
end
|
1102
|
-
|
1103
|
-
if defined?( ::Bundler )
|
1104
|
-
::Development::Require::BundlerSupport.call
|
1105
|
-
end
|
1106
|
-
|
1107
|
-
::Development.load_configuration_file( ::File.join( '~', ::Development::ConfigurationFileName ) )
|
751
|
+
# post-load setup
|
752
|
+
require_relative './setup.rb'
|