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,8 +2,51 @@ module Sprout
2
2
 
3
3
  module Executable
4
4
 
5
- # Concrete param object for :boolean values
5
+ ##
6
+ # Concrete Sprout::Executable::Param object for Boolean values.
7
+ #
8
+ # By default Boolean parameters have their value set to false and
9
+ # :hidden_value set to true. This means that when they are serialized
10
+ # to the shell, they will usually be represented like:
11
+ #
12
+ # --name
13
+ #
14
+ # Rather than:
15
+ #
16
+ # --name=true
17
+ #
18
+ # The following example demonstrates a simple use of the Boolean
19
+ # parameter:
20
+ #
21
+ # class Foo
22
+ # include Sprout::Executable
23
+ #
24
+ # add_param :visible, Boolean
25
+ # end
26
+ #
27
+ # @see Sprout::Executable::Param
28
+ #
6
29
  class Boolean < Param
30
+
31
+ ##
32
+ # By default, the Boolean parameter will only
33
+ # be displayed when it's value is +true+.
34
+ #
35
+ # Set :show_on_false to true in order to reverse
36
+ # this rule.
37
+ #
38
+ # add_param :visible, Boolean, :show_on_false => true
39
+ #
40
+ # Will make the following:
41
+ #
42
+ # foo :name do |t|
43
+ # t.visible = false
44
+ # end
45
+ #
46
+ # Serialize to the shell with:
47
+ #
48
+ # foo -visible=false
49
+ #
7
50
  attr_accessor :show_on_false
8
51
 
9
52
  def initialize
@@ -15,6 +58,9 @@ module Sprout
15
58
  @hidden_value = true
16
59
  end
17
60
 
61
+ ##
62
+ # Convert string representations of truthiness
63
+ # to something more Booley.
18
64
  def value=(value)
19
65
  value = (value == "true" || value === true) ? true : false
20
66
  super value
@@ -1,6 +1,8 @@
1
1
  module Sprout
2
2
 
3
3
  module Executable
4
+
5
+ ##
4
6
  # Included by any parameters that represent
5
7
  # a collection of values, rather than a single
6
8
  # value.
@@ -8,6 +10,11 @@ module Sprout
8
10
  # Should only be included by classes that
9
11
  # extend Sprout::Executable::Param.
10
12
  #
13
+ # @see Sprout::Executable::Files
14
+ # @see Sprout::Executable::Paths
15
+ # @see Sprout::Executable::Strings
16
+ # @see Sprout::Executable::Urls
17
+ #
11
18
  module CollectionParam
12
19
 
13
20
  def initialize
@@ -17,7 +24,30 @@ module Sprout
17
24
  @option_parser_type_name = 'a,b,c'
18
25
  end
19
26
 
20
- # Assign the value and raise if
27
+ ##
28
+ # Assign the value and raise if a collection wasn't provided.
29
+ #
30
+ # This customization was added so that Rake tasks could help
31
+ # users avoid accidentally clobbering a collection with equals assignments.
32
+ #
33
+ # The following example is incorrect and will raise an exception:
34
+ #
35
+ # foo :name do |t|
36
+ # t.collection = 'A'
37
+ # end
38
+ #
39
+ # The following example is correct and should not raise an exception:
40
+ #
41
+ # foo :name do |t|
42
+ # t.collection << 'A'
43
+ # end
44
+ #
45
+ # The following example is also correct and should not raise an exception:
46
+ #
47
+ # foo :name do |t|
48
+ # t.collection = ['A']
49
+ # end
50
+ #
21
51
  def value=(val)
22
52
  if(val.is_a?(String) || !val.is_a?(Enumerable))
23
53
  message = "The #{name} property is an Enumerable. It looks like you may have used the assignment operator (=) with (#{value.inspect}) where the append operator (<<) was expected."
@@ -26,12 +56,14 @@ module Sprout
26
56
  @value = val
27
57
  end
28
58
 
59
+ ##
29
60
  # Hide the collection param if no items
30
61
  # have been added to it.
31
62
  def visible?
32
63
  (!value.nil? && value.size > 0)
33
64
  end
34
65
 
66
+ ##
35
67
  # Returns a shell formatted string of the collection
36
68
  def to_shell
37
69
  prepare if !prepared?
@@ -3,16 +3,29 @@ module Sprout
3
3
  module Executable
4
4
 
5
5
  ##
6
- # Concrete param object for :file values
6
+ # Concrete Sprout::Executable::Param object for File values.
7
7
  #
8
- # This class is actually referenced in Excecutables with:
8
+ # This class is used in Sprout::Excecutable s with:
9
9
  #
10
10
  # add_param :some_name, File
11
11
  #
12
- # @see Sprout::Executable::ParameterFactory
12
+ # This parameter is truly special in that whatever values
13
+ # are sent to the File parameter will be added to the underlying
14
+ # Rake task as prerequisites and must exist before +Sprout::Executable.execute+
15
+ # is called - _unless_ the parameter value
16
+ # matches the Sprout::Executable instance's +output+ value.
17
+ #
18
+ # Of course this will only be the case if there is a Rake
19
+ # task wrapper for the Executable, if the Sprout::Executable
20
+ # is being used to create a Ruby executable, then these File
21
+ # parameters will only be validated before execution.
22
+ #
23
+ # @see Sprout::Executable::Param
13
24
  #
14
25
  class FileParam < Param
15
26
 
27
+ attr_accessor :file_task_name
28
+
16
29
  def initialize
17
30
  super
18
31
  @option_parser_type_name = 'FILE'
@@ -4,6 +4,11 @@ module Sprout
4
4
 
5
5
  ##
6
6
  # Concrete param object for collections of files
7
+ #
8
+ # @see Sprout::Executable::FileParam
9
+ # @see Sprout::Executable::Param
10
+ # @see Sprout::Executable::CollectionParam
11
+ #
7
12
  class Files < Executable::Param
8
13
  include CollectionParam
9
14
 
@@ -3,7 +3,11 @@ module Sprout
3
3
 
4
4
  module Executable
5
5
 
6
- # Concrete param object for numberic values
6
+ ##
7
+ # Concrete Sprout::Executable::Param object for numeric values.
8
+ #
9
+ # @see Sprout::Executable::Param
10
+ #
7
11
  class Number < Param; end
8
12
  end
9
13
  end
@@ -6,36 +6,175 @@ module Sprout
6
6
  ##
7
7
  # The abstract base class for all Executable parameters.
8
8
  #
9
+ # This class provides a variety of template methods and general
10
+ # functionality to the different executable parameter types.
11
+ #
12
+ # Many of these parameter attributes are exposed to Sprout::Executable
13
+ # concrete classes as the options hash like:
14
+ #
15
+ # class Foo
16
+ # include Sprout::Executable
17
+ #
18
+ # add_param :name, String, :hidden_name => true
19
+ # end
20
+ #
21
+ # @see Sprout::Executable::Boolean
22
+ # @see Sprout::Executable::FileParam
23
+ # @see Sprout::Executable::Files
24
+ # @see Sprout::Executable::Number
25
+ # @see Sprout::Executable::ParameterFactory
26
+ # @see Sprout::Executable::Path
27
+ # @see Sprout::Executable::Paths
28
+ # @see Sprout::Executable::StringParam
29
+ # @see Sprout::Executable::Strings
30
+ # @see Sprout::Executable::Url
31
+ # @see Sprout::Executable::Urls
32
+ #
9
33
  class Param
34
+
35
+ ##
36
+ # Default value for the delimiter that will
37
+ # separate parameter names from their values.
10
38
  DEFAULT_DELIMITER = '='
39
+
40
+ ##
41
+ # Defaut TYPE assumed for parameters when
42
+ # creating documentation for the OptionParser.
11
43
  DEFAULT_OPTION_PARSER_TYPE_NAME = 'STRING'
12
44
 
13
- # These values should usually be pulled
14
- # from the 'belongs_to' executable:
45
+ ##
46
+ # Default value for the parameter prefix.
47
+ # Should usually be pulled from the
48
+ # +belongs_to+ Sprout::Executable.
15
49
  DEFAULT_PREFIX = '--'
50
+
51
+ ##
52
+ # Default prefix for truncated parameters.
53
+ # Should usually be pulled from the
54
+ # +belongs_to+ Sprout::Executable.
16
55
  DEFAULT_SHORT_PREFIX = '-'
17
56
 
57
+ ##
58
+ # The Sprout::Executable that this parameter
59
+ # instance belongs to.
18
60
  attr_accessor :belongs_to
61
+
62
+ ##
63
+ # Executable::Params join their name/value pair with an
64
+ # equals sign by default, this can be modified
65
+ # To a space or whatever you wish.
66
+ attr_accessor :delimiter
67
+
68
+ ##
69
+ # The String description that will be used for
70
+ # RDoc documentation and user help.
19
71
  attr_accessor :description
72
+
73
+ ##
74
+ # Boolean value that hides the name parameter
75
+ # from the shell execution.
76
+ #
77
+ # add_param :name, String, :hidden_name => true
78
+ #
79
+ # Without this option, the above parameter would
80
+ # serialize to the process like:
81
+ #
82
+ # foo --name=Value
83
+ #
84
+ # But with this option, the above parameter would
85
+ # serialize to the process like:
86
+ #
87
+ # foo Value
88
+ #
20
89
  attr_accessor :hidden_name
90
+
91
+ ##
92
+ # Boolean value that hides the value parameter
93
+ # from the shell execution.
94
+ #
95
+ # add_param :visible, Boolean, :hidden_value => true
96
+ #
97
+ # Without this option, the above parameter would
98
+ # serialize to the process like:
99
+ #
100
+ # foo --visible=true
101
+ #
102
+ # But with this option, the above parameter would
103
+ # serialize to the process like:
104
+ #
105
+ # foo --visible
106
+ #
21
107
  attr_accessor :hidden_value
22
- attr_accessor :file_task_name
108
+
109
+ ##
110
+ # The String (or Symbol) name of the parameter.
23
111
  attr_accessor :name
112
+
113
+ ##
114
+ # The String prefix that should be in front of each
115
+ # command line parameter.
116
+ #
117
+ # If no value is set for this option, the
118
+ # DEFAULT_PREFIX (--) will be used for regular parameters,
119
+ # and the DEFAULT_SHORT_PREFIX (-) will be used for short
120
+ # parameters.
24
121
  attr_accessor :prefix
122
+
123
+ ##
124
+ # A Symbol that refers to a custom attribute reader
125
+ # that is available to instance methods on the
126
+ # Sprout::Executable that uses it.
127
+ #
128
+ # add_param :visible, Boolean, :reader => :get_visible
129
+ #
130
+ # def get_visible
131
+ # return @visible
132
+ # end
133
+ #
25
134
  attr_accessor :reader
135
+
136
+ ##
137
+ # Boolean value that will cause a Sprout::Errors::UsageError
138
+ # if the executable is invoked without this parameter first
139
+ # being set.
140
+ #
141
+ # add_param :visible, Boolean :required => true
142
+ #
143
+ # Default false
144
+ #
26
145
  attr_accessor :required
146
+
147
+ ##
148
+ # An optional Proc that should be called when this parameter
149
+ # is serialized to shell output. The Proc should return a
150
+ # String value that makes sense to the underlying process.
151
+ #
152
+ # add_param :visible, Boolean, :to_shell_proc => Proc.new {|p| "---result" }
153
+ #
27
154
  attr_accessor :to_shell_proc
155
+
156
+ ##
157
+ # The data type of the parameter, used to generate more appropriate
158
+ # RDoc content for the concrete Sprout::Executable.
28
159
  attr_accessor :type
29
- attr_accessor :validator
160
+
161
+ ##
162
+ # The value that was assigned to this parameter when the
163
+ # concrete Sprout::Executable was instantiated and configured.
30
164
  attr_accessor :value
31
- attr_accessor :visible
32
- attr_accessor :writer
33
165
 
34
166
  ##
35
- # Executable::Params join their name/value pair with an
36
- # equals sign by default, this can be modified
37
- # To a space or whatever you wish.
38
- attr_accessor :delimiter
167
+ # A Symbol that refers to a custom attribute writer
168
+ # that is available to instance methods on the
169
+ # Sprout::Executable that uses it.
170
+ #
171
+ # add_param :visible, Boolean, :writer => :set_visible
172
+ #
173
+ # def set_visible=(vis)
174
+ # @visible = vis
175
+ # end
176
+ #
177
+ attr_accessor :writer
39
178
 
40
179
  ##
41
180
  # Set the file_expression (blob) to append to each path
@@ -43,17 +182,48 @@ module Sprout
43
182
  #
44
183
  # Defaults to the parent Executable.default_file_expression
45
184
  #
46
- # NOTE: We should add support for file_expressionS
185
+ # TODO: We should add support for file_expressionS
47
186
  # since these are really just blobs that are sent
48
187
  # to the FileList[expr] and that interface accepts
49
188
  # an array.
50
189
  attr_writer :file_expression
51
190
 
52
191
  ##
53
- # Return the name with a single leading dash
54
- # and underscores replaced with dashes
192
+ # Optional String value of the name of this parameter
193
+ # that should be returned to the shell.
194
+ #
195
+ # By default, this method will infer the name by
196
+ # prepending the +prefix+ and replacing underscores
197
+ # with dashes. For example:
198
+ #
199
+ # add_param :some_name, String
200
+ #
201
+ # Would return '--some-name=value' to the shell.
202
+ #
203
+ # If this option is set, then the provided value
204
+ # will be used rather than inferred.
205
+ #
206
+ # add_param :some_name, String, :shell_name => '--OtherName'
207
+ #
208
+ # Would return '--OtherName=value' when sent to the shell.
209
+ #
55
210
  attr_writer :shell_name
56
211
 
212
+ ##
213
+ # Optional String value that should be used for this
214
+ # parameter's short name. Generally only helpful
215
+ # for Sprout::Executable 's that are going to be exposed
216
+ # to Ruby OptionParser as Ruby applications.
217
+ #
218
+ # By default, this value will be the first letter
219
+ # of the parameter name, and when multiple parameters
220
+ # share the same first letter, the first one encountered
221
+ # will be used.
222
+ attr_writer :short_name
223
+ ##
224
+ # Default constructor for Params, if you create
225
+ # a new concrete type, be sure to call +super()+ in your
226
+ # own constructor.
57
227
  def initialize
58
228
  @description = 'Default Description'
59
229
  @hidden_value = false
@@ -70,14 +240,14 @@ module Sprout
70
240
  end
71
241
 
72
242
  ##
73
- # Raise an exception if a required parameter is nil.
243
+ # Returns Boolean value if this parameter is required.
74
244
  def required?
75
245
  (required == true)
76
246
  end
77
247
 
78
248
  ##
79
- # Ensure this parameter is in a valid state, raise an appropriate
80
- # exception if it is not.
249
+ # Ensure this parameter is in a valid state, raise a Sprout::Errors::MissingArgumentError
250
+ # if it is not.
81
251
  def validate
82
252
  if(required? && value.nil?)
83
253
  raise Sprout::Errors::MissingArgumentError.new("#{name} is required and must not be nil")
@@ -86,11 +256,19 @@ module Sprout
86
256
 
87
257
  ##
88
258
  # Set the default value of the parameter.
259
+ # Using this option will ensure that required parameters
260
+ # are not nil, and default values can be overridden on
261
+ # instances.
262
+ #
263
+ # add_param :name, String, :default => 'Bob'
264
+ #
89
265
  def default=(value)
90
266
  self.value = value
91
267
  @default = value
92
268
  end
93
269
 
270
+ ##
271
+ # Return the default value or nil if none was provided.
94
272
  def default
95
273
  @default
96
274
  end
@@ -136,6 +314,9 @@ module Sprout
136
314
  @short_prefix ||= (belongs_to.nil?) ? DEFAULT_SHORT_PREFIX : belongs_to.default_short_prefix
137
315
  end
138
316
 
317
+ ##
318
+ # How this parameter is provided to the
319
+ # Ruby OptionParser when being exposed as a Ruby Executable.
139
320
  def option_parser_declaration
140
321
  declaration = [ prefix, option_parser_name ]
141
322
  # TODO: Need to figure out how to support hidden name inputs...
@@ -148,14 +329,30 @@ module Sprout
148
329
  declaration.join('')
149
330
  end
150
331
 
332
+ ##
333
+ # The Ruby OptionParser short name with prefix.
151
334
  def option_parser_short_name
152
335
  [ short_prefix, short_name ].join('')
153
336
  end
154
337
 
338
+ ##
339
+ # The short name for this parameter.
340
+ # If it's not explicitly, the first
341
+ # character of the parameter name will
342
+ # be used. When multiple parameters have
343
+ # the same first character, the first one
344
+ # encountered will win.
155
345
  def short_name
156
346
  @short_name ||= name.to_s.split('').shift
157
347
  end
158
348
 
349
+ ##
350
+ # The String representation of the value in
351
+ # a format that is appropriate for the terminal.
352
+ #
353
+ # For certain types of parameters, like File,
354
+ # spaces may be escaped on some platforms.
355
+ #
159
356
  def shell_value
160
357
  value.to_s
161
358
  end
@@ -168,6 +365,13 @@ module Sprout
168
365
  @shell_name ||= prefix + name.to_s.split('_').join('-')
169
366
  end
170
367
 
368
+ ##
369
+ # Prepare and serialize this parameter to a string
370
+ # that is appropriate for shell execution on the
371
+ # current platform.
372
+ #
373
+ # Calling +to_shell+ will first trigger a call to
374
+ # the +prepare+ template method unless +prepared?+ returns +true+.
171
375
  def to_shell
172
376
  prepare if !prepared?
173
377
  validate
@@ -208,10 +412,22 @@ module Sprout
208
412
  def prepare_prerequisites
209
413
  end
210
414
 
415
+ ##
416
+ # Clean the provided path using the current Sprout::System.
211
417
  def clean_path path
212
418
  Sprout::System.create.clean_path path
213
419
  end
214
420
 
421
+ ##
422
+ # Return true if the Sprout::Executable
423
+ # that this parameter +belongs_to+ has an +output+
424
+ # method (or parameter), and if the provided +file+
425
+ # matches the value of that parameter.
426
+ #
427
+ # This method (convention) is used to avoid creating circular
428
+ # prerequisites in Rake. For most types of File parameters
429
+ # we want to make them into prerequisites, but not if the
430
+ # File is the one being created by the outer Sprout::Executable.
215
431
  def file_is_output? file
216
432
  belongs_to.respond_to?(:output) && belongs_to.output.to_s == file
217
433
  end