sprout 1.0.32.pre → 1.0.35.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

Files changed (208) hide show
  1. data/Gemfile +2 -1
  2. data/Gemfile.lock +4 -2
  3. data/README.textile +12 -13
  4. data/VERSION +1 -0
  5. data/doc/Dir.html +288 -0
  6. data/doc/Rake/Task.html +184 -0
  7. data/doc/Sprout.html +144 -0
  8. data/doc/Sprout/ArchiveUnpacker.html +1246 -0
  9. data/doc/Sprout/Base.html +126 -0
  10. data/doc/Sprout/Base/ClassMethods.html +434 -0
  11. data/doc/Sprout/Concern.html +353 -0
  12. data/doc/Sprout/Daemon.html +166 -0
  13. data/doc/Sprout/Daemon/ClassMethods.html +244 -0
  14. data/doc/Sprout/Daemon/InstanceMethods.html +601 -0
  15. data/doc/Sprout/Errors.html +101 -0
  16. data/doc/Sprout/Errors/ArchiveUnpackerError.html +125 -0
  17. data/doc/Sprout/Errors/DestinationExistsError.html +133 -0
  18. data/doc/Sprout/Errors/DuplicateMemberError.html +132 -0
  19. data/doc/Sprout/Errors/ExecutableError.html +125 -0
  20. data/doc/Sprout/Errors/ExecutableRegistrationError.html +132 -0
  21. data/doc/Sprout/Errors/ExecutionError.html +121 -0
  22. data/doc/Sprout/Errors/GeneratorError.html +125 -0
  23. data/doc/Sprout/Errors/InvalidArgumentError.html +132 -0
  24. data/doc/Sprout/Errors/LoadError.html +121 -0
  25. data/doc/Sprout/Errors/MissingArgumentError.html +132 -0
  26. data/doc/Sprout/Errors/MissingExecutableError.html +132 -0
  27. data/doc/Sprout/Errors/MissingGeneratorError.html +132 -0
  28. data/doc/Sprout/Errors/MissingTemplateError.html +132 -0
  29. data/doc/Sprout/Errors/ProcessRunnerError.html +121 -0
  30. data/doc/Sprout/Errors/RemoteFileLoaderError.html +110 -0
  31. data/doc/Sprout/Errors/SproutError.html +114 -0
  32. data/doc/Sprout/Errors/UnknownArchiveType.html +122 -0
  33. data/doc/Sprout/Errors/UsageError.html +121 -0
  34. data/doc/Sprout/Errors/ValidationError.html +121 -0
  35. data/doc/Sprout/Errors/VersionRequirementNotMetError.html +121 -0
  36. data/doc/Sprout/Executable.html +173 -0
  37. data/doc/Sprout/Executable/Boolean.html +483 -0
  38. data/doc/Sprout/Executable/ClassMethods.html +417 -0
  39. data/doc/Sprout/Executable/CollectionParam.html +483 -0
  40. data/doc/Sprout/Executable/FileParam.html +484 -0
  41. data/doc/Sprout/Executable/Files.html +292 -0
  42. data/doc/Sprout/Executable/InstanceMethods.html +2006 -0
  43. data/doc/Sprout/Executable/Number.html +141 -0
  44. data/doc/Sprout/Executable/Param.html +2818 -0
  45. data/doc/Sprout/Executable/ParameterFactory.html +232 -0
  46. data/doc/Sprout/Executable/Path.html +223 -0
  47. data/doc/Sprout/Executable/Paths.html +253 -0
  48. data/doc/Sprout/Executable/StringParam.html +213 -0
  49. data/doc/Sprout/Executable/Strings.html +167 -0
  50. data/doc/Sprout/Executable/Url.html +160 -0
  51. data/doc/Sprout/Executable/Urls.html +170 -0
  52. data/doc/Sprout/FileTarget.html +1109 -0
  53. data/doc/Sprout/Generator.html +689 -0
  54. data/doc/Sprout/Generator/Base.html +1626 -0
  55. data/doc/Sprout/Generator/Command.html +690 -0
  56. data/doc/Sprout/Generator/DirectoryManifest.html +476 -0
  57. data/doc/Sprout/Generator/FileManifest.html +572 -0
  58. data/doc/Sprout/Generator/Manifest.html +377 -0
  59. data/doc/Sprout/Generator/TemplateManifest.html +196 -0
  60. data/doc/Sprout/GeneratorGenerator.html +1018 -0
  61. data/doc/Sprout/Library.html +1141 -0
  62. data/doc/Sprout/LibraryGenerator.html +309 -0
  63. data/doc/Sprout/Log.html +496 -0
  64. data/doc/Sprout/MXMLC.html +6373 -0
  65. data/doc/Sprout/Platform.html +714 -0
  66. data/doc/Sprout/ProcessRunner.html +1352 -0
  67. data/doc/Sprout/ProgressBar.html +376 -0
  68. data/doc/Sprout/ProgressBarImpl.html +2119 -0
  69. data/doc/Sprout/ProgressBarManager.html +434 -0
  70. data/doc/Sprout/ProgressBarOutputStream.html +416 -0
  71. data/doc/Sprout/RDocParser.html +211 -0
  72. data/doc/Sprout/RemoteFileLoader.html +172 -0
  73. data/doc/Sprout/RemoteFileTarget.html +679 -0
  74. data/doc/Sprout/ReversedProgressBar.html +194 -0
  75. data/doc/Sprout/RubyFeature.html +155 -0
  76. data/doc/Sprout/RubyFeature/ClassMethods.html +1065 -0
  77. data/doc/Sprout/RubyGenerator.html +764 -0
  78. data/doc/Sprout/Specification.html +767 -0
  79. data/doc/Sprout/System.html +191 -0
  80. data/doc/Sprout/System/BaseSystem.html +1455 -0
  81. data/doc/Sprout/System/JavaSystem.html +122 -0
  82. data/doc/Sprout/System/OSXSystem.html +335 -0
  83. data/doc/Sprout/System/ThreadMock.html +193 -0
  84. data/doc/Sprout/System/UnixSystem.html +584 -0
  85. data/doc/Sprout/System/VistaSystem.html +251 -0
  86. data/doc/Sprout/System/WinNixSystem.html +325 -0
  87. data/doc/Sprout/System/WinSystem.html +571 -0
  88. data/doc/Sprout/ToolGenerator.html +931 -0
  89. data/doc/Sprout/VERSION.html +128 -0
  90. data/doc/SproutTestCase.html +1412 -0
  91. data/doc/String.html +286 -0
  92. data/doc/_index.html +1035 -0
  93. data/doc/class_list.html +36 -0
  94. data/doc/css/common.css +1 -0
  95. data/doc/css/full_list.css +53 -0
  96. data/doc/css/style.css +310 -0
  97. data/doc/file.README.html +96 -0
  98. data/doc/file.archive_unpacker.html +288 -0
  99. data/doc/file.base.html +208 -0
  100. data/doc/file.base_system.html +278 -0
  101. data/doc/file.boolean.html +135 -0
  102. data/doc/file.collection_param.html +139 -0
  103. data/doc/file.command.html +126 -0
  104. data/doc/file.concern.html +136 -0
  105. data/doc/file.daemon.html +309 -0
  106. data/doc/file.dir.html +76 -0
  107. data/doc/file.directory_manifest.html +122 -0
  108. data/doc/file.errors.html +147 -0
  109. data/doc/file.executable.html +638 -0
  110. data/doc/file.file_manifest.html +109 -0
  111. data/doc/file.file_param.html +120 -0
  112. data/doc/file.file_target.html +140 -0
  113. data/doc/file.files.html +85 -0
  114. data/doc/file.generator.html +296 -0
  115. data/doc/file.generator_class.html +72 -0
  116. data/doc/file.generator_generator.html +137 -0
  117. data/doc/file.generator_test.html +92 -0
  118. data/doc/file.generator_test_helper.html +67 -0
  119. data/doc/file.java_system.html +62 -0
  120. data/doc/file.library.html +291 -0
  121. data/doc/file.library_generator.html +74 -0
  122. data/doc/file.log.html +100 -0
  123. data/doc/file.manifest.html +67 -0
  124. data/doc/file.mxmlc.html +740 -0
  125. data/doc/file.number.html +67 -0
  126. data/doc/file.osx_system.html +79 -0
  127. data/doc/file.param.html +491 -0
  128. data/doc/file.parameter_factory.html +119 -0
  129. data/doc/file.path.html +81 -0
  130. data/doc/file.paths.html +80 -0
  131. data/doc/file.platform.html +124 -0
  132. data/doc/file.process_runner.html +224 -0
  133. data/doc/file.progress_bar.html +390 -0
  134. data/doc/file.rdoc_parser.html +145 -0
  135. data/doc/file.remote_file_loader.html +117 -0
  136. data/doc/file.remote_file_target.html +176 -0
  137. data/doc/file.ruby_base.html +64 -0
  138. data/doc/file.ruby_feature.html +244 -0
  139. data/doc/file.ruby_generator.html +118 -0
  140. data/doc/file.ruby_input.html +62 -0
  141. data/doc/file.ruby_test_case.html +78 -0
  142. data/doc/file.ruby_test_helper.html +61 -0
  143. data/doc/file.specification.html +248 -0
  144. data/doc/file.sprout.html +64 -0
  145. data/doc/file.sprout_test_case.html +280 -0
  146. data/doc/file.string.html +72 -0
  147. data/doc/file.string_param.html +76 -0
  148. data/doc/file.strings.html +71 -0
  149. data/doc/file.system.html +86 -0
  150. data/doc/file.template_manifest.html +67 -0
  151. data/doc/file.tool.html +92 -0
  152. data/doc/file.tool_generator.html +90 -0
  153. data/doc/file.unix_system.html +128 -0
  154. data/doc/file.url.html +71 -0
  155. data/doc/file.urls.html +70 -0
  156. data/doc/file.version.html +71 -0
  157. data/doc/file.vista_system.html +69 -0
  158. data/doc/file.win_nix_system.html +88 -0
  159. data/doc/file.win_system.html +129 -0
  160. data/doc/file_list.html +230 -0
  161. data/doc/frames.html +13 -0
  162. data/doc/index.html +96 -0
  163. data/doc/js/app.js +202 -0
  164. data/doc/js/full_list.js +149 -0
  165. data/doc/js/jquery.js +154 -0
  166. data/doc/method_list.html +3355 -0
  167. data/doc/top-level-namespace.html +192 -0
  168. data/lib/sprout/archive_unpacker.rb +203 -137
  169. data/lib/sprout/base.rb +38 -11
  170. data/lib/sprout/concern.rb +51 -0
  171. data/lib/sprout/daemon.rb +256 -0
  172. data/lib/sprout/executable.rb +40 -11
  173. data/lib/sprout/executable/boolean.rb +47 -1
  174. data/lib/sprout/executable/collection_param.rb +33 -1
  175. data/lib/sprout/executable/file_param.rb +16 -3
  176. data/lib/sprout/executable/files.rb +5 -0
  177. data/lib/sprout/executable/number.rb +5 -1
  178. data/lib/sprout/executable/param.rb +232 -16
  179. data/lib/sprout/executable/parameter_factory.rb +39 -1
  180. data/lib/sprout/executable/path.rb +7 -1
  181. data/lib/sprout/executable/paths.rb +6 -1
  182. data/lib/sprout/executable/string_param.rb +8 -1
  183. data/lib/sprout/executable/strings.rb +7 -1
  184. data/lib/sprout/executable/url.rb +8 -1
  185. data/lib/sprout/executable/urls.rb +7 -1
  186. data/lib/sprout/file_target.rb +11 -11
  187. data/lib/sprout/generator.rb +244 -0
  188. data/lib/sprout/generator/base.rb +0 -94
  189. data/lib/sprout/generators/generator/generator_generator.rb +35 -1
  190. data/lib/sprout/generators/generator/templates/generator_class.rb +3 -3
  191. data/lib/sprout/library.rb +75 -0
  192. data/lib/sprout/log.rb +11 -12
  193. data/lib/sprout/process_runner.rb +29 -9
  194. data/lib/sprout/remote_file_target.rb +20 -9
  195. data/lib/sprout/system/base_system.rb +11 -3
  196. data/lib/sprout/test/sprout_test_case.rb +1 -0
  197. data/lib/sprout/version.rb +7 -11
  198. data/rakefile.rb +7 -12
  199. data/script/add_param_handler.rb +43 -0
  200. data/sprout.gemspec +2 -3
  201. data/test/fixtures/executable/fdb.rb +764 -0
  202. data/test/fixtures/executable/flex3sdk_gem/fdb +60 -0
  203. data/test/fixtures/executable/mxmlc.rb +9 -11
  204. data/test/unit/daemon_test.rb +61 -0
  205. data/test/unit/process_runner_test.rb +21 -0
  206. data/test/unit/remote_file_target_test.rb +45 -11
  207. data/test/unit/sprout_test_helper.rb +1 -1
  208. metadata +210 -29
@@ -2,17 +2,55 @@
2
2
  module Sprout::Executable
3
3
 
4
4
  ##
5
- # A factory to create concrete Executable::Param
5
+ # A factory to create concrete Sprout::Executable::Param
6
6
  # entities from a set of known types.
7
7
  #
8
8
  # If an unrecognized Class reference is provided
9
9
  # we will instantiate it and ensure that it
10
10
  # responds to the public members of the
11
11
  # Executable::Param interface.
12
+ #
13
+ # This Factory gives you the ability to create new,
14
+ # custom parameter types by simply ensuring they are
15
+ # available to Ruby before your executable is
16
+ # interpreted.
17
+ #
18
+ # Following is an example of a custom Parameter:
19
+ #
20
+ # class CustomParam < Sprout::Executable::Param
21
+ #
22
+ # def to_shell
23
+ # "--foo-bar=#{value}"
24
+ # end
25
+ # end
26
+ #
27
+ # Following is an example Executable that can consume
28
+ # the above parameter:
29
+ #
30
+ # require 'custom_param'
31
+ #
32
+ # class Foo
33
+ # include Sprout::Executable
34
+ #
35
+ # add_param :name, CustomParam
36
+ #
37
+ # end
38
+ #
39
+ # That's it, there is no need to register your custom types
40
+ # with the Factory, just get it into your load path and
41
+ # require it.
42
+ #
12
43
  class ParameterFactory
13
44
 
14
45
  class << self
15
46
 
47
+ ##
48
+ # This factory allows us to use classes by
49
+ # reference in the Executable interface.
50
+ # Since there are already Ruby primitives for
51
+ # String and File and we don't want to clobber
52
+ # them, we use this factory to convert those
53
+ # to the appropriate types.
16
54
  def create type
17
55
  # Didn't want to clobber the stdlib references
18
56
  # to these two important data types...
@@ -3,7 +3,13 @@ module Sprout
3
3
  module Executable
4
4
 
5
5
  ##
6
- # Concrete param object for :path values
6
+ # Concrete Sprout::Executable::Param object for Path values.
7
+ #
8
+ # Path parameters will create a FileList of prerequisites by concatenating the value with
9
+ # the +file_expression+ that is set on the parameter or Sprout::Executable.
10
+ #
11
+ # @see Sprout::Executable::Param
12
+ #
7
13
  class Path < Executable::Param
8
14
 
9
15
  def prepare_prerequisites
@@ -3,7 +3,12 @@ module Sprout
3
3
  module Executable
4
4
 
5
5
  ##
6
- # Concrete param object for collections of paths
6
+ # A collection of Paths.
7
+ #
8
+ # @see Sprout::Executable::Path
9
+ # @see Sprout::Executable::Param
10
+ # @see Sprout::Executable::CollectionParam
11
+ #
7
12
  class Paths < Files
8
13
 
9
14
  def prepare_prerequisites
@@ -2,7 +2,14 @@ module Sprout
2
2
 
3
3
  module Executable
4
4
 
5
- # Concrete param object for :string values
5
+ ##
6
+ # A parameter with a String value.
7
+ #
8
+ # Any spaces in the value will be escaped when
9
+ # returned to a shell.
10
+ #
11
+ # @see Sprout::Executable::Param
12
+ #
6
13
  class StringParam < Executable::Param
7
14
 
8
15
  def shell_value
@@ -2,7 +2,13 @@ module Sprout
2
2
 
3
3
  module Executable
4
4
 
5
- # Concrete param object for collections of strings
5
+ ##
6
+ # A collection of String values.
7
+ #
8
+ # @see Sprout::Executable::String
9
+ # @see Sprout::Executable::Param
10
+ # @see Sprout::Executable::CollectionParam
11
+ #
6
12
  class Strings < Executable::Param
7
13
  include CollectionParam
8
14
  end
@@ -2,7 +2,14 @@ module Sprout
2
2
 
3
3
  module Executable
4
4
 
5
- # Concrete param object for collections of files
5
+ ##
6
+ # A parameter that represents a URL.
7
+ #
8
+ # @see Sprout::Executable::Param
9
+ #
10
+ # TODO: Should provide some custom validations for values
11
+ # that should be a URL.
12
+ #
6
13
  class Url < StringParam
7
14
  end
8
15
  end
@@ -2,7 +2,13 @@ module Sprout
2
2
 
3
3
  module Executable
4
4
 
5
- # Concrete param object for collections of files
5
+ ##
6
+ # Collection of URL values.
7
+ #
8
+ # @see Sprout::Executable::Url
9
+ # @see Sprout::Executable::Param
10
+ # @see Sprout::Executable::CollectionParam
11
+ #
6
12
  class Urls < Strings
7
13
  end
8
14
  end
@@ -36,29 +36,29 @@ module Sprout
36
36
  end
37
37
 
38
38
  ##
39
- # Add a library to the RubyGem package.
40
- #
41
- # @name Symbol that will be used to retrieve this library later.
42
- # @path File, Path or Array of files that will be associated with this
43
- # library and copied to the target lib.
44
- #
45
- # If the path is a directory, all files forward of that directory
46
- # will be copied into the RubyGem.
39
+ # Add a library to the package.
47
40
  #
41
+ # @return [Sprout::Library] The newly created library that was added.
42
+ # @param name [Symbol] Name that will be used to retrieve this library on +load+.
43
+ # @param path [File, Path, Array] File or files that will be associated with
44
+ # this library and copied into the target project library folder when loaded.
45
+ # (If the path is a directory, all files forward of that directory will be included.)
48
46
  def add_library name, path
49
47
  if path.is_a?(Array)
50
48
  path = path.collect { |p| expand_local_path(p) }
51
49
  else
52
50
  path = expand_local_path path
53
51
  end
54
- libraries << Sprout::Library.new( :name => name, :path => path, :file_target => self )
52
+ library = Sprout::Library.new( :name => name, :path => path, :file_target => self )
53
+ libraries << library
54
+ library
55
55
  end
56
56
 
57
57
  ##
58
58
  # Add an executable to the RubyGem package.
59
59
  #
60
- # @name Symbol that will be used to retrieve this executable later.
61
- # @target The relative path to the executable that will be associated
60
+ # @param name [Symbol] that will be used to retrieve this executable later.
61
+ # @param path [File] relative path to the executable that will be associated
62
62
  # with this name.
63
63
  #
64
64
  def add_executable name, path
@@ -0,0 +1,244 @@
1
+ require 'sprout/generator/base'
2
+ require 'sprout/generator/command'
3
+ require 'sprout/generator/manifest'
4
+ require 'sprout/generator/file_manifest'
5
+ require 'sprout/generator/template_manifest'
6
+ require 'sprout/generator/directory_manifest'
7
+
8
+ module Sprout
9
+
10
+ ##
11
+ #
12
+ # = Introduction
13
+ #
14
+ # Sprout Generators are command line applications that are
15
+ # installed by RubyGems and should universally provide the
16
+ # following features:
17
+ #
18
+ # * Terminal tab completion to discover generators
19
+ # * Call with no arguments to see help output
20
+ # * Call with an +--input+ (or trailing) argument to create
21
+ # * Call with a collection of arguments given on a previous run
22
+ # plus +--delete+ to undo a previous +create+
23
+ #
24
+ # = Usage
25
+ #
26
+ # == Discovery
27
+ #
28
+ # Sprout generators should be installed by RubyGems as command line
29
+ # applications on your system. After installing the flashsdk gem, you
30
+ # should have access to a variety of generators. You can find out what
31
+ # generators are available by typing: sprout- followed by pressing the
32
+ # <TAB> key.
33
+ #
34
+ # Your terminal should list out all available applications that match
35
+ # this name.
36
+ #
37
+ # Some generators are expected to create new projects, others expect to
38
+ # run within existing projects. You should be able to infer the kind of
39
+ # generator you're looking at by the name, but if you can't just run the
40
+ # generator with no arguments to see it's usage guidelines.
41
+ #
42
+ # Generators that expect to be run from within a project will usually
43
+ # expect a file named +Gemfile+ to exist in the project root. If you're
44
+ # trying to run Sprout generators in a project that wasn't created using
45
+ # Sprouts, create this file and add the Rubygems that include the
46
+ # generators that you want to use.
47
+ #
48
+ # == Execution
49
+ #
50
+ # Generators are created by human beings and sometimes they have
51
+ # different assumptions than you do. If you're running a generator
52
+ # within a project (especially for the first time - or since updating a
53
+ # gem), be sure to get your project checked into version control before
54
+ # running anything.
55
+ #
56
+ # Non-application generators should always be executed at the project
57
+ # root (where you store your Rakefile, Gemfile or build.xml).
58
+ #
59
+ # == Deletion
60
+ #
61
+ # Any generator that inherits from the provided Sprout::Generators::Base
62
+ # includes support for deletion. If you run a generator and realize that
63
+ # you don't want the files that it created, you can always run the same
64
+ # generator again with the same arguments, but add the --delete (or -d)
65
+ # argument.
66
+ #
67
+ # == Templates
68
+ #
69
+ # Each time a generator is asked to locate a template, it begins a lookup
70
+ # process. This process is designed to make it easy for you to modify any
71
+ # template at the scope you desire.
72
+ #
73
+ # The lookup process will end at the first location where the expected
74
+ # file is found.
75
+ #
76
+ # The search will begin with the location specified by the +-templates+
77
+ # option (if provided) and will continue by adding '/templates' to the
78
+ # end of each location specified by the listing for
79
+ # Sprout::Generator#search_paths .
80
+ #
81
+ # = Creation
82
+ #
83
+ # The core Sprout gem comes with a Sprout::GeneratorGenerator. This command line
84
+ # application is intended to be executed within a project and given the name
85
+ # of a generator that you'd like to create.
86
+ #
87
+ # Try experimenting with this, and please
88
+ # suggest[http://groups.google.com/group/projectsprouts/] any improvements to
89
+ # the Google Group.
90
+ #
91
+ # ---
92
+ #
93
+ # Back to Home: {file:README.textile}
94
+ #
95
+ # Next Topic: {Sprout::Library}
96
+ #
97
+ # ---
98
+ #
99
+ # @see Sprout::GeneratorGenerator
100
+ # @see Sprout::Library
101
+ # @see Sprout::Executable
102
+ # @see Sprout::Specification
103
+ # @see Sprout::RubyFeature
104
+ # @see Sprout::System
105
+ #
106
+ module Generator
107
+ include RubyFeature
108
+
109
+ class << self
110
+
111
+ ##
112
+ # Register a generator class and template path for future use.
113
+ # Generator class names must end with "Generator", and everything
114
+ # to the left will be used for future lookups.
115
+ #
116
+ # The following example will register a TestGenerator that can be
117
+ # retrieved as +:test+.
118
+ #
119
+ # Sprout::Generator.register TestGenerator
120
+ #
121
+ # @param generator_class [Class] A reference to the concrete Generator class.
122
+ # Usually these classes extend Sprout::Generator::Base.
123
+ # @param templates_path [Directory] The path to the default templates that should
124
+ # be used for this generator. By default, a folder named +templates+ relative to
125
+ # the class definition will be used. Templates will also be searched for in a variety
126
+ # of locations depending on the user system. This path is simply the final searching
127
+ # point.
128
+ # @return [Hash] the entity that was stored to represent the provided Generator.
129
+ # The entity will generally have the keys, :class and :templates.
130
+ def register generator_class, templates_path=nil
131
+ generator_paths << { :class => generator_class, :templates => templates_path } unless templates_path.nil?
132
+ super(generator_class)
133
+ end
134
+
135
+ ##
136
+ # Create an instance of a concrete Generator using a +type+ argument.
137
+ #
138
+ # The idea is that libraries may register a generator class named,
139
+ # +TestGenerator+, and other generators can instantiate it without
140
+ # including it's Class by reference with:
141
+ #
142
+ # Sprout::Generator.create_instance :test
143
+ #
144
+ # @param type [Symbol] A snake-cased name of the class without the Generator suffix.
145
+ # for example, to instantiate a generator named, +TestSuiteGenerator+, this argument
146
+ # would be +:test_suite+
147
+ # @param options [Hash] deprecated - please remove this argument wherever it's found.
148
+ def create_instance type, options=nil
149
+ class_name = "#{type.to_s.camel_case}Generator"
150
+ registered_entities.each do |entity|
151
+ if(entity.to_s.match(/::#{class_name}$/) || entity.to_s.match(/^#{class_name}$/))
152
+ return entity.new
153
+ end
154
+ end
155
+ raise Sprout::Errors::MissingGeneratorError.new "Could not find any generator named: (#{class_name}). Perhaps you need to add a RubyGem to your Gemfile?"
156
+ end
157
+
158
+ ##
159
+ # Retrieve the root template folder for the provided Class.
160
+ #
161
+ # This method will look for a templates folder next to
162
+ # each superclass in the inheritance chain.
163
+ #
164
+ def template_folder_for clazz
165
+ # Search the potential matches in reverse order
166
+ # because subclasses have registered AFTER their
167
+ # superclasses and superclasses match the ===
168
+ # check...
169
+ generator_paths.reverse.each do |options|
170
+ if options[:class] === clazz
171
+ return options[:templates]
172
+ end
173
+ end
174
+ nil
175
+ end
176
+
177
+ ##
178
+ # Returns a new collection of paths to search within for generator
179
+ # declarations and more importantly, folders named, 'templates'.
180
+ #
181
+ # The collection of search_paths will be a subset of the following
182
+ # that will include only those directories that exist:
183
+ #
184
+ # ./config/generators
185
+ # ./vendor/generators
186
+ # ~/Library/Sprouts/1.0/generators # OS X only
187
+ # ~/.sprouts/1.0/generators # Unix only
188
+ # [USER_HOME]/Application Data/Sprouts/cache/1.0/generators # Windows only
189
+ # ENV['SPROUT_GENERATORS'] # Only if defined
190
+ # [Generator Declaration __FILE__]
191
+ # [Generator SUPER-class declaration __FILE__]
192
+ # [Repeat step above until there is no super-class]
193
+ #
194
+ # When the generators attempt to resolve templates, each of the preceding
195
+ # folders will be scanned for a child directory named 'templates'. Within
196
+ # that directory, the requested template name will be scanned and the first
197
+ # found template file will be used. This process will be repeated for each
198
+ # template file that is requested.
199
+ #
200
+ # The results of this search are not cached, so you can override a single
201
+ # template and leave the rest wherever the generator has defined them.
202
+ #
203
+ # @return [Array] of paths
204
+ #
205
+ def search_paths
206
+ # NOTE: Do not cache this list, specific generators
207
+ # will modify it with their own lookups
208
+ create_search_paths.select { |path| File.directory?(path) }
209
+ end
210
+
211
+ private
212
+
213
+ def create_search_paths
214
+ paths = [
215
+ File.join('config', 'generators'),
216
+ File.join('vendor', 'generators'),
217
+ Sprout.generator_cache
218
+ ]
219
+ paths << ENV['SPROUT_GENERATORS'] unless ENV['SPROUT_GENERATORS'].nil?
220
+ paths
221
+ end
222
+
223
+ ##
224
+ # I know this seems weird - but we can't instantiate the classes
225
+ # during registration because they register before they've been fully
226
+ # interpreted...
227
+ def update_registered_entities
228
+ registered_entities.collect! do |gen|
229
+ (gen.is_a?(Class)) ? gen.new : gen
230
+ end
231
+ end
232
+
233
+ def configure_instance generator
234
+ generator
235
+ end
236
+
237
+ def generator_paths
238
+ @generator_paths ||= []
239
+ end
240
+
241
+ end
242
+ end
243
+ end
244
+
@@ -1,99 +1,5 @@
1
1
  module Sprout
2
-
3
2
  module Generator
4
- include RubyFeature
5
-
6
- class << self
7
-
8
- def register generator_class, templates_path=nil
9
- generator_paths << { :class => generator_class, :templates => templates_path } unless templates_path.nil?
10
- super(generator_class)
11
- end
12
-
13
- def create_instance type, options=nil
14
- class_name = "#{type.to_s.camel_case}Generator"
15
- registered_entities.each do |entity|
16
- if(entity.to_s.match(/::#{class_name}$/) || entity.to_s.match(/^#{class_name}$/))
17
- return entity.new
18
- end
19
- end
20
- raise Sprout::Errors::MissingGeneratorError.new "Could not find any generator named: (#{class_name}). Perhaps you need to add a RubyGem to your Gemfile?"
21
- end
22
-
23
- def template_folder_for clazz
24
- # Search the potential matches in reverse order
25
- # because subclasses have registered AFTER their
26
- # superclasses and superclasses match the ===
27
- # check...
28
- generator_paths.reverse.each do |options|
29
- if options[:class] === clazz
30
- return options[:templates]
31
- end
32
- end
33
- nil
34
- end
35
-
36
- ##
37
- # Returns a new collection of paths to search within for generator declarations
38
- # and more importantly, folders named, 'templates'.
39
- #
40
- # The collection of search_paths will be a subset of the following
41
- # that will include only those directories that exist:
42
- #
43
- # ./config/generators
44
- # ./vendor/generators
45
- # ~/Library/Sprouts/1.0/generators # OS X only
46
- # ~/.sprouts/1.0/generators # Unix only
47
- # [USER_HOME]/Application Data/Sprouts/cache/1.0/generators # Windows only
48
- # ENV['SPROUT_GENERATORS'] # Only if defined
49
- # [Generator Declaration __FILE__]/templates
50
- #
51
- # When the generators attempt to resolve templates, each of the preceding
52
- # folders will be scanned for a child directory named 'templates'. Within
53
- # that directory, the requested template name will be scanned and the first
54
- # found template file will be used. This process will be repeated for each
55
- # template file that is requested.
56
- #
57
- # The idea is that you may wish to override some template files that a
58
- # generator creates, but leave others unchanged.
59
- #
60
- def search_paths
61
- # NOTE: Do not cache this list, specific generators
62
- # will modify it with their own lookups
63
- create_search_paths.select { |path| File.directory?(path) }
64
- end
65
-
66
- private
67
-
68
- def create_search_paths
69
- paths = [
70
- File.join('config', 'generators'),
71
- File.join('vendor', 'generators'),
72
- Sprout.generator_cache
73
- ]
74
- paths << ENV['SPROUT_GENERATORS'] unless ENV['SPROUT_GENERATORS'].nil?
75
- paths
76
- end
77
-
78
- ##
79
- # I know this seems weird - but we can't instantiate the classes
80
- # during registration because they register before they've been fully
81
- # interpreted...
82
- def update_registered_entities
83
- registered_entities.collect! do |gen|
84
- (gen.is_a?(Class)) ? gen.new : gen
85
- end
86
- end
87
-
88
- def configure_instance generator
89
- generator
90
- end
91
-
92
- def generator_paths
93
- @generator_paths ||= []
94
- end
95
-
96
- end
97
3
 
98
4
  class Base
99
5
  include Sprout::Executable