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/namespaces.rb
ADDED
data/lib/requires.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
basepath = 'development'
|
3
|
+
|
4
|
+
files = [
|
5
|
+
|
6
|
+
'require',
|
7
|
+
|
8
|
+
'configuration_interface',
|
9
|
+
|
10
|
+
'directory/directory_interface',
|
11
|
+
'directory',
|
12
|
+
|
13
|
+
'gem/gem_interface',
|
14
|
+
'gem',
|
15
|
+
|
16
|
+
'gemset/gemset_interface',
|
17
|
+
'gemset'
|
18
|
+
|
19
|
+
]
|
20
|
+
|
21
|
+
files.each do |this_file|
|
22
|
+
require_relative( ::File.join( basepath, this_file ) + '.rb' )
|
23
|
+
end
|
data/lib/setup.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
# Object is enabled with Development require functionality.
|
4
|
+
#
|
5
|
+
class ::Object
|
6
|
+
include ::Development::Require
|
7
|
+
extend ::Development::Require
|
8
|
+
include ::Development::ConfigurationInterface
|
9
|
+
end
|
10
|
+
|
11
|
+
if defined?( ::Bundler )
|
12
|
+
::Development::Require::BundlerSupport.call
|
13
|
+
end
|
14
|
+
|
15
|
+
::Development.load_configuration_file( ::File.join( '~', ::Development::ConfigurationFileName ) )
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/development.rb'
|
3
|
+
|
4
|
+
describe ::Development::Directory do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
::Development.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
################
|
11
|
+
# initialize #
|
12
|
+
# name #
|
13
|
+
# path #
|
14
|
+
################
|
15
|
+
|
16
|
+
it 'can initialize with a name and a path' do
|
17
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
18
|
+
directory.name.should == :name
|
19
|
+
directory.path.should == ::File.expand_path( 'some/path' )
|
20
|
+
end
|
21
|
+
|
22
|
+
###########
|
23
|
+
# path= #
|
24
|
+
###########
|
25
|
+
|
26
|
+
it 'can set the path' do
|
27
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
28
|
+
directory.set_path( 'some/other/path' )
|
29
|
+
directory.path.should == ::File.expand_path( 'some/other/path' )
|
30
|
+
end
|
31
|
+
|
32
|
+
#########
|
33
|
+
# add #
|
34
|
+
#########
|
35
|
+
|
36
|
+
it 'can add gems by name that do not already exist in Development definition' do
|
37
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
38
|
+
gem_instance = ::Development.gem( :gem_name )
|
39
|
+
directory.add( :gem_name )
|
40
|
+
directory.members.should == [ gem_instance ]
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can add gems that already exist in Development definition' do
|
44
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
45
|
+
gem_instance = ::Development.gem( :gem_name )
|
46
|
+
directory.add( gem_instance )
|
47
|
+
directory.members.should == [ gem_instance ]
|
48
|
+
end
|
49
|
+
|
50
|
+
############
|
51
|
+
# delete #
|
52
|
+
# remove #
|
53
|
+
############
|
54
|
+
|
55
|
+
it 'delete and remove are aliases' do
|
56
|
+
::Development::Directory.instance_method( :delete ) == ::Development::Directory.instance_method( :remove )
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can delete a gem by instance' do
|
60
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
61
|
+
gem_instance = ::Development.gem( :gem_name )
|
62
|
+
directory.add( :gem_name )
|
63
|
+
directory.delete( gem_instance )
|
64
|
+
directory.members.should == [ ]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'can delete a gem by name' do
|
68
|
+
directory = ::Development::Directory.new( :name, 'some/path' )
|
69
|
+
gem_instance = ::Development.gem( :gem_name )
|
70
|
+
directory.add( :gem_name )
|
71
|
+
directory.delete( :gem_name )
|
72
|
+
directory.members.should == [ ]
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/development.rb'
|
3
|
+
|
4
|
+
describe ::Development::Gem do
|
5
|
+
|
6
|
+
################
|
7
|
+
# initialize #
|
8
|
+
# directory #
|
9
|
+
################
|
10
|
+
|
11
|
+
it 'can initialize without a directory' do
|
12
|
+
|
13
|
+
gem_instance_without_directory = ::Development::Gem.new( :gem_name )
|
14
|
+
gem_instance_without_directory.name.should == :gem_name
|
15
|
+
gem_instance_without_directory.directory.should == nil
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can initialize with a directory' do
|
20
|
+
|
21
|
+
gem_instance_with_directory = ::Development::Gem.new( :gem_name, 'some/path' )
|
22
|
+
gem_instance_with_directory.name.should == :gem_name
|
23
|
+
directory = gem_instance_with_directory.directory
|
24
|
+
directory.name.should == :gem_name
|
25
|
+
directory.path.should == ::File.expand_path( 'some/path' )
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
################
|
30
|
+
# directory= #
|
31
|
+
################
|
32
|
+
|
33
|
+
it 'can set directy by name' do
|
34
|
+
gem_instance_with_directory = ::Development::Gem.new( :gem_name, 'some/path' )
|
35
|
+
directory = ::Development.directory( :directory_name, 'some/other/path' )
|
36
|
+
gem_instance_with_directory.set_directory( :directory_name )
|
37
|
+
gem_instance_with_directory.directory.should == directory
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can set directy by instance' do
|
41
|
+
gem_instance_with_directory = ::Development::Gem.new( :gem_name, 'some/path' )
|
42
|
+
directory = ::Development.directory( :directory_name, 'some/other/path' )
|
43
|
+
gem_instance_with_directory.set_directory( directory )
|
44
|
+
gem_instance_with_directory.directory.should == directory
|
45
|
+
end
|
46
|
+
|
47
|
+
####################
|
48
|
+
# self.enable! #
|
49
|
+
# self.disable! #
|
50
|
+
# self.enabled? #
|
51
|
+
# self.disabled? #
|
52
|
+
####################
|
53
|
+
|
54
|
+
it 'can enable and disable gems' do
|
55
|
+
some_gem_instance = ::Development.gem( :some_gem )
|
56
|
+
some_gem_instance.enabled?.should == false
|
57
|
+
some_gem_instance.enable!
|
58
|
+
some_gem_instance.enabled?.should == true
|
59
|
+
some_gem_instance.disable!
|
60
|
+
some_gem_instance.enabled?.should == false
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/development.rb'
|
3
|
+
|
4
|
+
describe ::Development::Gemset do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
::Development.clear
|
8
|
+
end
|
9
|
+
|
10
|
+
################
|
11
|
+
# initialize #
|
12
|
+
# name #
|
13
|
+
################
|
14
|
+
|
15
|
+
it 'can initialize with a name and a path' do
|
16
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
17
|
+
gemset_instance.name.should == :name
|
18
|
+
end
|
19
|
+
|
20
|
+
################
|
21
|
+
# directory= #
|
22
|
+
# directory #
|
23
|
+
################
|
24
|
+
|
25
|
+
it 'can set a directory for all gems in set by name' do
|
26
|
+
directory = ::Development.directory( :directory, 'some/path' )
|
27
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
28
|
+
gemset_instance.set_directory( :directory )
|
29
|
+
gemset_instance.directory.should == directory
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'can set a directory for all gems in set by instance' do
|
33
|
+
directory = ::Development.directory( :directory, 'some/path' )
|
34
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
35
|
+
gemset_instance.set_directory( directory )
|
36
|
+
gemset_instance.directory.should == directory
|
37
|
+
end
|
38
|
+
|
39
|
+
#############
|
40
|
+
# add #
|
41
|
+
# members #
|
42
|
+
#############
|
43
|
+
|
44
|
+
it 'can add gems by name that do not already exist in Development definition' do
|
45
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
46
|
+
gemset_instance.add( :gem_name )
|
47
|
+
gemset_instance.members.should == [ ::Development.get_gem( :gem_name ) ]
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'can add gems by name that already exist in Development definition' do
|
51
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
52
|
+
gem_instance = ::Development.gem( :gem_name )
|
53
|
+
gemset_instance.add( :gem_name )
|
54
|
+
gemset_instance.members.should == [ gem_instance ]
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can add gems that already exist in Development definition by instance' do
|
58
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
59
|
+
gem_instance = ::Development.gemset( :gem_name )
|
60
|
+
gemset_instance.add( gem_instance )
|
61
|
+
gemset_instance.members.should == [ gem_instance ]
|
62
|
+
end
|
63
|
+
|
64
|
+
############
|
65
|
+
# delete #
|
66
|
+
# remove #
|
67
|
+
############
|
68
|
+
|
69
|
+
it 'delete and remove are aliases' do
|
70
|
+
::Development::Gemset.instance_method( :delete ) == ::Development::Gemset.instance_method( :remove )
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'can delete a gem by instance' do
|
74
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
75
|
+
gem_instance = ::Development.gemset( :gem_name )
|
76
|
+
gemset_instance.add( :gem_name )
|
77
|
+
gemset_instance.delete( gem_instance )
|
78
|
+
gemset_instance.members.should == [ ]
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can delete a gem by name' do
|
82
|
+
gemset_instance = ::Development::Gemset.new( :name )
|
83
|
+
gem_instance = ::Development.gemset( :gem_name )
|
84
|
+
gemset_instance.add( :gem_name )
|
85
|
+
gemset_instance.delete( :gem_name )
|
86
|
+
gemset_instance.members.should == [ ]
|
87
|
+
end
|
88
|
+
|
89
|
+
####################
|
90
|
+
# self.enable! #
|
91
|
+
# self.disable! #
|
92
|
+
# self.enabled? #
|
93
|
+
# self.disabled? #
|
94
|
+
####################
|
95
|
+
|
96
|
+
it 'can enable and disable all gems and general load path searching' do
|
97
|
+
some_gemset_instance = ::Development.gemset( :some_gemset )
|
98
|
+
some_gemset_instance.enabled?.should == false
|
99
|
+
some_gemset_instance.enable!
|
100
|
+
some_gemset_instance.enabled?.should == true
|
101
|
+
some_gemset_instance.disable!
|
102
|
+
some_gemset_instance.enabled?.should == false
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/spec/development_spec.rb
CHANGED
@@ -2,342 +2,207 @@
|
|
2
2
|
require_relative '../lib/development.rb'
|
3
3
|
|
4
4
|
describe ::Development do
|
5
|
-
|
5
|
+
|
6
6
|
before :each do
|
7
7
|
::Development.clear
|
8
8
|
end
|
9
|
-
|
10
|
-
###########################################
|
11
|
-
# self.parse_named_directory_expression #
|
12
|
-
###########################################
|
13
|
-
|
14
|
-
it 'can parse a named directory expression' do
|
15
|
-
::Proc.new { ::Development.parse_named_directory_expression( '+directory_name' ) }.should raise_error( ::Development::Exception::MalformedExpression::MalformedNamedDirectoryExpression )
|
16
|
-
::Development.parse_named_directory_expression( '+directory_name some/path/from/here' )
|
17
|
-
::Development.directory( :directory_name ).should == ::File.expand_path( 'some/path/from/here' )
|
18
|
-
end
|
19
|
-
|
20
|
-
##################################
|
21
|
-
# self.parse_gemset_expression #
|
22
|
-
##################################
|
23
|
-
|
24
|
-
it 'can parse a gemset expression' do
|
25
|
-
::Development.parse_gemset_expression( '=gemset' )
|
26
|
-
::Development.gemset( :gemset ).should == [ ]
|
27
|
-
::Development.parse_gemset_expression( '=another_gemset some_gem, +some_other_gem, another_gem, -another_gem' )
|
28
|
-
::Development.gemset( :another_gemset ).should == [ :some_gem, :some_other_gem ]
|
29
|
-
::Development.parse_gemset_expression( '=some_other_gemset some_gem +some_other_gem another_gem -another_gem' )
|
30
|
-
::Development.gemset( :some_other_gemset ).should == [ :some_gem, :some_other_gem ]
|
31
|
-
end
|
32
|
-
|
33
|
-
####################################
|
34
|
-
# self.parse_location_expression #
|
35
|
-
####################################
|
36
|
-
|
37
|
-
it 'can parse a location expression' do
|
38
|
-
::Development.parse_named_directory_expression( '+directory_name some/path/from/here' )
|
39
|
-
::Development.directory( :directory_name ).should == ::File.expand_path( 'some/path/from/here' )
|
40
|
-
::Development.parse_named_directory_expression( '+directory_name some/path/from/here' )
|
41
|
-
::Development.parse_location_expression( '@directory_name gem_name, some_other_gem' )
|
42
|
-
::Proc.new { ::Development.parse_location_expression( '@unknown_directory_name gem_name, some_other_gem' ) }.should raise_error( ::Development::Exception::MalformedExpression::UnknownDirectoryName )
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
##########################################
|
47
|
-
# self.parse_enable_disable_expression #
|
48
|
-
##########################################
|
49
9
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
::Development.parse_enable_disable_expression( '!enable some_gem, some_other_gem, some_gemset' )
|
55
|
-
::Development.enabled_for_all?.should == false
|
56
|
-
::Development.enabled_gems.should == [ :some_gem, :some_other_gem, :some_gemset ]
|
57
|
-
::Development.disabled_gems.should == [ ]
|
58
|
-
|
59
|
-
::Development.parse_enable_disable_expression( '!disable some_gem, some_other_gem' )
|
60
|
-
::Development.enabled_for_all?.should == false
|
61
|
-
::Development.enabled_gems.should == [ :some_gemset ]
|
62
|
-
::Development.disabled_gems.should == [ :some_gem, :some_other_gem ]
|
63
|
-
|
64
|
-
::Development.parse_enable_disable_expression( '!enable some_gem, some_other_gem' )
|
65
|
-
::Development.enabled_for_all?.should == false
|
66
|
-
::Development.enabled_gems.should == [ :some_gemset, :some_gem, :some_other_gem ]
|
67
|
-
::Development.disabled_gems.should == [ ]
|
68
|
-
|
69
|
-
::Development.parse_enable_disable_expression( '!disable' )
|
70
|
-
::Development.enabled_for_all?.should == false
|
71
|
-
::Development.enabled_gems.should == [ ]
|
72
|
-
::Development.disabled_gems.should == [ :some_gemset, :some_gem, :some_other_gem ]
|
73
|
-
|
74
|
-
::Development.parse_enable_disable_expression( '!enable' )
|
75
|
-
::Development.enabled_for_all?.should == true
|
76
|
-
::Development.enabled_gems.should == [ :some_gemset, :some_gem, :some_other_gem ]
|
77
|
-
::Development.disabled_gems.should == [ ]
|
78
|
-
|
79
|
-
::Development.parse_enable_disable_expression( '!disable' )
|
80
|
-
::Development.enabled_for_all?.should == false
|
81
|
-
::Development.enabled_gems.should == [ ]
|
82
|
-
::Development.disabled_gems.should == [ :some_gemset, :some_gem, :some_other_gem ]
|
10
|
+
######################################################################################################################
|
11
|
+
# private ##########################################################################################################
|
12
|
+
######################################################################################################################
|
83
13
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
::Development.disabled_gems.should == [ ]
|
14
|
+
#################################
|
15
|
+
# self.path_is_gem_directory? #
|
16
|
+
#################################
|
88
17
|
|
89
|
-
|
90
|
-
::Development.
|
91
|
-
::Development.
|
92
|
-
::Development.disabled_gems.should == [ :some_gem, :some_other_gem, :some_gemset ]
|
93
|
-
|
18
|
+
it 'can find a gem name in a load path, meaning load path specifies the gem directory' do
|
19
|
+
::Development.path_is_gem_directory?( 'spec/mock/require_mock', 'require_mock' ).should == true
|
20
|
+
::Development.path_is_gem_directory?( 'spec/mock/require_mock-submock', 'require_mock/submock' ).should == true
|
94
21
|
end
|
95
|
-
|
96
|
-
####################################################
|
97
|
-
# self.parse_general_load_path_expression #
|
98
|
-
# self.parse_remove_general_load_path_expression #
|
99
|
-
####################################################
|
100
22
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
::Development.general_load_paths.include?( '/path/to/somewhere' ).should == true
|
105
|
-
::Development.parse_remove_general_load_path_expression( '-/path/to/somewhere' )
|
106
|
-
::Development.general_load_paths.include?( '/path/to/somewhere' ).should == false
|
107
|
-
|
108
|
-
::Development.parse_general_load_path_expression( '~/path/to/somewhere' )
|
109
|
-
::Development.general_load_paths.include?( ::File.expand_path( '~/path/to/somewhere' ) ).should == true
|
110
|
-
::Development.parse_remove_general_load_path_expression( '-~/path/to/somewhere' )
|
111
|
-
::Development.general_load_paths.include?( ::File.expand_path( '~/path/to/somewhere' ) ).should == false
|
112
|
-
|
113
|
-
::Development.parse_general_load_path_expression( ::File.expand_path( '../../path/to/somewhere' ) )
|
114
|
-
::Development.general_load_paths.include?( ::File.expand_path( '../../path/to/somewhere' ) ).should == true
|
115
|
-
::Development.parse_remove_general_load_path_expression( '-../../path/to/somewhere' )
|
116
|
-
::Development.general_load_paths.include?( ::File.expand_path( '../../path/to/somewhere' ) ).should == false
|
117
|
-
|
118
|
-
::Development.parse_general_load_path_expression( ::File.expand_path( 'path/to/somewhere' ) )
|
119
|
-
::Development.general_load_paths.include?( ::File.expand_path( 'path/to/somewhere' ) ).should == true
|
120
|
-
::Development.parse_remove_general_load_path_expression( '-path/to/somewhere' )
|
121
|
-
::Development.general_load_paths.include?( ::File.expand_path( 'path/to/somewhere' ) ).should == false
|
23
|
+
#######################################
|
24
|
+
# self.path_contains_gem_directory? #
|
25
|
+
#######################################
|
122
26
|
|
27
|
+
it 'can find a gem name at a load path, meaning load path specifies the directory holding gem directory' do
|
28
|
+
::Development.path_contains_gem_directory?( 'spec/mock', 'require_mock', 'require_mock' ).should == true
|
29
|
+
::Development.path_contains_gem_directory?( 'spec/mock', 'require_mock-submock', 'require_mock/submock' ).should == true
|
123
30
|
end
|
124
31
|
|
125
|
-
|
126
|
-
# self.
|
127
|
-
|
32
|
+
###########################
|
33
|
+
# self.load_gem_in_path #
|
34
|
+
###########################
|
128
35
|
|
129
|
-
it 'can
|
36
|
+
it 'can load a gem from a development path' do
|
130
37
|
|
131
|
-
::Development.
|
132
|
-
::Development.
|
38
|
+
defined?( ::Development::RequireMock ).should == nil
|
39
|
+
::Development.load_gem_in_path( 'spec/mock/require_mock', 'require_mock' )
|
40
|
+
defined?( ::Development::RequireMock ).should == 'constant'
|
133
41
|
|
134
|
-
::Development.
|
135
|
-
::Development.
|
136
|
-
|
137
|
-
::Development.parse_general_directory_or_location_expression( '@named_path/path/to/somewhere' )
|
138
|
-
::Development.general_load_paths.include?( ::File.expand_path( '~/path/to/somewhere/path/to/somewhere' ) ).should == true
|
42
|
+
defined?( ::Development::RequireMock::SubMock ).should == nil
|
43
|
+
::Development.load_gem_in_path( 'spec/mock/require_mock-submock', 'require_mock/submock' )
|
44
|
+
defined?( ::Development::RequireMock::SubMock ).should == 'constant'
|
139
45
|
|
140
46
|
end
|
141
|
-
|
142
|
-
########################################
|
143
|
-
# self.parse_configuration_file_line #
|
144
|
-
########################################
|
145
|
-
|
146
|
-
it 'can parse a line from a file to create an expression from multiple lines' do
|
147
|
-
|
148
|
-
expression_string = ''
|
149
|
-
|
150
|
-
# empty expression, text at beginning of line
|
151
|
-
::Development.parse_configuration_file_line( expression_string, '+named_path path/to/somewhere' ).should == false
|
152
|
-
expression_string.should == '+named_path path/to/somewhere'
|
153
|
-
::Development.parse_configuration_file_line( expression_string, '@named_path some_gem' ).should == true
|
154
|
-
expression_string.should == '+named_path path/to/somewhere'
|
155
|
-
|
156
|
-
expression_string = ''
|
157
|
-
::Development.parse_configuration_file_line( expression_string, '@named_path some_gem' ).should == false
|
158
|
-
expression_string.should == '@named_path some_gem'
|
159
|
-
::Development.parse_configuration_file_line( expression_string, ' some_other_gem' ).should == false
|
160
|
-
expression_string.should == '@named_path some_gem some_other_gem'
|
161
|
-
::Development.parse_configuration_file_line( expression_string, ' another_gem' ).should == false
|
162
|
-
expression_string.should == '@named_path some_gem some_other_gem another_gem'
|
163
|
-
::Development.parse_configuration_file_line( expression_string, ' yet_another_gem' ).should == false
|
164
|
-
expression_string.should == '@named_path some_gem some_other_gem another_gem yet_another_gem'
|
165
|
-
::Development.parse_configuration_file_line( expression_string, '@named_path a_gem' ).should == true
|
166
|
-
expression_string.should == '@named_path some_gem some_other_gem another_gem yet_another_gem'
|
167
|
-
|
168
|
-
# empty expression, comment
|
169
|
-
expression_string = ''
|
170
|
-
::Development.parse_configuration_file_line( expression_string, '# blah blah blah blah' ).should == false
|
171
|
-
expression_string.should == ''
|
172
|
-
|
173
|
-
# part expression, indented text
|
174
|
-
::Development.parse_configuration_file_line( expression_string, '@named_path some_gem' ).should == false
|
175
|
-
::Development.parse_configuration_file_line( expression_string, ' some_other_gem' ).should == false
|
176
47
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
::Development.parse_configuration_file_line( expression_string, ' # blah!' ).should == false
|
181
|
-
::Development.parse_configuration_file_line( expression_string, ' yet_another_gem' ).should == false
|
182
|
-
::Development.parse_configuration_file_line( expression_string, '@named_path some_unnamed_gem' ).should == true
|
183
|
-
|
184
|
-
end
|
48
|
+
######################################################################################################################
|
49
|
+
# public ###########################################################################################################
|
50
|
+
######################################################################################################################
|
185
51
|
|
186
|
-
|
187
|
-
# self.
|
188
|
-
|
52
|
+
########################
|
53
|
+
# self.directory #
|
54
|
+
# self.get_directory #
|
55
|
+
########################
|
189
56
|
|
190
|
-
it 'can
|
57
|
+
it 'can declare directories' do
|
191
58
|
|
192
|
-
|
193
|
-
::Development.parse_configuration_expression( '+directory_name some/path/from/here' )
|
194
|
-
::Development.directory( :directory_name ).should == ::File.expand_path( 'some/path/from/here' )
|
195
|
-
|
196
|
-
# = - gemset expression
|
197
|
-
::Development.parse_configuration_expression( '=another_gemset some_gem, +some_other_gem, another_gem, -another_gem' )
|
198
|
-
::Development.gemset( :another_gemset ).should == [ :some_gem, :some_other_gem ]
|
59
|
+
directory = ::Development.directory( :name, 'some/path' )
|
199
60
|
|
200
|
-
|
201
|
-
::Development.
|
202
|
-
::Development.directory( :directory_name ).should == ::File.expand_path( 'some/path/from/here' )
|
61
|
+
::Development.directory( :name ).should == directory
|
62
|
+
::Development.get_directory( :name ).should == directory
|
203
63
|
|
204
|
-
|
205
|
-
::Development.
|
206
|
-
|
207
|
-
::Development.enabled_gems.should == [ :some_gem, :some_other_gem, :some_gemset ]
|
208
|
-
::Development.disabled_gems.should == [ ]
|
64
|
+
::Development.directory( :name, 'some_other_path' ).should == directory
|
65
|
+
::Development.directory( :name ).should == directory
|
66
|
+
directory.path.should == ::File.expand_path( 'some_other_path' )
|
209
67
|
|
210
|
-
::Development.parse_configuration_expression( '!disable' )
|
211
|
-
::Development.enabled_for_all?.should == false
|
212
|
-
::Development.enabled_gems.should == [ ]
|
213
|
-
::Development.disabled_gems.should == [ :some_gem, :some_other_gem, :some_gemset ]
|
214
|
-
|
215
|
-
# general path expression
|
216
|
-
# - - remove general path
|
217
|
-
::Development.parse_configuration_expression( '/path/to/somewhere' )
|
218
|
-
::Development.general_load_paths.include?( '/path/to/somewhere' ).should == true
|
219
|
-
::Development.parse_configuration_expression( '-/path/to/somewhere' )
|
220
|
-
::Development.general_load_paths.include?( '/path/to/somewhere' ).should == false
|
221
|
-
|
222
68
|
end
|
223
69
|
|
224
|
-
|
225
|
-
# self.
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
::Development.
|
70
|
+
##################
|
71
|
+
# self.gem #
|
72
|
+
# self.get_gem #
|
73
|
+
##################
|
74
|
+
|
75
|
+
it 'can declare gems' do
|
76
|
+
gem_instance = ::Development.gem( :gem_name )
|
77
|
+
::Development.gem( :gem_name ).should == gem_instance
|
78
|
+
::Development.get_gem( :gem_name ).should == gem_instance
|
231
79
|
end
|
232
80
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
::Development.gem_name_at_load_path?( 'spec', 'mock_gem' ).should == true
|
239
|
-
::Development.gem_name_at_load_path?( 'spec', 'mock_gem-subgem' ).should == true
|
81
|
+
it 'can declare gems with a directory' do
|
82
|
+
directory = ::Development.directory( :directory_name, 'some/path' )
|
83
|
+
gem_instance = ::Development.gem( :gem_name, directory )
|
84
|
+
::Development.gem( :gem_name ).should == gem_instance
|
85
|
+
::Development.get_gem( :gem_name ).should == gem_instance
|
240
86
|
end
|
241
87
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
defined?( ::Development::MockGem ).should == nil
|
249
|
-
::Development.load_gem_in_path( 'spec/mock_gem', 'mock_gem' )
|
250
|
-
defined?( ::Development::MockGem ).should == 'constant'
|
251
|
-
|
252
|
-
defined?( ::Development::MockGem::Subgem ).should == nil
|
253
|
-
::Development.load_gem_in_path( 'spec/mock_gem-subgem', 'mock_gem-subgem' )
|
254
|
-
defined?( ::Development::MockGem::Subgem ).should == 'constant'
|
255
|
-
|
88
|
+
it 'can declare gems with a path' do
|
89
|
+
gem_instance = ::Development.gem( :gem_name, 'some/path' )
|
90
|
+
::Development.gem( :gem_name ).should == gem_instance
|
91
|
+
gem_instance.directory.path.should == ::File.expand_path( 'some/path' )
|
92
|
+
::Development.get_gem( :gem_name ).should == gem_instance
|
256
93
|
end
|
257
94
|
|
258
|
-
|
259
|
-
# self.
|
260
|
-
|
261
|
-
|
262
|
-
it 'can load a gem from a development path' do
|
95
|
+
#####################
|
96
|
+
# self.gemset #
|
97
|
+
# self.get_gemset #
|
98
|
+
#####################
|
263
99
|
|
264
|
-
|
265
|
-
::Development.
|
266
|
-
|
100
|
+
it 'can declare gemsets' do
|
101
|
+
gemset_instance = ::Development.gemset( :gemset_name )
|
102
|
+
::Development.gemset( :gemset_name ).should == gemset_instance
|
103
|
+
::Development.get_gemset( :gemset_name ).should == gemset_instance
|
104
|
+
end
|
267
105
|
|
268
|
-
|
269
|
-
::Development.
|
270
|
-
|
271
|
-
|
106
|
+
it 'can declare gemsets with a set of gems' do
|
107
|
+
gemset_instance = ::Development.gemset( :gemset_name, :some_gem, :some_other_gem )
|
108
|
+
::Development.gemset( :gemset_name ).should == gemset_instance
|
109
|
+
gemset_instance.members.should == [ ::Development.gem( :some_gem ), ::Development.gem( :some_other_gem ) ]
|
110
|
+
::Development.get_gemset( :gemset_name ).should == gemset_instance
|
272
111
|
end
|
273
112
|
|
274
|
-
|
275
|
-
# self.
|
276
|
-
|
113
|
+
###################################
|
114
|
+
# self.general_load_path #
|
115
|
+
# self.general_load_paths #
|
116
|
+
# self.remove_general_load_path #
|
117
|
+
###################################
|
277
118
|
|
278
|
-
it 'can
|
279
|
-
|
280
|
-
::Development.
|
281
|
-
|
282
|
-
::Development.
|
283
|
-
|
284
|
-
::Development.gemset( :compositing_objects ).should == [ :"hash-compositing", :"array-compositing", :"array-sorted-compositing", :"array-unique-compositing", :"array-sorted-unique-compositing" ]
|
285
|
-
::Development.gemset( :ridiculous_power ).should == [ :"persistence", :"magnets" ]
|
286
|
-
|
287
|
-
::Development.directory( :code ).should == ::File.expand_path( '~/Projects' )
|
288
|
-
::Development.directory( :ridiculous_power ).should == ::File.expand_path( '~/Projects/rp' )
|
289
|
-
::Development.directory( :ruby ).should == ::File.expand_path( '~/Projects/rp/ruby' )
|
290
|
-
::Development.directory( :hooked_objects ).should == ::File.expand_path( '~/Projects/rp/ruby/hooked_objects' )
|
291
|
-
::Development.directory( :compositing_objects ).should == ::File.expand_path( '~/Projects/rp/ruby/compositing_objects' )
|
119
|
+
it 'can declare and remove general load paths' do
|
120
|
+
::Development.general_load_path( 'some/path' )
|
121
|
+
::Development.general_load_paths.should == [ ::File.expand_path( 'some/path' ) ]
|
122
|
+
::Development.remove_general_load_path( 'some/path' )
|
123
|
+
::Development.general_load_paths.should == [ ]
|
124
|
+
end
|
292
125
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
126
|
+
####################
|
127
|
+
# self.enable! #
|
128
|
+
# self.disable! #
|
129
|
+
# self.enabled? #
|
130
|
+
# self.disabled? #
|
131
|
+
####################
|
132
|
+
|
133
|
+
it 'can enable and disable gems' do
|
134
|
+
some_gem_instance = ::Development.gemset( :some_gem )
|
135
|
+
some_gem_instance.enabled?.should == false
|
136
|
+
some_gemset_instance = ::Development.gemset( :some_gemset )
|
137
|
+
some_gemset_instance.enabled?.should == false
|
138
|
+
::Development.enable!( :some_gem, :some_gemset )
|
139
|
+
some_gemset_instance.enabled?.should == true
|
140
|
+
some_gem_instance.enabled?.should == true
|
141
|
+
::Development.disable!( :some_gem )
|
142
|
+
some_gem_instance.enabled?.should == false
|
143
|
+
some_gemset_instance.enabled?.should == true
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'can enable and disable all gems and general load path searching' do
|
147
|
+
::Development.enable!
|
298
148
|
::Development.enabled_for_all?.should == true
|
299
|
-
|
149
|
+
::Development.disable!
|
150
|
+
::Development.enabled_for_all?.should == false
|
151
|
+
some_gem_instance = ::Development.gemset( :some_gem )
|
152
|
+
some_gem_instance.enabled?.should == false
|
153
|
+
some_gemset_instance = ::Development.gemset( :some_gem )
|
154
|
+
some_gemset_instance.enabled?.should == false
|
155
|
+
::Development.enable!
|
156
|
+
some_gem_instance.enabled?.should == true
|
157
|
+
some_gemset_instance.enabled?.should == true
|
158
|
+
::Development.disable!
|
159
|
+
some_gem_instance.enabled?.should == false
|
160
|
+
some_gemset_instance.enabled?.should == false
|
300
161
|
end
|
301
|
-
|
162
|
+
|
163
|
+
it 'can enable a gem with a path using a hash' do
|
164
|
+
::Development.enable!( 'persistence' => '~/Projects/rp/persistence' )
|
165
|
+
gem_instance = ::Development.gem( :persistence )
|
166
|
+
gem_instance.name.should == :persistence
|
167
|
+
gem_instance.directory.path.should == ::File.expand_path( '~/Projects/rp/persistence' )
|
168
|
+
gem_instance.enabled?.should == true
|
169
|
+
end
|
170
|
+
|
302
171
|
####################
|
303
172
|
# Object.require #
|
304
173
|
####################
|
305
174
|
|
306
175
|
it 'hooks require for registered gems' do
|
307
176
|
|
308
|
-
::Development.
|
309
|
-
::Development.
|
310
|
-
::Development.parse_configuration_expression( '!enable require_mock' )
|
177
|
+
::Development.directory( :directory_name, './spec/mock' ).add( 'require_mock2' )
|
178
|
+
::Development.enable!( 'require_mock2' )
|
311
179
|
|
312
|
-
defined?( ::Development::
|
313
|
-
require '
|
314
|
-
defined?( ::Development::
|
180
|
+
defined?( ::Development::RequireMock2 ).should == nil
|
181
|
+
require 'require_mock2'
|
182
|
+
defined?( ::Development::RequireMock2 ).should == 'constant'
|
315
183
|
|
316
184
|
end
|
317
185
|
|
318
186
|
it 'hooks require for registered gems' do
|
319
187
|
|
320
|
-
::Development.
|
321
|
-
::Development.
|
322
|
-
::Development.parse_configuration_expression( '!enable require_mock2' )
|
188
|
+
::Development.directory( :directory_name, './spec/mock' ).add( 'require_mock3' )
|
189
|
+
::Development.enable!( 'require_mock3' )
|
323
190
|
|
324
|
-
defined?( ::Development::
|
325
|
-
require '
|
326
|
-
defined?( ::Development::
|
191
|
+
defined?( ::Development::RequireMock3 ).should == nil
|
192
|
+
require 'require_mock3'
|
193
|
+
defined?( ::Development::RequireMock3 ).should == 'constant'
|
327
194
|
|
328
195
|
end
|
329
196
|
|
330
197
|
it 'hooks require for enable-all' do
|
331
198
|
|
332
|
-
::Development.
|
333
|
-
::Development.
|
334
|
-
::Development.parse_configuration_expression( '!enable' )
|
199
|
+
::Development.directory( :directory_name, './spec/mock' ).add( 'require_mock4' )
|
200
|
+
::Development.enable!
|
335
201
|
|
336
|
-
defined?( ::Development::
|
337
|
-
require '
|
338
|
-
defined?( ::Development::
|
202
|
+
defined?( ::Development::RequireMock4 ).should == nil
|
203
|
+
require 'require_mock4'
|
204
|
+
defined?( ::Development::RequireMock4 ).should == 'constant'
|
339
205
|
|
340
206
|
end
|
341
207
|
|
342
208
|
end
|
343
|
-
|