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
data/Command Reference DELETED
@@ -1,99 +0,0 @@
1
- = Tap from the Command Line
2
-
3
- The tap command is the gateway for the execution of sub-commands. To get help for tap, type:
4
-
5
- % tap --help
6
-
7
- The tap command sets up the execution environment from 'tap.yml', if it exists, and passes control to the specified sub-command. Sub-command help can be obtained using:
8
-
9
- % tap [sub-command] --help
10
-
11
- == run
12
-
13
- 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:
14
-
15
- % tap run sample/task
16
- % tap run -- sample/task --key=value input_one -- another/task input_two
17
-
18
- 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 run itself can be specified before the first option break.
19
-
20
- % tap run --debug -- sample/task --key=value
21
-
22
- Here run receives the '--debug' option and sample/task receives the '--key=value' option'. <em>NOTE</em> 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:
23
-
24
- % tap run --help
25
- % tap run sample/task --help
26
-
27
- Inputs work the same way. For example:
28
-
29
- % tap run -- sample/task --key=value one -- another/task two three
30
-
31
- Specifies the following:
32
-
33
- t1 = app.task('sample/task', :key => 'value')
34
- t1.enq('one')
35
-
36
- t2 = app.task('another/task')
37
- t2.enq('two', 'three')
38
-
39
- Any number of tasks, configurations, and inputs may be specified in this way. As a special note, rake tasks can be specified as well. If the app cannot find a tap task by the specified name, rake is loaded (using the same loading rules as the rake command) and run tries to find a corresponding rake task. ENV options can be specified in the rake statement.
40
-
41
- % tap run -- test KEY=value
42
-
43
- === YAML inputs
44
-
45
- 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}.
46
-
47
- On *nix, just hit enter to get the next line:
48
-
49
- % tap run -- sample/task '---
50
- > number: 1'
51
-
52
- On Windows, you need to pull some tricks to get newlines into your argument. Cleverly use a caret to ignore the next line feed:
53
-
54
- % tap run -- sample/task '---^
55
- More?
56
- More? number: 1'
57
-
58
- Notice that pressing enter _every other line_ is what actually puts the "\n" into the parameter. Keep using carets to enter more lines. The syntax on Windows isn't exactly pretty, but it 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:
59
-
60
- % ruby C:/ruby/bin/tap run -- sample/task '---^
61
- More?
62
- More? number: 1'
63
-
64
- == generate/destroy
65
-
66
- Generate and destory launch generator scripts, the same as in Rails. By default Tap provides generators for:
67
-
68
- root:: the basic Tap directory structure
69
- task:: a Tap:Task and test for the task
70
- file_task:: a Tap::FileTask and test for the task
71
- workflow:: a Tap::Workflow and test for the workflow
72
- config:: a yaml config file for the specified task
73
- command:: a new subcommand
74
- generator:: a new generator
75
-
76
- Some examples:
77
-
78
- % tap generate root .
79
- % tap generate task sample_task
80
- % tap generate config sample_task
81
-
82
- % tap destroy config sample_task
83
- % tap destroy task sample_task
84
- % tap destroy root .
85
-
86
- == console
87
-
88
- Console opens an irb session with Tap loaded and configured using 'tap.yml'. Console defines a variable 'app' referencing Tap::App.instance, for easy access.
89
-
90
- % tap console
91
- irb(main):001:0> app.log(:hello)
92
- I[17:18:53] hello
93
- => true
94
- irb(main):002:0>
95
-
96
- For actively testing your code, remember that many of your files will be loaded using Dependencies (from {ActiveSupport}[http://rubyforge.org/projects/activesupport/]). You can modify your code, clear the dependencies, and observe the changes within a single session. The command is:
97
-
98
- irb(main):003:0> app.reload
99
- # => [... an array of unloaded constants ...]
data/Rakefile DELETED
@@ -1,127 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
- require 'rake/gempackagetask'
5
-
6
- $:.unshift "./lib"
7
- require 'tap/constants'
8
- require 'tap/patches/rake/testtask.rb'
9
-
10
- desc 'Default: Run tests.'
11
- task :default => :test
12
-
13
- #
14
- # Gem specification
15
- #
16
- Gem::manage_gems
17
-
18
- spec = Gem::Specification.new do |s|
19
- s.name = "tap"
20
- s.version = Tap::VERSION
21
- s.author = "Simon Chiang"
22
- s.email = "simon.chiang@uchsc.edu"
23
- s.homepage = Tap::WEBSITE
24
- s.platform = Gem::Platform::RUBY
25
- s.summary = "A framework for configurable, distributable, and easy-to-use tasks and workflow applications."
26
- s.files = File.read("Manifest.txt").split("\n").select {|f| f !~ /^\s*#/ && !File.directory?(f) }
27
- s.require_path = "lib"
28
- s.rubyforge_project = "tap"
29
- s.test_file = "test/tap_test_suite.rb"
30
- s.bindir = "bin"
31
- s.executables = ["tap"]
32
- s.default_executable = "tap"
33
-
34
- s.has_rdoc = true
35
- s.rdoc_options << '--title' << 'Tap - Task Application' << '--main' << 'README'
36
- s.extra_rdoc_files = ["README", "MIT-LICENSE", "History", "Tutorial", "Basic Overview", "Command Reference"]
37
- s.add_dependency("activesupport", ">=2.0.1")
38
- end
39
-
40
- Rake::GemPackageTask.new(spec) do |pkg|
41
- pkg.need_tar = true
42
- end
43
-
44
- desc 'Prints the gem manifest.'
45
- task :print_manifest do
46
- spec.files.each do |file|
47
- puts file
48
- end
49
- end
50
-
51
- desc 'Run tests.'
52
- Rake::TestTask.new(:test) do |t|
53
- t.test_files = if ENV['check']
54
- Dir.glob( File.join('test', "**/*#{ENV['check']}*_check.rb") )
55
- else
56
- Dir.glob( File.join('test', ENV['pattern'] || '**/*_test.rb') ).delete_if do |filename|
57
- filename =~ /test\/check/
58
- end
59
- end
60
-
61
- t.verbose = true
62
- t.warning = true
63
- end
64
-
65
- #
66
- # Documentation tasks
67
- #
68
-
69
- desc 'Generate documentation.'
70
- Rake::RDocTask.new(:rdoc) do |rdoc|
71
- require 'tap/support/tdoc'
72
-
73
- rdoc.rdoc_dir = 'rdoc'
74
- rdoc.title = 'tap'
75
- rdoc.template = 'tap/support/tdoc/tdoc_html_template'
76
- rdoc.options << '--line-numbers' << '--inline-source' << '--fmt' << 'tdoc'
77
- rdoc.rdoc_files.include('README', 'MIT-LICENSE', "History", "Tutorial", "Basic Overview", "Command Reference")
78
- rdoc.rdoc_files.include('lib/tap/**/*.rb')
79
- end
80
-
81
- desc 'Generate website.'
82
- task :website => [:rdoc] do |t|
83
- require 'tap'
84
-
85
- # temporary
86
- $: << File.dirname(__FILE__) + "/tap/simple_site/lib"
87
- $: << File.dirname(__FILE__) + "/tap/ddb/lib"
88
- Dependencies.load_paths << File.dirname(__FILE__) + "/tap/simple_site/lib"
89
- Dependencies.load_paths << File.dirname(__FILE__) + "/tap/ddb/lib"
90
-
91
- require 'simple_site'
92
-
93
- app = Tap::App.instance
94
-
95
- app['pkg'] = "pkg/website-#{Tap::VERSION}"
96
- app['content'] = 'website/content'
97
- app['views'] = 'website/views'
98
- app.run 'simple_site/compile', '.'
99
-
100
- cp_r "rdoc", app.filepath('pkg', "rdoc")
101
- end
102
-
103
- #
104
- # Hoe tasks
105
- #
106
-
107
- desc 'Install the package as a gem'
108
- task :install_gem => [:package] do
109
- sh "#{'sudo ' unless WINDOZE}gem install pkg/*.gem"
110
- end
111
-
112
- desc "Publish Website to RubyForge"
113
- task :publish_website => [:website] do
114
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
115
- host = "#{config["username"]}@rubyforge.org"
116
-
117
- rsync_args = "-v -c -r"
118
- remote_dir = "/var/www/gforge-projects/tap"
119
- local_dir = "pkg/website-#{Tap::VERSION}"
120
-
121
- sh %{rsync #{rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
122
- end
123
-
124
- desc 'Show information about the gem.'
125
- task :debug_gem do
126
- puts spec.to_ruby
127
- end
data/Tutorial DELETED
@@ -1,287 +0,0 @@
1
- = Quick Start Tutorial
2
-
3
- This tutorial demonstrates the basic use of tap from the command line, how to:
4
-
5
- * generate and run a task
6
- * generate and run a command
7
-
8
- === Task Basics
9
-
10
- Begin by creating a tap root directory structure:
11
-
12
- % tap generate root /path/to/root_dir
13
- % cd /path/to/root_dir
14
-
15
- Make a task:
16
-
17
- % tap generate task sample/task
18
-
19
- Test the task (in fact using the rake test task):
20
-
21
- % tap run test
22
-
23
- Get help for the task:
24
-
25
- % tap run -- sample/task --help
26
- Sample::Task
27
-
28
- Replace with a description. The default task simply
29
- demonstrates the use of a config and logging.
30
- Usage:
31
- Replace with usage instructions
32
-
33
- Options:
34
- --key a sample config ('value')
35
- --help Print this help.
36
- --debug Trace execution and debug
37
- --use Loads inputs from file.
38
- --iterate Iterates over inputs.
39
-
40
- Run the task in the most basic way:
41
-
42
- % tap run sample/task input_one
43
- ctl-i prints information
44
- ctl-c interupts execution
45
- beginning run...
46
- I[21:32:28] sample/task input_one was processed with value
47
-
48
- Run the task, setting the 'key' configuration and iterating over several inputs:
49
-
50
- % tap run -- sample/task --key='the new value' --iterate one two three
51
- ctl-i prints information
52
- ctl-c interupts execution
53
- beginning run...
54
- I[21:33:31] sample/task one was processed with the new value
55
- I[21:33:31] sample/task two was processed with the new value
56
- I[21:33:31] sample/task three was processed with the new value
57
-
58
- Run multiple tasks, or in this case the same task twice, followed by a dump task. The tasks are separated into 'rounds' of execution, where the rounds are indicated by '--' and '--+' respectively. The sample tasks in the first round run to completion before tap runs the dump task. Normally the dump task saves results to a file you specify, but with no specified file (as below) the dump is to the console:
59
-
60
- % tap run -- sample/task one -- sample/task two --+ tap/dump
61
- ctl-i prints information
62
- ctl-c interupts execution
63
- beginning run...
64
- I[21:50:40] sample/task one was processed with value
65
- I[21:50:40] sample/task two was processed with value
66
- # audit:
67
- # o-[] "two"
68
- # o-[sample/task] "two was processed with value"
69
- #
70
- # o-[] "one"
71
- # o-[sample/task] "one was processed with value"
72
- #
73
- # date: 2008-04-08 21:50:40
74
- ---
75
- sample/task (8603460):
76
- - one was processed with value
77
- sample/task (8602320):
78
- - two was processed with value
79
-
80
- Don't be thrown by the shuffled order in the dump -- the dump is valid YAML and represents the results hashed by task.
81
-
82
- Now navigate to and open the 'lib/sample/task.rb' file. Inside you can see the class definition, with comments indicating how to define additional configurations, add command line documentation, log activity, and define the process method. Let's change it up a bit:
83
-
84
- [lib/sample/task.rb]
85
- module Sample
86
- # == Description
87
- # A simple math task that multiplies an input by a
88
- # factor. Remember, strings can be multipled too!
89
- # === Usage
90
- # % tap run -- sample/task INPUT
91
- #
92
- class Task < Tap::Task
93
-
94
- # The sum of the inputs is multiplied by this
95
- # factor. String factors are converted to
96
- # an integer.
97
- config(:factor, 2) do |value| # a factor
98
- value.to_i
99
- end
100
-
101
- def process(input)
102
- result = input * factor
103
- log self.name, result
104
-
105
- result
106
- end
107
-
108
- end
109
- end
110
-
111
- The new configurations and documentation are immediately available:
112
-
113
- % tap run -- sample/task --help
114
- Sample::Task
115
-
116
- A simple math task that multiplies an input by a
117
- factor. Remember, strings can be multipled too!
118
- Usage:
119
- % tap run -- sample/task INPUT
120
-
121
- Options:
122
- --factor a factor (2)
123
- --help Print this help.
124
- --debug Trace execution and debug
125
- --use Loads inputs from file.
126
- --iterate Iterates over inputs.
127
-
128
- And the task is ready to go:
129
-
130
- % tap run -- sample/task "yo"
131
- ctl-i prints information
132
- ctl-c interupts execution
133
- beginning run...
134
- I[22:22:13] sample/task yo yo
135
-
136
- Make a configuration file for the task:
137
-
138
- % tap generate config sample/task
139
-
140
- You get documentation in the configuration file as well. We can set configurations here and have them be used by the task:
141
-
142
- [config/sample/task.yml]
143
- # Sample::Task configuration
144
-
145
- # The sum of the inputs is multiplied by this
146
- # factor. String factors are converted to
147
- # an integer.
148
- # a factor (2)
149
- factor: 3
150
-
151
- As can be seen here:
152
-
153
- % tap run -- sample/task yo
154
- ctl-i prints information
155
- ctl-c interupts execution
156
- beginning run...
157
- I[22:26:41] sample/task yo yo yo
158
-
159
- If you need to batch run the same task with the same inputs, but multiple sets of configurations, simply define an array of configurations in the config file:
160
-
161
- [config/sample/task.yml]
162
- # Sample::Task configuration
163
- - factor: 1
164
- - factor: 2
165
- - factor: 3
166
-
167
- % tap run -- sample/task yo
168
- ctl-i prints information
169
- ctl-c interupts execution
170
- beginning run...
171
- I[22:37:46] sample/task yo
172
- I[22:37:46] sample/task yo yo
173
- I[22:37:46] sample/task yo yo yo
174
-
175
- === Command Basics
176
-
177
- Now say you want to do something fancier than the basic execution provided by the run command. First, generate a new command:
178
-
179
- % tap generate command echo
180
-
181
- The new command is now available from tap:
182
-
183
- % tap echo --help
184
- tap echo {options} ARGS...
185
-
186
- The default command simply prints the input arguments
187
- and application information, then exits.
188
-
189
- Options:
190
- --help (-h) Print this help.
191
- --debug Specifies debug mode.
192
-
193
- % tap echo one two three
194
- Received: one, two, three
195
- state: 0 (READY) queue: 0 thread_queue: 0 threads: 0 results: 0
196
-
197
- The command script itself is very general and can be run through ruby directly. The tap command basically just sets up the environment using tap.yml and then loads the command script, hence you can do whatever you like within the command script. Lets open it up and change a few things:
198
-
199
- [cmd/echo.rb]
200
- # = Usage
201
- # tap echo {options} ARGS...
202
- #
203
- # = Description
204
- # Formats the inputs, then echoes them to the
205
- # 'echo/output.txt' file and to the console.
206
- #
207
-
208
- require 'tap'
209
- require 'tap/script'
210
-
211
- app = Tap::App.instance
212
-
213
- #
214
- # handle options
215
- #
216
-
217
- opts = [
218
- ['--help', '-h', GetoptLong::NO_ARGUMENT, "Print this help."],
219
- ['--debug', nil, GetoptLong::NO_ARGUMENT, "Specifies debug mode."]]
220
-
221
- Tap::Script.handle_options(*opts) do |opt, value|
222
- case opt
223
- when '--help'
224
- puts Tap::Script.usage(__FILE__, "Usage", "Description", "Information", :keep_headers => false)
225
- puts
226
- puts "Options:"
227
- puts Tap::Script.usage_options(opts)
228
- exit
229
-
230
- when '--debug'
231
- app.options.debug = true
232
-
233
- end
234
- end
235
-
236
- #
237
- # initialize some tasks
238
- #
239
-
240
- # transform the inputs
241
- t1 = Tap::Task.new do |task, *inputs|
242
- inputs.collect {|input| "echo #{input}" }.join("\n")
243
- end
244
-
245
- # write to a file
246
- t2 = Tap::FileTask.new do |task, input|
247
- target = "echo/output.txt"
248
-
249
- # backup existing files, and ensure the directory exists
250
- task.prepare(target)
251
-
252
- File.open(target, "wb") {|f| f << input }
253
- target
254
- end
255
-
256
- # now make a simple workflow
257
- app.sequence(t1, t2)
258
-
259
- #
260
- # enque, run, and print out the results
261
- #
262
-
263
- t1.enq(*ARGV)
264
- app.run
265
-
266
- app.results(t2).each do |target|
267
- puts "[#{target}]"
268
- puts File.read(target)
269
- end
270
-
271
- Now run the command a few times:
272
-
273
- % tap echo one two three
274
- [echo/output.txt]
275
- echo one
276
- echo two
277
- echo three
278
-
279
- % tap echo tip top tap
280
- [echo/output.txt]
281
- echo tip
282
- echo top
283
- echo tap
284
-
285
- You should find that the 'echo/output.txt' file exists with the 'tip top tap' result. Moreover a backup directory will exist with the 'one two three' result, due to the FileTask#prepare method.
286
-
287
-