tap 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. data/History +37 -30
  2. data/MIT-LICENSE +1 -1
  3. data/README +92 -44
  4. data/bin/tap +62 -75
  5. data/cmd/console.rb +42 -0
  6. data/cmd/destroy.rb +16 -0
  7. data/cmd/generate.rb +16 -0
  8. data/cmd/run.rb +126 -0
  9. data/doc/Class Reference +362 -0
  10. data/doc/Command Reference +153 -0
  11. data/doc/Tutorial +237 -0
  12. data/lib/tap.rb +6 -45
  13. data/lib/tap/app.rb +126 -500
  14. data/lib/tap/constants.rb +2 -29
  15. data/lib/tap/env.rb +555 -250
  16. data/lib/tap/file_task.rb +60 -103
  17. data/lib/tap/generator/base.rb +109 -0
  18. data/lib/tap/generator/destroy.rb +37 -0
  19. data/lib/tap/generator/generate.rb +61 -0
  20. data/lib/tap/generator/generators/command/command_generator.rb +16 -12
  21. data/lib/tap/generator/generators/command/templates/command.erb +13 -19
  22. data/lib/tap/generator/generators/config/config_generator.rb +18 -27
  23. data/lib/tap/generator/generators/config/templates/doc.erb +12 -0
  24. data/lib/tap/generator/generators/config/templates/nodoc.erb +8 -0
  25. data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -11
  26. data/lib/tap/generator/generators/file_task/templates/file.txt +11 -2
  27. data/lib/tap/generator/generators/file_task/templates/result.yml +6 -0
  28. data/lib/tap/generator/generators/file_task/templates/task.erb +24 -31
  29. data/lib/tap/generator/generators/file_task/templates/test.erb +18 -22
  30. data/lib/tap/generator/generators/root/root_generator.rb +45 -31
  31. data/lib/tap/generator/generators/root/templates/Rakefile +64 -41
  32. data/lib/tap/generator/generators/root/templates/gemspec +27 -0
  33. data/lib/tap/generator/generators/root/templates/tapfile +8 -0
  34. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -0
  35. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
  36. data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +15 -0
  37. data/lib/tap/generator/generators/task/task_generator.rb +21 -28
  38. data/lib/tap/generator/generators/task/templates/task.erb +13 -23
  39. data/lib/tap/generator/generators/task/templates/test.erb +15 -18
  40. data/lib/tap/generator/manifest.rb +14 -0
  41. data/lib/tap/patches/rake/rake_test_loader.rb +0 -0
  42. data/lib/tap/patches/rake/testtask.rb +0 -0
  43. data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -0
  44. data/lib/tap/patches/ruby19/parsedate.rb +0 -0
  45. data/lib/tap/root.rb +260 -21
  46. data/lib/tap/support/aggregator.rb +11 -11
  47. data/lib/tap/support/assignments.rb +172 -0
  48. data/lib/tap/support/audit.rb +20 -18
  49. data/lib/tap/support/batchable.rb +21 -10
  50. data/lib/tap/support/batchable_class.rb +107 -0
  51. data/lib/tap/support/class_configuration.rb +154 -239
  52. data/lib/tap/support/command_line.rb +97 -102
  53. data/lib/tap/support/comment.rb +270 -0
  54. data/lib/tap/support/configurable.rb +86 -65
  55. data/lib/tap/support/configurable_class.rb +296 -0
  56. data/lib/tap/support/configuration.rb +122 -0
  57. data/lib/tap/support/constant.rb +70 -0
  58. data/lib/tap/support/constant_utils.rb +127 -0
  59. data/lib/tap/support/declarations.rb +111 -0
  60. data/lib/tap/support/executable.rb +30 -17
  61. data/lib/tap/support/executable_queue.rb +0 -0
  62. data/lib/tap/support/framework.rb +71 -0
  63. data/lib/tap/support/framework_class.rb +199 -0
  64. data/lib/tap/support/instance_configuration.rb +147 -0
  65. data/lib/tap/support/lazydoc.rb +428 -0
  66. data/lib/tap/support/manifest.rb +89 -0
  67. data/lib/tap/support/run_error.rb +0 -0
  68. data/lib/tap/support/shell_utils.rb +33 -9
  69. data/lib/tap/support/summary.rb +30 -0
  70. data/lib/tap/support/tdoc.rb +339 -134
  71. data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -0
  72. data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -0
  73. data/lib/tap/support/templater.rb +180 -0
  74. data/lib/tap/support/validation.rb +409 -76
  75. data/lib/tap/support/versions.rb +5 -3
  76. data/lib/tap/task.rb +78 -174
  77. data/lib/tap/tasks/dump.rb +56 -0
  78. data/lib/tap/tasks/rake.rb +93 -0
  79. data/lib/tap/test.rb +3 -3
  80. data/lib/tap/test/env_vars.rb +2 -2
  81. data/lib/tap/test/file_methods.rb +19 -20
  82. data/lib/tap/test/script_methods.rb +144 -0
  83. data/lib/tap/test/subset_methods.rb +1 -1
  84. data/lib/tap/test/tap_methods.rb +28 -62
  85. data/lib/tap/workflow.rb +22 -39
  86. metadata +48 -179
  87. data/Basic Overview +0 -151
  88. data/Command Reference +0 -99
  89. data/Rakefile +0 -127
  90. data/Tutorial +0 -287
  91. data/lib/tap/cmd/console.rb +0 -31
  92. data/lib/tap/cmd/destroy.rb +0 -20
  93. data/lib/tap/cmd/generate.rb +0 -20
  94. data/lib/tap/cmd/run.rb +0 -151
  95. data/lib/tap/dump.rb +0 -57
  96. data/lib/tap/generator.rb +0 -91
  97. data/lib/tap/generator/generators/command/USAGE +0 -6
  98. data/lib/tap/generator/generators/config/USAGE +0 -21
  99. data/lib/tap/generator/generators/config/templates/config.erb +0 -1
  100. data/lib/tap/generator/generators/file_task/USAGE +0 -3
  101. data/lib/tap/generator/generators/file_task/templates/file.yml +0 -3
  102. data/lib/tap/generator/generators/generator/USAGE +0 -0
  103. data/lib/tap/generator/generators/generator/generator_generator.rb +0 -21
  104. data/lib/tap/generator/generators/generator/templates/generator.erb +0 -32
  105. data/lib/tap/generator/generators/generator/templates/usage.erb +0 -1
  106. data/lib/tap/generator/generators/root/USAGE +0 -0
  107. data/lib/tap/generator/generators/root/templates/ReadMe.txt +0 -0
  108. data/lib/tap/generator/generators/root/templates/tap.yml +0 -80
  109. data/lib/tap/generator/generators/task/USAGE +0 -3
  110. data/lib/tap/generator/generators/workflow/USAGE +0 -0
  111. data/lib/tap/generator/generators/workflow/templates/task.erb +0 -16
  112. data/lib/tap/generator/generators/workflow/templates/test.erb +0 -7
  113. data/lib/tap/generator/generators/workflow/workflow_generator.rb +0 -6
  114. data/lib/tap/generator/options.rb +0 -26
  115. data/lib/tap/generator/usage.rb +0 -26
  116. data/lib/tap/support/batchable_methods.rb +0 -34
  117. data/lib/tap/support/command_line_methods.rb +0 -76
  118. data/lib/tap/support/configurable_methods.rb +0 -224
  119. data/lib/tap/support/logger.rb +0 -88
  120. data/lib/tap/support/rake.rb +0 -43
  121. data/lib/tap/support/tdoc/config_attr.rb +0 -362
  122. data/test/app/config/another/task.yml +0 -1
  123. data/test/app/config/batch.yml +0 -2
  124. data/test/app/config/empty.yml +0 -0
  125. data/test/app/config/erb.yml +0 -2
  126. data/test/app/config/some/task.yml +0 -1
  127. data/test/app/config/template.yml +0 -2
  128. data/test/app/config/version-0.1.yml +0 -1
  129. data/test/app/config/version.yml +0 -1
  130. data/test/app/lib/app_test_task.rb +0 -3
  131. data/test/app_test.rb +0 -1849
  132. data/test/env/test_configure/recurse_a.yml +0 -2
  133. data/test/env/test_configure/recurse_b.yml +0 -2
  134. data/test/env/test_configure/tap.yml +0 -23
  135. data/test/env/test_load_env_config/dir/tap.yml +0 -3
  136. data/test/env/test_load_env_config/recurse_a.yml +0 -2
  137. data/test/env/test_load_env_config/recurse_b.yml +0 -2
  138. data/test/env/test_load_env_config/tap.yml +0 -3
  139. data/test/env_test.rb +0 -198
  140. data/test/file_task/config/batch.yml +0 -2
  141. data/test/file_task/config/configured.yml +0 -1
  142. data/test/file_task/old_file_one.txt +0 -0
  143. data/test/file_task/old_file_two.txt +0 -0
  144. data/test/file_task_test.rb +0 -1291
  145. data/test/root/alt_lib/alt_module.rb +0 -4
  146. data/test/root/file.txt +0 -0
  147. data/test/root/glob/one.txt +0 -0
  148. data/test/root/glob/two.txt +0 -0
  149. data/test/root/lib/absolute_alt_filepath.rb +0 -2
  150. data/test/root/lib/alternative_filepath.rb +0 -2
  151. data/test/root/lib/another_module.rb +0 -2
  152. data/test/root/lib/nested/some_module.rb +0 -4
  153. data/test/root/lib/no_module_included.rb +0 -0
  154. data/test/root/lib/some/module.rb +0 -4
  155. data/test/root/lib/some_class.rb +0 -2
  156. data/test/root/lib/some_module.rb +0 -3
  157. data/test/root/load_path/load_path_module.rb +0 -2
  158. data/test/root/load_path/skip_module.rb +0 -2
  159. data/test/root/mtime/older.txt +0 -0
  160. data/test/root/unload/full_path.rb +0 -2
  161. data/test/root/unload/loaded_by_nested.rb +0 -2
  162. data/test/root/unload/nested/nested_load.rb +0 -6
  163. data/test/root/unload/nested/nested_with_ext.rb +0 -4
  164. data/test/root/unload/nested/relative_path.rb +0 -4
  165. data/test/root/unload/older.rb +0 -2
  166. data/test/root/unload/unload_base.rb +0 -9
  167. data/test/root/versions/another.yml +0 -0
  168. data/test/root/versions/file-0.1.2.yml +0 -0
  169. data/test/root/versions/file-0.1.yml +0 -0
  170. data/test/root/versions/file.yml +0 -0
  171. data/test/root_test.rb +0 -718
  172. data/test/support/aggregator_test.rb +0 -99
  173. data/test/support/audit_test.rb +0 -445
  174. data/test/support/batchable_test.rb +0 -74
  175. data/test/support/class_configuration_test.rb +0 -331
  176. data/test/support/command_line_test.rb +0 -58
  177. data/test/support/configurable/config/configured.yml +0 -2
  178. data/test/support/configurable_test.rb +0 -295
  179. data/test/support/executable_queue_test.rb +0 -103
  180. data/test/support/executable_test.rb +0 -38
  181. data/test/support/logger_test.rb +0 -31
  182. data/test/support/rake_test.rb +0 -37
  183. data/test/support/shell_utils_test.rb +0 -24
  184. data/test/support/tdoc_test.rb +0 -370
  185. data/test/support/validation_test.rb +0 -54
  186. data/test/support/versions_test.rb +0 -103
  187. data/test/tap_test_helper.rb +0 -57
  188. data/test/tap_test_suite.rb +0 -7
  189. data/test/task/config/batch.yml +0 -2
  190. data/test/task/config/batched.yml +0 -2
  191. data/test/task/config/configured.yml +0 -1
  192. data/test/task/config/example.yml +0 -1
  193. data/test/task_base_test.rb +0 -24
  194. data/test/task_syntax_test.rb +0 -300
  195. data/test/task_test.rb +0 -320
  196. data/test/test/env_vars_test.rb +0 -48
  197. data/test/test/file_methods/test_assert_files/expected/one.txt +0 -1
  198. data/test/test/file_methods/test_assert_files/expected/two.txt +0 -1
  199. data/test/test/file_methods/test_assert_files/input/one.txt +0 -1
  200. data/test/test/file_methods/test_assert_files/input/two.txt +0 -1
  201. data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/one.txt +0 -1
  202. data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/two.txt +0 -1
  203. data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +0 -1
  204. data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/two.txt +0 -1
  205. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +0 -1
  206. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +0 -1
  207. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/expected/one.txt +0 -1
  208. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +0 -1
  209. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +0 -1
  210. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +0 -1
  211. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +0 -1
  212. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +0 -1
  213. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +0 -1
  214. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +0 -1
  215. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +0 -1
  216. data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
  217. data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
  218. data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
  219. data/test/test/file_methods_doc/test_sub/expected/one.txt +0 -1
  220. data/test/test/file_methods_doc/test_sub/expected/two.txt +0 -1
  221. data/test/test/file_methods_doc/test_sub/input/one.txt +0 -1
  222. data/test/test/file_methods_doc/test_sub/input/two.txt +0 -1
  223. data/test/test/file_methods_doc_test.rb +0 -29
  224. data/test/test/file_methods_test.rb +0 -275
  225. data/test/test/subset_methods_test.rb +0 -171
  226. data/test/test/tap_methods/test_assert_files/expected/task/name/a.txt +0 -1
  227. data/test/test/tap_methods/test_assert_files/expected/task/name/b.txt +0 -1
  228. data/test/test/tap_methods/test_assert_files/input/a.txt +0 -1
  229. data/test/test/tap_methods/test_assert_files/input/b.txt +0 -1
  230. data/test/test/tap_methods_test.rb +0 -399
  231. data/test/workflow_test.rb +0 -120
  232. data/vendor/rails_generator.rb +0 -56
  233. data/vendor/rails_generator/base.rb +0 -263
  234. data/vendor/rails_generator/commands.rb +0 -581
  235. data/vendor/rails_generator/generated_attribute.rb +0 -42
  236. data/vendor/rails_generator/lookup.rb +0 -209
  237. data/vendor/rails_generator/manifest.rb +0 -53
  238. data/vendor/rails_generator/options.rb +0 -143
  239. data/vendor/rails_generator/scripts.rb +0 -83
  240. data/vendor/rails_generator/scripts/destroy.rb +0 -7
  241. data/vendor/rails_generator/scripts/generate.rb +0 -7
  242. data/vendor/rails_generator/scripts/update.rb +0 -12
  243. data/vendor/rails_generator/simple_logger.rb +0 -46
  244. data/vendor/rails_generator/spec.rb +0 -44
@@ -0,0 +1,153 @@
1
+ = Command Reference
2
+
3
+ The <tt>tap</tt> executable is the gateway for the execution of tasks. To get help for tap, type:
4
+
5
+ % tap --help
6
+
7
+ <tt>tap</tt> sets up the execution environment from <tt>tap.yml</tt>, if it exists, and passes control to the specified command. Command help can be obtained using:
8
+
9
+ % tap [command] --help
10
+
11
+ This reference covers the commands: run, console, generate, destroy
12
+
13
+ === tap run
14
+
15
+ Run configures, enqueues, and executes tasks. Run has a rich syntax allowing the specification of any number of tasks with configurations and inputs, but simplifies under most circumstances. Several examples illustrate the key points:
16
+
17
+ % tap run sample/task
18
+ % tap run -- sample/task --key=value input_one -- another/task input_two
19
+
20
+ The second statement specifies two tasks with inputs, and specifies a configuration for sample/task. As can be seen, run separates tasks using a double-dash, the standard option break. Options for the run command can be specified before the first option break.
21
+
22
+ % tap run --debug -- sample/task --key=value
23
+
24
+ Here run receives the <tt>--debug</tt> option and sample/task receives the <tt>--key=value</tt> option. NOTE: it's always a good idea to include the first option break to formally signify when configuration of run stops. Otherwise you may be confused when the following commands both produce the help for run:
25
+
26
+ % tap run --help
27
+ % tap run sample/task --help
28
+
29
+ Inputs work the same way. For example:
30
+
31
+ % tap run -- sample/task --key=value one -- another/task two three
32
+
33
+ Specifies the following:
34
+
35
+ t1 = Sample::Task.new(:key => 'value')
36
+ t1.enq('one')
37
+
38
+ t2 = Another::Task.new
39
+ t2.enq('two', 'three')
40
+
41
+ Any number of tasks, configurations, and inputs may be specified in this way.
42
+
43
+ ==== Task Lookup
44
+
45
+ Tap can find and run tasks from multiple environments, for instance from multiple gems. Tap provides a compact way to specify which task to run in the event of a name conflict. The actual process involves minimizing the path to the environment and the relative path to the task file, but from the command line all of the details are hidden:
46
+
47
+ % tap run -T
48
+ one:
49
+ sample/task # some sample task
50
+ another/task # another task
51
+ two:
52
+ sample/task # a conflicting sample task
53
+
54
+ In this situation, these commands run the 'one' sample/task:
55
+
56
+ % tap run -- sample/task
57
+ % tap run -- one:sample/task
58
+
59
+ While this runs the 'two' sample/task:
60
+
61
+ % tap run -- two::sample/task
62
+
63
+ Additionally, base-fragments of the minimized paths can be specified (if laziness strikes); they will be resolved in order from top to bottom within the specified environment.
64
+
65
+ Runs the 'one' sample/task:
66
+
67
+ % tap run -- task
68
+
69
+ Runs the 'two' sample/task:
70
+
71
+ % tap run -- two::task
72
+
73
+ The full minimized path must be specified for another/task:
74
+
75
+ % tap run -- another/task
76
+ % tap run -- one:another/task
77
+
78
+ ==== Rounds
79
+
80
+ Run allows specification of a number of rounds of tasks. All tasks in a round are run to completion before the next round begins. Rounds are specified by adding '+' characters after the double-dash task break.
81
+
82
+ % tap run -- round_one_task --+ round_two_task
83
+
84
+ Tasks may be added to rounds in any order. This is equivalent to the last:
85
+
86
+ % tap run --+ round_two_task -- round_one_task
87
+
88
+ Rounds are particularly useful for dump tasks; add a dump task as a final round to capture all results from previous rounds:
89
+
90
+ % tap run -- task -- task --+ dump
91
+
92
+ ==== YAML inputs
93
+
94
+ Non-string inputs can be provided through run. If an input begins with "---\n" then it is loaded as YAML into an object before being passed to a task. The syntax can be a lot to type, but is very handy to have around. The following enques sample/task with a hash input, {'number' => 1}.
95
+
96
+ On *nix, just hit enter to get the next line:
97
+
98
+ % tap run -- sample/task '---
99
+ > number: 1'
100
+
101
+ On Windows, you need to pull some tricks to get newlines into your argument. Cleverly use a caret to ignore the next line feed:
102
+
103
+ % tap run -- sample/task '---^
104
+ More?
105
+ More? number: 1'
106
+
107
+ Notice that pressing enter <em>every other line</em> is what actually puts the "\n" into the parameter. Keep using carets to enter more lines. The syntax on Windows isn't exactly pretty, and it only works with a caveat: the latest execution script generated by rubygems (tap.bat) re-processes inputs to tap before executing the command for real. I haven't found a workaround short of invoking tap from ruby itself:
108
+
109
+ % ruby C:/ruby/bin/tap run -- sample/task '---^
110
+ More?
111
+ More? number: 1'
112
+
113
+ In these cases, consider putting the inputs into a file and load them to the command line with the <tt>--use</tt> option:
114
+
115
+ [inputs.yml]
116
+ number: 1
117
+
118
+ % tap run -- sample/task --use inputs.yml
119
+
120
+ === tap console
121
+
122
+ Console opens an irb session with Tap loaded and configured using <tt>tap.yml</tt>. Console defines variables 'app' and 'env' referencing Tap::App.instance and Tap::Env.instance, for easy access.
123
+
124
+ % tap console
125
+ irb(main):001:0> app.log(:hello)
126
+ I[17:18:53] hello
127
+ => true
128
+ irb(main):002:0>
129
+
130
+ === tap generate/destroy
131
+
132
+ Generate and destory launch generator scripts, similar to those in Rails. By default Tap provides generators for:
133
+
134
+ {root}[link:classes/Tap/Generator/Generators/RootGenerator.html]:: the basic Tap directory structure
135
+ {task}[link:classes/Tap/Generator/Generators/TaskGenerator.html]:: a Tap::Task and test
136
+ {file_task}[link:classes/Tap/Generator/Generators/FileTaskGenerator.html]:: a Tap::FileTask and test
137
+ {config}[link:classes/Tap/Generator/Generators/ConfigGenerator.html]:: a yaml config file for the specified task
138
+ {command}[link:classes/Tap/Generator/Generators/CommandGenerator.html]:: a new command
139
+
140
+ --
141
+ {generator}[link:classes/Tap/Generator/GeneratorseneratorGenerator.html]:: a new generator
142
+ {workflow}[link:classes/Tap/Generator/Generators/Workflow/WorkflowGenerator.html]:: a Tap::Workflow and test
143
+ ++
144
+
145
+ For example:
146
+
147
+ % tap generate root .
148
+ % tap generate task sample_task
149
+ % tap generate config sample_task
150
+
151
+ % tap destroy config sample_task
152
+ % tap destroy task sample_task
153
+ % tap destroy root .
data/doc/Tutorial ADDED
@@ -0,0 +1,237 @@
1
+ = Quick Start Tutorial
2
+
3
+ === Basic Usage
4
+
5
+ Begin by creating a tap directory structure:
6
+
7
+ % tap generate root sample
8
+ % cd sample
9
+
10
+ Comes with a task:
11
+
12
+ % tap run -T
13
+ sample:
14
+ goodnight # your basic goodnight moon task
15
+ tap:
16
+ dump # the default dump task
17
+ rake # run rake tasks
18
+
19
+ Test the task:
20
+
21
+ % rake test
22
+
23
+ Get help for the task:
24
+
25
+ % tap run -- goodnight --help
26
+ Goodnight -- your basic goodnight moon task
27
+ --------------------------------------------------------------------------------
28
+ Prints the input with a configurable message.
29
+ --------------------------------------------------------------------------------
30
+ usage: tap run -- goodnight INPUT
31
+
32
+ configurations:
33
+ --message MESSAGE
34
+
35
+ options:
36
+ -h, --help Print this help
37
+ --name NAME Specify a name
38
+ --use FILE Loads inputs from file
39
+
40
+ Run the task:
41
+
42
+ % tap run -- goodnight moon
43
+ I[23:22:19] goodnight moon
44
+
45
+ Run the task, setting the 'message' configuration:
46
+
47
+ % tap run -- goodnight moon --message hello
48
+ I[23:22:46] hello moon
49
+
50
+ Run multiple tasks, or in this case the same task twice:
51
+
52
+ % tap run -- goodnight moon -- goodnight opus
53
+ I[23:23:06] goodnight moon
54
+ I[23:23:06] goodnight opus
55
+
56
+ Same as above, but now dump the results to a file:
57
+
58
+ % tap run -- goodnight moon -- goodnight opus --+ dump output.yml
59
+ I[23:23:26] goodnight moon
60
+ I[23:23:26] goodnight opus
61
+ I[23:23:26] dump output.yml
62
+
63
+ The dump file contents look like this:
64
+
65
+ # audit:
66
+ # o-[] "opus"
67
+ # o-[goodnight] "goodnight opus"
68
+ #
69
+ # o-[] "moon"
70
+ # o-[goodnight] "goodnight moon"
71
+ #
72
+ # date: 2008-08-05 23:23:26
73
+ ---
74
+ goodnight (2769410):
75
+ - goodnight opus
76
+ goodnight (2780180):
77
+ - goodnight moon
78
+
79
+ The comments at the beginning are an audit trace of the run. In this case two
80
+ separate tasks were run sequentially, hence you can see each task, the task inputs,
81
+ and the task results as separate units. A YAML hash follows the audit with the
82
+ aggregated task results, keyed by the task name and object id. Since the results
83
+ are represented as a hash, the order of the tasks sometimes gets scrambled, as in
84
+ this case.
85
+
86
+ === Task Declaration
87
+
88
+ Tap provides a declaration syntax a-la rake, accessible through the Tap module to
89
+ prevent conflicts with rake. Declarations can get put in any <tt>.rb</tt> file
90
+ under the lib directory or in <tt>tapfile.rb</tt>.
91
+
92
+ [tapfile.rb]
93
+ # Goodnight::manifest your basic goodnight moon task
94
+ # Prints the input with a configurable message.
95
+
96
+ Tap.task('goodnight', :message => 'goodnight') do |task, name|
97
+ task.log task.message, name
98
+ "#{task.message} #{name}"
99
+ end
100
+
101
+ The declaration makes a task class based on the name (ie namespaces are naturally
102
+ supported by names like <tt>'nested/task'</tt>). The classes are ready for use in
103
+ scripts:
104
+
105
+ require 'tapfile'
106
+ Goodnight.new.process('moon') # => 'goodnight moon'
107
+
108
+ And from the command line, as above.
109
+
110
+ === Task Definition
111
+
112
+ Sometimes you need more than a block to define a task. Generate a task:
113
+
114
+ % tap generate task hello
115
+
116
+ Navigate to and open the <tt>lib/hello.rb</tt> file. Inside you can see the class
117
+ definition. Notice configurations are mapped to methods, and the task documentation
118
+ is located in the comments. Let's change it up a bit:
119
+
120
+ [lib/hello.rb]
121
+ # Hello::manifest your basic hello world task
122
+ #
123
+ # Prints hello to a number of things with a configurable,
124
+ # reversible message.
125
+ #
126
+ class Hello < Tap::Task
127
+
128
+ config :message, 'hello' # a greeting
129
+ config :reverse, false, &c.flag # reverses the message
130
+
131
+ def process(*names)
132
+ names.collect do |name|
133
+ log(reverse ? message.reverse : message, name)
134
+ "#{message} #{name}"
135
+ end
136
+ end
137
+ end
138
+
139
+ The new configurations and documentation are immediately available:
140
+
141
+ % tap run -- hello --help
142
+ Hello -- your basic hello world task
143
+ --------------------------------------------------------------------------------
144
+ Prints hello to a number of things with a configurable, reversible message.
145
+ --------------------------------------------------------------------------------
146
+ usage: tap run -- hello NAMES...
147
+
148
+ configurations:
149
+ --message MESSAGE a greeting
150
+ --reverse reverses the message
151
+
152
+ options:
153
+ -h, --help Print this help
154
+ --name NAME Specify a name
155
+ --use FILE Loads inputs from file
156
+
157
+ And the task is ready to go:
158
+
159
+ % tap run -- hello moon lamp 'little toy boat'
160
+ I[23:29:26] hello moon
161
+ I[23:29:26] hello lamp
162
+ I[23:29:26] hello little toy boat
163
+
164
+ % tap run -- hello mittens --reverse
165
+ I[23:29:53] olleh mittens
166
+
167
+ Now lets use the previous results; they get loaded and added to the end of the inputs:
168
+
169
+ % tap run -- hello --use output.yml
170
+ I[23:31:32] hello goodnight moon
171
+ I[23:31:32] hello goodnight opus
172
+
173
+ === Config Files
174
+
175
+ So say you wanted static configs for a task. Make a configuration file:
176
+
177
+ % tap generate config goodnight
178
+
179
+ Set the configurations here and they get used by the task:
180
+
181
+ [config/goodnight.yml]
182
+ ###############################################################################
183
+ # Goodnight configuration
184
+ ###############################################################################
185
+
186
+ message: good evening
187
+
188
+ As can be seen here:
189
+
190
+ % tap run -- goodnight moon
191
+ I[23:40:39] good evening moon
192
+
193
+ If you need to run a task with multiple sets of configurations, simply define an
194
+ array of configurations in the config file:
195
+
196
+ [config/goodnight.yml]
197
+ - message: good afternoon
198
+ - message: good evening
199
+ - message: goodnight
200
+
201
+ % tap run -- goodnight moon
202
+ I[23:42:46] good afternoon moon
203
+ I[23:42:46] good evening moon
204
+ I[23:42:46] goodnight moon
205
+
206
+ The --name option sets the config file used:
207
+
208
+ % tap run -- goodnight moon --name no_config_file
209
+ I[23:43:20] goodnight moon
210
+
211
+ === Tap Configuration
212
+
213
+ Tap itself is highly configurable. Say you think the run syntax is unnecessarily
214
+ verbose; you can make command aliases to shorten it. Open the <tt>tap.yml</tt>
215
+ file in your root directory and set the following:
216
+
217
+ [tap.yml]
218
+ alias:
219
+ --: [run, --]
220
+ -T: [run, -T]
221
+
222
+ Now:
223
+
224
+ % tap -- hello world
225
+ I[23:43:59] hello world
226
+
227
+ % tap -T
228
+ sample:
229
+ goodnight # your basic goodnight moon task
230
+ hello # your basic hello world task
231
+ tap:
232
+ dump # the default dump task
233
+ rake # run rake tasks
234
+
235
+ Global configurations can go in the <tt>~/.tap.yml</tt> file. Using configurations,
236
+ you can specify directory aliases, options, gems, and even additional paths to load
237
+ as if they were gems.
data/lib/tap.rb CHANGED
@@ -1,69 +1,30 @@
1
1
  require 'rubygems'
2
2
 
3
3
  require 'yaml' # expensive to load
4
- require 'logger'
5
- require 'ostruct'
6
4
  require 'thread'
7
- require 'erb'
8
-
9
- autoload(:GetoptLong, 'getoptlong')
10
- autoload(:PP, "pp")
11
5
 
12
6
  # Apply version-specific patches
13
7
  case RUBY_VERSION
14
8
  when /^1.9/
15
- $: << File.dirname(__FILE__) + "/tap/patches/ruby19"
9
+ $: << File.expand_path(File.dirname(__FILE__) + "/tap/patches/ruby19")
16
10
 
17
11
  # suppresses TDoc warnings
18
12
  $DEBUG_RDOC ||= nil
19
13
  end
20
14
 
21
- # Loading activesupport piecemeal like this cuts the tap load time in half.
22
- gem 'activesupport'
23
-
24
- require 'active_support/core_ext/array/extract_options.rb'
25
- class Array #:nodoc:
26
- include ActiveSupport::CoreExtensions::Array::ExtractOptions
27
- end
28
- require 'active_support/core_ext/class.rb'
29
- require 'active_support/core_ext/module.rb'
30
- require 'active_support/core_ext/symbol.rb'
31
- require 'active_support/core_ext/string.rb'
32
- require 'active_support/core_ext/blank.rb'
33
- require 'active_support/core_ext/hash/keys.rb'
34
- require 'active_support/dependencies'
35
- require 'active_support/clean_logger'
36
- class Hash #:nodoc:
37
- include ActiveSupport::CoreExtensions::Hash::Keys
38
- end
39
-
40
- $:.unshift File.dirname(__FILE__)
15
+ $:.unshift File.expand_path(File.dirname(__FILE__))
41
16
 
42
17
  require 'tap/constants'
43
- class String # :nodoc:
44
- include Tap::Constants
45
- end
46
18
 
47
- require 'tap/support/aggregator'
48
- require 'tap/support/audit'
49
- require 'tap/support/batchable_methods'
50
- require 'tap/support/batchable'
51
- require 'tap/support/class_configuration'
52
- require 'tap/support/command_line_methods'
53
- require 'tap/support/configurable'
54
- require 'tap/support/configurable_methods'
55
- require 'tap/support/executable'
56
- require 'tap/support/executable_queue'
57
- require 'tap/support/logger'
58
- require 'tap/support/run_error'
59
- require 'tap/support/shell_utils'
60
- require 'tap/support/validation'
19
+ # require in order...
61
20
  require 'tap/env'
62
21
  require 'tap/app'
63
22
  require 'tap/task'
64
23
  require 'tap/file_task'
65
24
  require 'tap/workflow'
66
- require 'tap/dump'
25
+
26
+ require 'tap/support/declarations'
27
+ Tap.extend Tap::Support::Declarations
67
28
 
68
29
  # Apply platform-specific patches
69
30
  # case RUBY_PLATFORM