development 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -7,4 +7,4 @@ Update for preventing multiple-load.
|
|
7
7
|
Oops! Configuration-file enabling was commented out. So 1.0.3 is the first working version!
|
8
8
|
... And then left comments in.
|
9
9
|
Fix for enabling by gemset.
|
10
|
-
|
10
|
+
Directories can now specify either the directory the gem directory is in or the gem directory itself.
|
data/lib/development.rb
CHANGED
@@ -894,32 +894,45 @@ module ::Development
|
|
894
894
|
# ensure we have 'gem-subname' rather than 'gem/subname'
|
895
895
|
# we really just need one or the other consistently
|
896
896
|
gem_directory_name = gem_name.gsub( '/', '-' )
|
897
|
-
|
897
|
+
|
898
898
|
# look for gem name in enabled gems/gemsets
|
899
899
|
if @enabled_gems.include?( gem_name.to_sym ) or
|
900
900
|
@enable_for_all && ! @disabled_gems.include?( gem_name.to_sym )
|
901
901
|
|
902
|
-
if directory_name = @gem_locations[ gem_name.to_sym ]
|
903
|
-
|
904
|
-
|
902
|
+
if directory_name = @gem_locations[ gem_name.to_sym ]
|
903
|
+
|
904
|
+
load_path = directory( directory_name )
|
905
|
+
|
906
|
+
if gem_name_in_load_path?( load_path, gem_directory_name )
|
907
|
+
|
908
|
+
load_gem_in_path( load_path, gem_directory_name )
|
909
|
+
@loaded_gems.push( gem_name.to_sym )
|
910
|
+
did_load = true
|
905
911
|
|
906
|
-
|
907
|
-
|
908
|
-
|
912
|
+
elsif gem_name_at_load_path?( load_path, gem_directory_name )
|
913
|
+
|
914
|
+
load_gem_at_path( load_path, gem_directory_name )
|
915
|
+
@loaded_gems.push( gem_name.to_sym )
|
916
|
+
did_load = true
|
917
|
+
|
918
|
+
end
|
919
|
+
|
920
|
+
end
|
921
|
+
|
922
|
+
unless did_load
|
909
923
|
|
910
|
-
else
|
911
924
|
# look in each path for gem - use first to match
|
912
925
|
@general_load_paths.each do |this_load_path|
|
913
926
|
|
914
927
|
# look for gem name at load path
|
915
928
|
if gem_name_at_load_path?( this_load_path, gem_name )
|
916
|
-
|
929
|
+
load_gem_at_path( this_load_path, gem_name )
|
917
930
|
@loaded_gems.push( gem_name.to_sym )
|
918
931
|
did_load = true
|
919
932
|
end
|
920
933
|
|
921
934
|
end
|
922
|
-
|
935
|
+
|
923
936
|
end
|
924
937
|
|
925
938
|
end
|
@@ -932,12 +945,47 @@ module ::Development
|
|
932
945
|
|
933
946
|
end
|
934
947
|
|
948
|
+
#################################
|
949
|
+
# self.gem_name_in_load_path? #
|
950
|
+
#################################
|
951
|
+
|
952
|
+
###
|
953
|
+
# Query whether gem name is present in load path, meaning load path specifies the gem directory.
|
954
|
+
#
|
955
|
+
# @param load_path
|
956
|
+
#
|
957
|
+
# Path where gem directory might be located.
|
958
|
+
#
|
959
|
+
# @param gem_directory_name
|
960
|
+
#
|
961
|
+
# Name of gem. Assumes gem-subname is used rather than gem/subname.
|
962
|
+
#
|
963
|
+
# @return [true,false] Whether gem name is present.
|
964
|
+
#
|
965
|
+
def self.gem_name_in_load_path?( gem_path, gem_directory_name, require_gem_at_path = false )
|
966
|
+
|
967
|
+
exists_at_load_path = false
|
968
|
+
|
969
|
+
gem_name = gem_directory_name.gsub( '-', '/' )
|
970
|
+
|
971
|
+
gem_require_file = ::File.join( gem_path, 'lib', gem_name ) + '.rb'
|
972
|
+
|
973
|
+
if ::File.exist?( ::File.expand_path( gem_require_file ) )
|
974
|
+
|
975
|
+
exists_at_load_path = true
|
976
|
+
|
977
|
+
end
|
978
|
+
|
979
|
+
return exists_at_load_path
|
980
|
+
|
981
|
+
end
|
982
|
+
|
935
983
|
#################################
|
936
984
|
# self.gem_name_at_load_path? #
|
937
985
|
#################################
|
938
986
|
|
939
987
|
###
|
940
|
-
# Query whether gem name is present at load path.
|
988
|
+
# Query whether gem name is present at load path, meaning load path specifies the directory holding gem directory.
|
941
989
|
#
|
942
990
|
# @param load_path
|
943
991
|
#
|
@@ -968,13 +1016,39 @@ module ::Development
|
|
968
1016
|
return exists_at_load_path
|
969
1017
|
|
970
1018
|
end
|
1019
|
+
|
1020
|
+
###########################
|
1021
|
+
# self.load_gem_in_path #
|
1022
|
+
###########################
|
971
1023
|
|
972
|
-
|
973
|
-
#
|
974
|
-
|
1024
|
+
###
|
1025
|
+
# Load gem from gem directory path. Assumes gem is present in path.
|
1026
|
+
#
|
1027
|
+
# @param load_path
|
1028
|
+
#
|
1029
|
+
# Path where gem directory might be located.
|
1030
|
+
#
|
1031
|
+
# @param gem_directory_name
|
1032
|
+
#
|
1033
|
+
# Name of gem. Assumes gem-subname is used rather than gem/subname.
|
1034
|
+
#
|
1035
|
+
# @return [true,false] Whether gem name is present.
|
1036
|
+
#
|
1037
|
+
def self.load_gem_in_path( gem_path, gem_directory_name )
|
1038
|
+
|
1039
|
+
gem_name = gem_directory_name.gsub( '-', '/' )
|
1040
|
+
|
1041
|
+
gem_require_file = ::File.join( gem_path, 'lib', gem_name ) + '.rb'
|
1042
|
+
require_relative( ::File.expand_path( gem_require_file ) )
|
1043
|
+
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
###########################
|
1047
|
+
# self.load_gem_at_path #
|
1048
|
+
###########################
|
975
1049
|
|
976
1050
|
###
|
977
|
-
# Load gem from gem
|
1051
|
+
# Load gem from path to directory holding gem directory. Assumes gem is present at path.
|
978
1052
|
#
|
979
1053
|
# @param load_path
|
980
1054
|
#
|
@@ -986,7 +1060,7 @@ module ::Development
|
|
986
1060
|
#
|
987
1061
|
# @return [true,false] Whether gem name is present.
|
988
1062
|
#
|
989
|
-
def self.
|
1063
|
+
def self.load_gem_at_path( load_path, gem_directory_name )
|
990
1064
|
|
991
1065
|
gem_name = gem_directory_name.gsub( '-', '/' )
|
992
1066
|
gem_path = ::File.join( load_path, gem_directory_name )
|
data/lib/development/require.rb
CHANGED
data/spec/development_spec.rb
CHANGED
@@ -221,30 +221,55 @@ describe ::Development do
|
|
221
221
|
|
222
222
|
end
|
223
223
|
|
224
|
+
#################################
|
225
|
+
# self.gem_name_in_load_path? #
|
226
|
+
#################################
|
227
|
+
|
228
|
+
it 'can find a gem name in a load path, meaning load path specifies the gem directory' do
|
229
|
+
::Development.gem_name_in_load_path?( 'spec/mock_gem', 'mock_gem' ).should == true
|
230
|
+
::Development.gem_name_in_load_path?( 'spec/mock_gem-subgem', 'mock_gem-subgem' ).should == true
|
231
|
+
end
|
232
|
+
|
224
233
|
#################################
|
225
234
|
# self.gem_name_at_load_path? #
|
226
235
|
#################################
|
227
236
|
|
228
|
-
it 'can find a gem name at a load path' do
|
237
|
+
it 'can find a gem name at a load path, meaning load path specifies the directory holding gem directory' do
|
229
238
|
::Development.gem_name_at_load_path?( 'spec', 'mock_gem' ).should == true
|
230
239
|
::Development.gem_name_at_load_path?( 'spec', 'mock_gem-subgem' ).should == true
|
231
240
|
end
|
232
241
|
|
233
|
-
|
234
|
-
# self.
|
235
|
-
|
242
|
+
###########################
|
243
|
+
# self.load_gem_in_path #
|
244
|
+
###########################
|
236
245
|
|
237
246
|
it 'can load a gem from a development path' do
|
238
247
|
|
239
248
|
defined?( ::Development::MockGem ).should == nil
|
240
|
-
::Development.
|
249
|
+
::Development.load_gem_in_path( 'spec/mock_gem', 'mock_gem' )
|
241
250
|
defined?( ::Development::MockGem ).should == 'constant'
|
242
251
|
|
243
252
|
defined?( ::Development::MockGem::Subgem ).should == nil
|
244
|
-
::Development.
|
253
|
+
::Development.load_gem_in_path( 'spec/mock_gem-subgem', 'mock_gem-subgem' )
|
245
254
|
defined?( ::Development::MockGem::Subgem ).should == 'constant'
|
246
255
|
|
247
256
|
end
|
257
|
+
|
258
|
+
###########################
|
259
|
+
# self.load_gem_at_path #
|
260
|
+
###########################
|
261
|
+
|
262
|
+
it 'can load a gem from a development path' do
|
263
|
+
|
264
|
+
defined?( ::Development::MockGem2 ).should == nil
|
265
|
+
::Development.load_gem_at_path( 'spec', 'mock_gem2' )
|
266
|
+
defined?( ::Development::MockGem2 ).should == 'constant'
|
267
|
+
|
268
|
+
defined?( ::Development::MockGem2::Subgem2 ).should == nil
|
269
|
+
::Development.load_gem_at_path( 'spec', 'mock_gem-subgem2' )
|
270
|
+
defined?( ::Development::MockGem2::Subgem2 ).should == 'constant'
|
271
|
+
|
272
|
+
end
|
248
273
|
|
249
274
|
##################################
|
250
275
|
# self.load_configuration_file #
|
@@ -277,7 +302,7 @@ describe ::Development do
|
|
277
302
|
####################
|
278
303
|
# Object.require #
|
279
304
|
####################
|
280
|
-
|
305
|
+
|
281
306
|
it 'hooks require for registered gems' do
|
282
307
|
|
283
308
|
::Development.parse_configuration_expression( '+directory_name ./spec' )
|
@@ -289,6 +314,18 @@ describe ::Development do
|
|
289
314
|
defined?( ::Development::RequireMock ).should == 'constant'
|
290
315
|
|
291
316
|
end
|
317
|
+
|
318
|
+
it 'hooks require for registered gems' do
|
319
|
+
|
320
|
+
::Development.parse_configuration_expression( '+directory_name ./spec/require_mock2' )
|
321
|
+
::Development.parse_configuration_expression( '@directory_name require_mock2' )
|
322
|
+
::Development.parse_configuration_expression( '!enable require_mock2' )
|
323
|
+
|
324
|
+
defined?( ::Development::RequireMock2 ).should == nil
|
325
|
+
require 'require_mock2'
|
326
|
+
defined?( ::Development::RequireMock2 ).should == 'constant'
|
327
|
+
|
328
|
+
end
|
292
329
|
|
293
330
|
it 'hooks require for enable-all' do
|
294
331
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: development
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -57,8 +57,11 @@ files:
|
|
57
57
|
- spec/development_spec.rb
|
58
58
|
- spec/mock_gem/lib/mock_gem.rb
|
59
59
|
- spec/mock_gem-subgem/lib/mock_gem/subgem.rb
|
60
|
+
- spec/mock_gem-subgem2/lib/mock_gem/subgem2.rb
|
61
|
+
- spec/mock_gem2/lib/mock_gem2.rb
|
60
62
|
- spec/other_require_mock/lib/other_require_mock.rb
|
61
63
|
- spec/require_mock/lib/require_mock.rb
|
64
|
+
- spec/require_mock2/lib/require_mock2.rb
|
62
65
|
- README.md
|
63
66
|
- CHANGELOG.md
|
64
67
|
homepage: http://rubygems.org/gems/development
|
@@ -72,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
75
|
requirements:
|
73
76
|
- - ! '>='
|
74
77
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
78
|
+
version: 1.9.1
|
76
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
80
|
none: false
|
78
81
|
requirements:
|