development 1.0.8 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGELOG.md +3 -0
  2. data/README.md +59 -82
  3. data/lib/development/configuration_interface.rb +123 -0
  4. data/lib/development/directory/directory_interface.rb +165 -0
  5. data/lib/development/directory.rb +9 -0
  6. data/lib/development/gem/gem_interface.rb +191 -0
  7. data/lib/development/gem.rb +9 -0
  8. data/lib/development/gemset/gemset_interface.rb +314 -0
  9. data/lib/development/gemset.rb +9 -0
  10. data/lib/development.rb +428 -783
  11. data/lib/namespaces.rb +9 -0
  12. data/lib/requires.rb +23 -0
  13. data/lib/setup.rb +15 -0
  14. data/spec/development/directory_spec.rb +75 -0
  15. data/spec/development/gem_spec.rb +63 -0
  16. data/spec/development/gemset_spec.rb +105 -0
  17. data/spec/development_spec.rb +142 -277
  18. data/spec/{require_mock → mock/require_mock}/lib/require_mock.rb +0 -0
  19. data/spec/mock/require_mock-submock/lib/require_mock/submock.rb +3 -0
  20. data/spec/{require_mock2 → mock/require_mock2}/lib/require_mock2.rb +0 -0
  21. data/spec/mock/require_mock3/lib/require_mock3.rb +4 -0
  22. data/spec/mock/require_mock4/lib/require_mock4.rb +4 -0
  23. metadata +20 -19
  24. data/lib/development/exception/expression_error/unknown_directory_name.rb +0 -14
  25. data/lib/development/exception/expression_error/unknown_gem_or_gemset_name.rb +0 -14
  26. data/lib/development/exception/expression_error.rb +0 -18
  27. data/lib/development/exception/malformed_expression/malformed_enable_disable_expression.rb +0 -15
  28. data/lib/development/exception/malformed_expression/malformed_gemset_expression.rb +0 -15
  29. data/lib/development/exception/malformed_expression/malformed_general_directory_expression.rb +0 -15
  30. data/lib/development/exception/malformed_expression/malformed_location_expression.rb +0 -15
  31. data/lib/development/exception/malformed_expression/malformed_named_directory_expression.rb +0 -15
  32. data/lib/development/exception/malformed_expression/malformed_remove_general_directory_expression.rb +0 -15
  33. data/lib/development/exception/malformed_expression.rb +0 -16
  34. data/spec/mock_gem/lib/mock_gem.rb +0 -4
  35. data/spec/mock_gem-subgem/lib/mock_gem/subgem.rb +0 -4
  36. data/spec/mock_gem-subgem2/lib/mock_gem/subgem2.rb +0 -4
  37. data/spec/mock_gem2/lib/mock_gem2.rb +0 -4
  38. data/spec/other_require_mock/lib/other_require_mock.rb +0 -4
@@ -0,0 +1,191 @@
1
+
2
+ ###
3
+ # Interface for gem implementation. Implementation provided separately for ease of overloading.
4
+ #
5
+ module ::Development::Gem::GemInterface
6
+
7
+ ################
8
+ # initialize #
9
+ ################
10
+
11
+ ###
12
+ #
13
+ # @overload initialize( name, path_part, ... )
14
+ #
15
+ # @param name
16
+ #
17
+ # Reference name for directory.
18
+ #
19
+ # @param directory_or_path
20
+ #
21
+ # Development::Directory instance or String describing path.
22
+ #
23
+ def initialize( name, directory_or_path = nil )
24
+
25
+ gem_reference_name = name.to_s.gsub( '/', '-' )
26
+
27
+ @name = gem_reference_name.to_sym
28
+
29
+ self.set_directory( directory_or_path )
30
+
31
+ @enabled = false
32
+
33
+ # if there's a directory by gem name, use it
34
+ if directory = ::Development.get_directory( name )
35
+ @directory = directory
36
+ end
37
+
38
+ end
39
+
40
+ ##########
41
+ # name #
42
+ ##########
43
+
44
+ ###
45
+ # Name.
46
+ #
47
+ # @!attribute [reader] Name.
48
+ #
49
+ attr_reader :name
50
+
51
+ ###############
52
+ # directory #
53
+ ###############
54
+
55
+ ###
56
+ # Directory.
57
+ #
58
+ # @overload directory
59
+ #
60
+ # @overload directory( directory_name )
61
+ #
62
+ # @param directory_name
63
+ #
64
+ # Name of directory.
65
+ #
66
+ # @overload directory( directory_path_part, ... )
67
+ #
68
+ # @param directory_path_part
69
+ #
70
+ # The first part can be a symbol naming a directory; all parts can be String path parts.
71
+ #
72
+ # @return [::Development::Directory] Directory instance.
73
+ #
74
+ def directory( *args )
75
+
76
+ return_value = nil
77
+
78
+ if args.empty?
79
+ return_value = @directory
80
+ else
81
+ @directory = ::Development.directory( *args )
82
+ return_value = @directory
83
+ end
84
+
85
+ return return_value
86
+
87
+ end
88
+
89
+ ###################
90
+ # set_directory #
91
+ ###################
92
+
93
+ ###
94
+ # Directory.
95
+ #
96
+ # @!attribute [reader] Directory.
97
+ #
98
+ # @return [::Development::Gem] Self.
99
+ #
100
+ def set_directory( directory_or_path )
101
+
102
+ if directory_or_path
103
+
104
+ case directory_or_path
105
+ when ::Development::Directory
106
+ @directory = directory_or_path
107
+ else
108
+ unless @directory = ::Development.get_directory( directory_or_path )
109
+ if @directory
110
+ @directory.set_path( directory_or_path )
111
+ else
112
+ @directory = ::Development::Directory.new( @name, directory_or_path )
113
+ end
114
+ end
115
+ end
116
+
117
+ else
118
+
119
+ @directory = nil
120
+
121
+ end
122
+
123
+ return self
124
+
125
+ end
126
+
127
+ ##############
128
+ # enabled? #
129
+ ##############
130
+
131
+ ###
132
+ # Query whether Gem is enabled.
133
+ #
134
+ # @return [true,false] Whether Gem is enabled.
135
+ #
136
+ def enabled?
137
+
138
+ return @enabled
139
+
140
+ end
141
+
142
+ ###############
143
+ # disabled? #
144
+ ###############
145
+
146
+ ###
147
+ # Query whether Gem is disabled.
148
+ #
149
+ # @return [true,false] Whether Gem is disabled.
150
+ #
151
+ def disabled?
152
+
153
+ return ! @enabled
154
+
155
+ end
156
+
157
+ #############
158
+ # enable! #
159
+ #############
160
+
161
+ ###
162
+ # Enable all gems and general load path searching.
163
+ #
164
+ # @return [::Development::Gem] Self.
165
+ #
166
+ def enable!
167
+
168
+ @enabled = true
169
+
170
+ return self
171
+
172
+ end
173
+
174
+ ##############
175
+ # disable! #
176
+ ##############
177
+
178
+ ###
179
+ # Disble all gems and general load path searching.
180
+ #
181
+ # @return [::Development::Gem] Self.
182
+ #
183
+ def disable!
184
+
185
+ @enabled = false
186
+
187
+ return self
188
+
189
+ end
190
+
191
+ end
@@ -0,0 +1,9 @@
1
+
2
+ ###
3
+ # Gem class.
4
+ #
5
+ class ::Development::Gem
6
+
7
+ include ::Development::Gem::GemInterface
8
+
9
+ end
@@ -0,0 +1,314 @@
1
+
2
+ ###
3
+ # Interface for gemset implementation. Implementation provided separately for ease of overloading.
4
+ #
5
+ module ::Development::Gemset::GemsetInterface
6
+
7
+ ################
8
+ # initialize #
9
+ ################
10
+
11
+ def initialize( name, *gems_or_gemsets )
12
+
13
+ gem_reference_name = name.to_s.gsub( '/', '-' )
14
+
15
+ @name = gem_reference_name.to_sym
16
+
17
+ @gems_or_gemsets = { }
18
+
19
+ add( *gems_or_gemsets )
20
+
21
+ @enabled = false
22
+
23
+ # if there's a directory by gemset name, use it
24
+ if directory = ::Development.get_directory( name )
25
+ @directory = directory
26
+ end
27
+
28
+ end
29
+
30
+ ##########
31
+ # name #
32
+ ##########
33
+
34
+ ###
35
+ # Name.
36
+ #
37
+ # @!attribute [reader] Name.
38
+ #
39
+ attr_reader :name
40
+
41
+ #############
42
+ # members #
43
+ #############
44
+
45
+ ###
46
+ # Gems or Gemsets that are members of self.
47
+ #
48
+ # @return [Array<::Development::Gem,::Development::Gemset>] Members
49
+ #
50
+ def members
51
+
52
+ return @gems_or_gemsets.keys
53
+
54
+ end
55
+
56
+ ###############
57
+ # directory #
58
+ ###############
59
+
60
+ ###
61
+ # Directory.
62
+ #
63
+ # @overload directory
64
+ #
65
+ # @overload directory( directory_name )
66
+ #
67
+ # @param directory_name
68
+ #
69
+ # Name of directory.
70
+ #
71
+ # @overload directory( directory_path_part, ... )
72
+ #
73
+ # @param directory_path_part
74
+ #
75
+ # The first part can be a symbol naming a directory; all parts can be String path parts.
76
+ #
77
+ # @return [::Development::Directory] Directory instance.
78
+ #
79
+ def directory( *args )
80
+
81
+ return_value = nil
82
+
83
+ if args.empty?
84
+ return_value = @directory
85
+ else
86
+ @directory = ::Development.directory( *args )
87
+ return_value = @directory
88
+ end
89
+
90
+ return return_value
91
+
92
+ end
93
+
94
+ ###################
95
+ # set_directory #
96
+ ###################
97
+
98
+ ###
99
+ # Directory.
100
+ #
101
+ # @!attribute [reader] Directory.
102
+ #
103
+ # @return [::Development::Gem] Self.
104
+ #
105
+ def set_directory( directory_or_path, *path_parts )
106
+
107
+ if directory_or_path
108
+
109
+ case directory_or_path
110
+ when ::Development::Directory
111
+ @directory = directory_or_path
112
+ else
113
+ if path_parts.empty?
114
+ @directory = ::Development.get_directory( directory_or_path )
115
+ else
116
+ @directory ||= ::Development.directory( @name )
117
+ @directory.set_path( directory_or_path, *path_parts )
118
+ end
119
+ end
120
+
121
+ @gems_or_gemsets.each do |this_gem_or_gemset, true_value|
122
+ this_gem_or_gemset.set_directory( @directory )
123
+ end
124
+
125
+ else
126
+
127
+ @directory = nil
128
+
129
+ end
130
+
131
+ return self
132
+
133
+ end
134
+
135
+ #########
136
+ # add #
137
+ #########
138
+
139
+ ###
140
+ # Add gems or gemsets to directory.
141
+ #
142
+ # @overload add( gem_or_gemset, ... )
143
+ #
144
+ # @param gem_or_gemset
145
+ #
146
+ # Gem or Gemset instance or name to add to directory.
147
+ #
148
+ # @return [::Development::Gemset] Self.
149
+ #
150
+ def add( *gems_or_gemsets )
151
+
152
+ gems_or_gemsets.each do |this_gem_or_gemset|
153
+
154
+ found_gem_or_gemset = false
155
+
156
+ case this_gem_or_gemset
157
+
158
+ when ::Development::Gem,
159
+ ::Development::Gemset
160
+
161
+ @gems_or_gemsets[ this_gem_or_gemset ] = true
162
+
163
+ else
164
+
165
+ this_gem_or_gemset_reference_name = this_gem_or_gemset.to_s.gsub( '/', '-' )
166
+
167
+ if gemset_instance = ::Development.get_gemset( this_gem_or_gemset_reference_name )
168
+ gemset_instance.set_directory( @directory )
169
+ @gems_or_gemsets[ gemset_instance ] = true
170
+ found_gem_or_gemset = true
171
+ end
172
+
173
+ if gem_instance = ::Development.get_gem( this_gem_or_gemset_reference_name )
174
+ gem_instance.set_directory( @directory )
175
+ @gems_or_gemsets[ gem_instance ] = true
176
+ found_gem_or_gemset = true
177
+ end
178
+
179
+ unless found_gem_or_gemset
180
+ gem_instance = ::Development.gem( this_gem_or_gemset_reference_name )
181
+ gem_instance.set_directory( @directory )
182
+ @gems_or_gemsets[ gem_instance ] = true
183
+ end
184
+
185
+ end
186
+
187
+ end
188
+
189
+ return self
190
+
191
+ end
192
+
193
+ ############
194
+ # delete #
195
+ # remove #
196
+ ############
197
+
198
+ ###
199
+ # Remove gems or gemsets from directory.
200
+ #
201
+ # @overload delete( gem_or_gemset, ... )
202
+ #
203
+ # @param gem_or_gemset
204
+ #
205
+ # Gem or Gemset instance or name to add to directory.
206
+ #
207
+ # @return [::Development::Gemset] Self.
208
+ #
209
+ def delete( *gems_or_gemsets )
210
+
211
+ gems_or_gemsets.each do |this_gem_or_gemset|
212
+
213
+ case this_gem_or_gemset
214
+
215
+ when ::Development::Gem,
216
+ ::Development::Gemset
217
+
218
+ @gems_or_gemsets.delete( this_gem_or_gemset )
219
+
220
+ else
221
+
222
+ this_gem_or_gemset_reference_name = this_gem_or_gemset.to_s.gsub( '/', '-' )
223
+
224
+ if gemset_instance = ::Development.get_gemset( this_gem_or_gemset_reference_name )
225
+ @gems_or_gemsets.delete( gemset_instance )
226
+ end
227
+
228
+ if gem_instance = ::Development.get_gem( this_gem_or_gemset_reference_name )
229
+ @gems_or_gemsets.delete( gem_instance )
230
+ end
231
+
232
+ end
233
+
234
+ end
235
+
236
+ return self
237
+
238
+ end
239
+
240
+ alias_method :remove, :delete
241
+
242
+ ##############
243
+ # enabled? #
244
+ ##############
245
+
246
+ ###
247
+ # Query whether Gem is enabled.
248
+ #
249
+ # @return [true,false] Whether Gem is enabled.
250
+ #
251
+ def enabled?
252
+
253
+ return @enabled
254
+
255
+ end
256
+
257
+ ###############
258
+ # disabled? #
259
+ ###############
260
+
261
+ ###
262
+ # Query whether Gem is disabled.
263
+ #
264
+ # @return [true,false] Whether Gem is disabled.
265
+ #
266
+ def disabled?
267
+
268
+ return ! @enabled
269
+
270
+ end
271
+
272
+ #############
273
+ # enable! #
274
+ #############
275
+
276
+ ###
277
+ # Enable all gems and general load path searching.
278
+ #
279
+ # @return [::Development::Gem] Self.
280
+ #
281
+ def enable!
282
+
283
+ @enabled = true
284
+
285
+ @gems_or_gemsets.each do |this_gem_or_gemset, true_value|
286
+ this_gem_or_gemset.enable!
287
+ end
288
+
289
+ return self
290
+
291
+ end
292
+
293
+ ##############
294
+ # disable! #
295
+ ##############
296
+
297
+ ###
298
+ # Disble all gems and general load path searching.
299
+ #
300
+ # @return [::Development::Gem] Self.
301
+ #
302
+ def disable!
303
+
304
+ @enabled = false
305
+
306
+ @gems_or_gemsets.each do |this_gem_or_gemset, true_value|
307
+ this_gem_or_gemset.disable!
308
+ end
309
+
310
+ return self
311
+
312
+ end
313
+
314
+ end