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
data/CHANGELOG.md CHANGED
@@ -11,3 +11,6 @@ Directories can now specify either the directory the gem directory is in or the
11
11
  We now support Bundler!
12
12
  Removed all dependencies.
13
13
 
14
+ == 7/10/2012
15
+
16
+ Rewrote for configuration file in Ruby.
data/README.md CHANGED
@@ -45,88 +45,65 @@ I would make project-specific .development files a requirement (to avoid acciden
45
45
 
46
46
  ### Configuration File Example ###
47
47
 
48
- ###
49
- # Ruby 'development' configuration file (.development).
50
- #
51
- # * # denotes comment.
52
- # * Indentation is treated as a line continuation.
53
- # * Items can be separated by , or simply by whitespace.
54
- # * Length of whitespace is irrelevant - contiguous whitespace is "one unit".
55
- #
56
-
57
- ###
58
- # Any lines beginning with plain text (not =, +, -, @, !) will be interpreted as general directory expressions.
59
- # It is not necessary to specify any general directories. Multiple directories may be specified, one per line.
60
- #
61
- # Uncomment the line below to look for directories with gem name in ~/ruby_projects. Any directories specified
62
- # in this way will be used in the case that no explicit specification exists for gem name in question.
63
- #
64
- # ~/ruby_projects
65
-
66
- ###
67
- # Declare a gemset to group a set of gems and configure them by a single reference.
68
- #
69
- # Gems are permitted to be in multiple sets, with first match (from top of .development file downward) winning.
70
- #
71
- # =<gemset_name> gem-name, ...
72
- #
73
-
74
- =ruby module-cluster
75
-
76
- =hooked_objects hash-hooked
77
- array-hooked
78
- array-sorted
79
- array-unique
80
- array-sorted-unique
81
-
82
- =compositing_objects hash-compositing
83
- array-compositing
84
- array-sorted-compositing
85
- array-unique-compositing
86
- array-sorted-unique-compositing
87
-
88
- =ridiculous_power persistence
89
- magnets
90
-
91
- ###
92
- # Declare named locations to associate gems or gemsets with specific locations.
93
- #
94
- # +directory_name path, ...
95
- #
96
- # Paths that begin with @ will interpolate the directory name as the starting portion of the path.
97
- #
98
-
99
- +code ~/Projects
100
- +ridiculous_power @code/rp
101
- +ruby @ridiculous_power/ruby
102
-
103
- +hooked_objects @ruby/hooked_objects
104
- +compositing_objects @ruby/compositing_objects
105
-
106
- ###
107
- # Declare lookup locations for specific gems.
108
- #
109
- # Named paths listed on there own
110
- #
111
-
112
- @hooked_objects hooked_objects
113
- @compositing_objects compositing_objects
114
-
115
- @ridiculous_power ridiculous_power
116
-
117
- ###
118
- # !enable and !disable can be used to cause production gems to be used.
119
- #
120
- # * !enable or !disable on its own will enable or disable all gems and change the default (enabled/disabled),
121
- # after which individual gems can be enabled or disabled.
122
- #
123
- # * !enable or !disable followed by a gem name or a gemset name will enable or disable that gem/gemset.
124
- #
125
- # Nothing is enabled to start. Call !enable to use .development specifications in all cases; after
126
- # !enable individual gems/sets/paths can be enabled/disabled.
127
- #
128
-
129
- !enable
48
+ #### Short Example ####
49
+
50
+ ```ruby
51
+ enable! :parallel_ancestry => '~/Projects/rp/ruby/parallel_ancestry'
52
+ ```
53
+
54
+ #### Extended Example ####
55
+
56
+ ```ruby
57
+ ###
58
+ # Declare named locations to associate gems or gemsets with specific locations.
59
+ # If a directory exists by name of gem or gemset it will be used automatically.
60
+ # Otherwise the directory will have to be declared explicitly.
61
+ #
62
+ directory( :code, '~/Projects' )
63
+
64
+ ###
65
+ # Paths can start with names of other paths.
66
+ #
67
+ directory( :ridiculous_power, :code, 'rp' )
68
+
69
+ directory( :ruby, :ridiculous_power, 'ruby' )
70
+ directory( :hooked_objects, :ruby, 'hooked_objects' )
71
+ directory( :compositing_objects, :ruby, 'compositing_objects' )
72
+
73
+ ###
74
+ # Add gems or gemsets to directory.
75
+ #
76
+ directory( :ridiculous_power ).add( 'persistence', 'magnets' )
77
+
78
+ ###
79
+ # Declare a gemset to group a set of gems and configure them by a single reference.
80
+ #
81
+ gemset( :ruby, 'module-cluster',
82
+ 'parallel_ancestry',
83
+ 'identifies_as' )
84
+
85
+ gemset( :hooked_objects, 'hash-hooked',
86
+ 'array-hooked',
87
+ 'array-sorted',
88
+ 'array-unique',
89
+ 'array-sorted-unique' )
90
+
91
+ gemset( :compositing_objects, 'hash-compositing',
92
+ 'array-compositing',
93
+ 'array-sorted-compositing',
94
+ 'array-unique-compositing',
95
+ 'array-sorted-unique-compositing' )
96
+
97
+ ###
98
+ # Specify directory by gem or gemset.
99
+ #
100
+ gem( 'to_lambda' ).directory( :ruby )
101
+
102
+ ###
103
+ # Enable all (no parameters) or specific gems.
104
+ #
105
+ enable! :ruby, :hooked_objects, :compositing_objects, :parallel_ancestry
106
+ ```
130
107
 
131
108
  # License #
132
109
 
@@ -0,0 +1,123 @@
1
+
2
+ ###
3
+ # @private
4
+ #
5
+ # Interface with Object instance methods for use from configuration file since
6
+ # load cannot load into a context line by line.
7
+ #
8
+ module ::Development::ConfigurationInterface
9
+
10
+ ################
11
+ # gem_method #
12
+ ################
13
+
14
+ ###
15
+ # Define a gem or retrieve defined gem.
16
+ #
17
+ # @param name
18
+ #
19
+ # Name of gem.
20
+ #
21
+ # @param directory_or_path
22
+ #
23
+ # Development::Directory or String describing path.
24
+ #
25
+ # @return [::Development::Gem]
26
+ #
27
+ def gem_method( name, directory_or_path = nil )
28
+ return ::Development.gem( name, directory_or_path )
29
+ end
30
+
31
+ ############
32
+ # gemset #
33
+ ############
34
+
35
+ ###
36
+ # Define a gem or retrieve defined gem.
37
+ #
38
+ # @overload self.gemset( name, gem_or_gemset, ... )
39
+ #
40
+ # @param name
41
+ #
42
+ # Name of gemset.
43
+ #
44
+ # @param gem_or_gemset
45
+ #
46
+ # Gem or Gemset name or instance.
47
+ #
48
+ # @return [::Development::Gemset]
49
+ #
50
+ def gemset( name, *gems_or_gemsets )
51
+ return ::Development.gemset( name, *gems_or_gemsets )
52
+ end
53
+
54
+ ###############
55
+ # directory #
56
+ ###############
57
+
58
+ ###
59
+ # Return path for directory name.
60
+ #
61
+ # @overload self.directory( name, path, gem_or_gemset, ... )
62
+ #
63
+ # @param directory_name
64
+ #
65
+ # Name of named directory.
66
+ #
67
+ # @param path
68
+ #
69
+ # String describing directory path.
70
+ #
71
+ # @param gem_or_gemset
72
+ #
73
+ # Gem or Gemset or String or Symbol describing Gem or Gemset.
74
+ #
75
+ # @return [::Development::Directory] Directory.
76
+ #
77
+ def directory( name, *path_parts )
78
+ return ::Development.directory( name, *path_parts )
79
+ end
80
+
81
+ #############
82
+ # enable! #
83
+ #############
84
+
85
+ ###
86
+ # Enable gems.
87
+ #
88
+ # @overload enable!
89
+ #
90
+ # @overload enable( gem_or_gemset, ... )
91
+ #
92
+ # @param gem_or_gemset
93
+ #
94
+ # Gem or Gemset instance or name to enable.
95
+ #
96
+ # @return [::Development] Self.
97
+ #
98
+ def enable!( *gem_or_gemset_names )
99
+ return ::Development.enable!( *gem_or_gemset_names )
100
+ end
101
+
102
+ ##############
103
+ # disable! #
104
+ ##############
105
+
106
+ ###
107
+ # Disable gems.
108
+ #
109
+ # @overload disable!
110
+ #
111
+ # @overload disable( gem_or_gemset, ... )
112
+ #
113
+ # @param gem_or_gemset
114
+ #
115
+ # Gem or Gemset instance or name to disable.
116
+ #
117
+ # @return [::Development] Self.
118
+ #
119
+ def disable!( *gem_or_gemset_names )
120
+ return ::Development.disable!( *gem_or_gemset_names )
121
+ end
122
+
123
+ end
@@ -0,0 +1,165 @@
1
+
2
+ ###
3
+ # Interface for directory implementation. Implementation provided separately for ease of overloading.
4
+ #
5
+ module ::Development::Directory::DirectoryInterface
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 path_part
20
+ #
21
+ # Part of path; the first can be a symbol referring to a named path or a string,
22
+ # all other parts must be strings.
23
+ #
24
+ def initialize( name, *path_parts )
25
+
26
+ @name = name
27
+
28
+ self.set_path( *path_parts )
29
+
30
+ # a directory is also a gemset
31
+ @gemset = ::Development.gemset( name )
32
+ @gemset.set_directory( self )
33
+
34
+ # if there's a gem or gemset name by this directory name,
35
+ # we use it unless gem or gemset already has a directory
36
+ if name
37
+ if gem_instance = ::Development.get_gem( name )
38
+ gem_instance.set_directory( self )
39
+ end
40
+
41
+ if gemset_instance = ::Development.get_gemset( name )
42
+ gemset_instance.set_directory( self )
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ ##########
49
+ # name #
50
+ ##########
51
+
52
+ ###
53
+ # Name.
54
+ #
55
+ # @!attribute [reader] Name.
56
+ #
57
+ attr_reader :name
58
+
59
+ #############
60
+ # members #
61
+ #############
62
+
63
+ ###
64
+ # Gems or Gemsets with self as their directory.
65
+ #
66
+ # @return [Array<::Development::Gem,::Development::Gemset>] Members
67
+ #
68
+ def members
69
+
70
+ return @gemset.members
71
+
72
+ end
73
+
74
+ ##########
75
+ # path #
76
+ ##########
77
+
78
+ ###
79
+ # Path.
80
+ #
81
+ # @!attribute [reader] Name.
82
+ #
83
+ attr_reader :path
84
+
85
+ ##############
86
+ # set_path #
87
+ ##############
88
+
89
+ ###
90
+ # Set Path.
91
+ #
92
+ # @param path
93
+ #
94
+ # Path string.
95
+ #
96
+ # @return [::Development::Directory] Self.
97
+ #
98
+ def set_path( *path_parts )
99
+
100
+ if path_parts[ 0 ].is_a?( ::Symbol )
101
+ base_directory_name = path_parts[ 0 ]
102
+ base_directory = ::Development.get_directory( base_directory_name )
103
+ path_parts[ 0 ] = base_directory.path
104
+ end
105
+
106
+ path_parts.collect!( & :to_s )
107
+
108
+ if path_parts[ 0 ].nil?
109
+ @path = nil
110
+ else
111
+ @path = ::File.expand_path( ::File.join( *path_parts ) )
112
+ end
113
+
114
+ return self
115
+
116
+ end
117
+
118
+ #########
119
+ # add #
120
+ #########
121
+
122
+ ###
123
+ # Add gems or gemsets to directory.
124
+ #
125
+ # @overload add( gem_or_gemset, ... )
126
+ #
127
+ # @param gem_or_gemset
128
+ #
129
+ # Gem or Gemset instance or name to add to directory.
130
+ #
131
+ # @return [::Development::Directory] Self.
132
+ #
133
+ def add( *gems_or_gemsets )
134
+
135
+ @gemset.add( *gems_or_gemsets )
136
+
137
+ return self
138
+
139
+ end
140
+
141
+ ############
142
+ # delete #
143
+ # remove #
144
+ ############
145
+
146
+ ###
147
+ # Remove gems or gemsets from directory.
148
+ #
149
+ # @overload delete( gem_or_gemset, ... )
150
+ #
151
+ # @param gem_or_gemset
152
+ #
153
+ # Gem or Gemset instance or name to add to directory.
154
+ #
155
+ # @return [::Development::Directory] Self.
156
+ #
157
+ def delete( *gems_or_gemsets )
158
+
159
+ return @gemset.delete( *gems_or_gemsets )
160
+
161
+ end
162
+
163
+ alias_method :remove, :delete
164
+
165
+ end
@@ -0,0 +1,9 @@
1
+
2
+ ###
3
+ # Directory class.
4
+ #
5
+ class ::Development::Directory
6
+
7
+ include ::Development::Directory::DirectoryInterface
8
+
9
+ end