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
@@ -1,17 +1,21 @@
1
1
  module Tap::Generator::Generators
2
- class CommandGenerator < Rails::Generator::NamedBase # :nodoc:
3
- def initialize(*args)
4
- super(*args)
5
- @destination_root = Tap::App.instance[:root]
6
- @app = Tap::App.instance
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- command_path = @app.relative_filepath(:root, @app[:cmd])
12
- m.directory class_path.empty? ? command_path : File.join(command_path, class_path)
13
- m.template "command.erb", File.join(command_path, class_name.underscore + ".rb")
2
+
3
+ # :startdoc::generator a new tap command
4
+ #
5
+ # Generates a new tap command under the cmd directory. The
6
+ # new command can be run from the command line using:
7
+ #
8
+ # % tap <command>
9
+ #
10
+ class CommandGenerator < Tap::Generator::Base
11
+
12
+ def manifest(m, command_name)
13
+ m.directory app['cmd']
14
+
15
+ template_files do |source, target|
16
+ m.template app.filepath('cmd', "#{command_name}.rb"), source, :command_name => command_name
14
17
  end
15
18
  end
19
+
16
20
  end
17
21
  end
@@ -1,34 +1,28 @@
1
- # = Usage
2
- # tap <%= file_name %> {options} ARGS...
1
+ # tap <%= command_name %> {options} ARGS...
3
2
  #
4
- # = Description
5
3
  # The default command simply prints the input arguments
6
4
  # and application information, then exits.
7
5
  #
8
6
 
9
- require 'tap'
10
-
11
- app = Tap::App.instance
7
+ env = Tap::Env.instance
8
+ app = Tap::App.instance
12
9
 
13
10
  #
14
11
  # handle options
15
12
  #
16
13
 
17
- opts = [
18
- ['--help', '-h', GetoptLong::NO_ARGUMENT, "Print this help."],
19
- ['--debug', nil, GetoptLong::NO_ARGUMENT, "Specifies debug mode."]]
20
-
21
- Tap::Support::CommandLine.handle_options(*opts) do |opt, value|
22
- case opt
23
- when '--help'
24
- puts Tap::Support::CommandLine.command_help(__FILE__, opts)
25
- exit
26
-
27
- when '--debug'
28
- app.options.debug = true
14
+ OptionParser.new do |opts|
15
+ opts.separator ""
16
+ opts.separator "options:"
29
17
 
18
+ opts.on("-h", "--help", "Show this message") do
19
+ opts.banner = Tap::Support::CommandLine.usage(__FILE__)
20
+ puts opts
21
+ exit
30
22
  end
31
- end
23
+
24
+ end.parse!(ARGV)
25
+
32
26
 
33
27
  #
34
28
  # add your script code here
@@ -1,33 +1,24 @@
1
1
  module Tap::Generator::Generators
2
- class ConfigGenerator < Rails::Generator::NamedBase # :nodoc:
3
- attr_accessor :formatted_yaml
2
+
3
+ # :startdoc::generator a config file for a task
4
+ #
5
+ # Generates a new config file for a task. The configurations, defaults,
6
+ # and documentation is determined from the task source file.
7
+ class ConfigGenerator < Tap::Generator::Base
8
+
9
+ config :doc, true, &c.switch # include documentation in the config
10
+
11
+ def env
12
+ Tap::Env.instance
13
+ end
4
14
 
5
- def initialize(argv, options)
6
- @app = Tap::App.instance
7
- name, @version = @app.deversion(argv[0])
8
- argv[0] = name
15
+ def manifest(m, name, config_name=name)
16
+ const = env.search(:tasks, name) or raise "unknown task: #{name}"
17
+ task_class = const.constantize or raise "unknown task: #{name}"
9
18
 
10
- super(argv, options)
11
-
12
- @destination_root = Tap::App.instance[:root]
13
- end
14
-
15
- def manifest
16
- record do |m|
17
- task = @app.task(class_name)
18
- self.formatted_yaml = task.class.configurations.format_yaml
19
-
20
- config_path = @app.relative_filepath(:root, @app[:config])
21
-
22
- if @version == nil
23
- # then get the next increment?
24
- # Tap::App.vglob(File.join(config_path, class_name.underscore + '.yml'))
25
- end
26
- version = @version == nil ? '' : "-#{@version}"
27
-
28
- m.directory File.join(config_path, class_path)
29
- m.template "config.erb", File.join(config_path, class_name.underscore + "#{version}.yml")
30
-
19
+ m.directory app['config']
20
+ m.file app.filepath('config', config_name + '.yml') do |file|
21
+ task_class.configurations.format_str((doc ? :doc : :nodoc), file)
31
22
  end
32
23
  end
33
24
 
@@ -0,0 +1,12 @@
1
+ ###############################################################################
2
+ # <%= receiver %> configuration<%= configurations.length > 1 ? 's' : '' %>
3
+ ###############################################################################
4
+ <% configurations.each do |key, config| %>
5
+
6
+ <% Comment.wrap(config.desc.to_s.split(/\r?\n/), 50, 2).each do |line| %>
7
+ # <%= line %>
8
+ <% end %>
9
+ <%= config.default == nil ? '#' : '' %><%= yamlize({key.to_s => config.default}) %>
10
+
11
+ <% end %>
12
+
@@ -0,0 +1,8 @@
1
+ ###############################################################################
2
+ # <%= receiver %> configuration<%= configurations.length > 1 ? 's' : '' %>
3
+ ###############################################################################
4
+ <% configurations.each do |key, config| %>
5
+ <%= config.default == nil ? '#' : ''%><%= yamlize({key.to_s => config.default}) %>
6
+
7
+ <% end %>
8
+
@@ -1,21 +1,26 @@
1
1
  require 'tap/generator/generators/task/task_generator'
2
2
 
3
3
  module Tap::Generator::Generators
4
- class FileTaskGenerator < TaskGenerator # :nodoc:
4
+
5
+ # :startdoc::generator a file_task and test
6
+ #
7
+ # Generates a new Tap::FileTask and associated test files.
8
+ class FileTaskGenerator < TaskGenerator
5
9
 
6
- def task_manifest(m)
7
- return unless options[:test]
10
+ def manifest(m, const_name)
11
+ const = super
8
12
 
9
- test_path = @app.relative_filepath(:root, @app[:test])
10
- m.directory File.join(test_path, class_name.underscore)
13
+ if test
14
+ test_dir = app.filepath('test', const.path, "test_#{const.basename}")
11
15
 
12
- method_test_path = File.join(test_path, class_name.underscore, "test_#{file_name.underscore}")
13
- m.directory method_test_path
14
- m.directory File.join(method_test_path, "input")
15
- m.directory File.join(method_test_path, "expected")
16
+ m.directories test_dir, %W{
17
+ input
18
+ expected
19
+ }
16
20
 
17
- m.file "file.txt", File.join(method_test_path, "input", "file.txt")
18
- m.file "file.yml", File.join(method_test_path, "expected", "file.yml")
21
+ m.template File.join(test_dir, 'input/file.txt'), "file.txt", :const => const, :test_dir => test_dir
22
+ m.template File.join(test_dir, 'expected/result.yml'), "result.yml", :const => const, :test_dir => test_dir
23
+ end
19
24
  end
20
25
 
21
26
  end
@@ -1,2 +1,11 @@
1
- Line One
2
- Line Two
1
+ absquatulate - verb: This amusing, vivid, and expressive word is a bit of a jocular, contrived slang. To absquatulate is to decamp, to scram, to take off in a hell of a hurry like a fugitive heading into the woods.
2
+
3
+ algorism - noun: This is the name of the Arabic numbering system, using the figures 1 to 9 plus the zero. The derivation is from Middle Latin algorismus, from the Arabic al (the) plus Khuwarizmi, the surname of a ninth-century Arabic mathematician. Algorithm is sometimes used as a synonym, but is also used to designate a set of rules for the solution of a mathematical problem in a finite number of steps. These words are entirely unrelated to algolagnia, with its very different meaning and derivation.
4
+
5
+ defenestration - verb: Defenestration is the act of throwing someone (yes, someone!) or something out of a window. To defenestrate a person or thing is to engage in this activity - a strange one indeed, since these words are more commonly applied to situations where what is thrown out of the window is a person, rather than a thing. It is surprising, in view of what must be the infrequency of this type of activity, that there exists word for it, but then, there exists a word for just about everything.
6
+
7
+ macaronic - adj: This peculiar word, a jocular concoction from macaroni, is applied, in a narrow sense, to language characterized by a mixture of Latin and non-Latin words, or by non-Latin words given phony Latin endings; in a broader sense, to prose or verse composed of any mixture of languages; in its broadest sense, to anything mixed or jumbled.
8
+
9
+ trumpery - noun: Trumpery is worthless stuff.
10
+
11
+ usufruct - noun: Usufruct is a term used in law primarily, to denote one's right to enjoy the use and benefits flowing from the use of another's property, without the ownership of it and without the right to harm or waste or destroy it.
@@ -0,0 +1,6 @@
1
+ ---
2
+ - 111
3
+ - 155
4
+ - 123
5
+ - 125
6
+ - 56
@@ -1,40 +1,33 @@
1
- # == Description
2
- # Replace with a description. The default task reads
3
- # in the lines of a text file and dumps them as YAML
4
- # into a yaml file.
5
- # === Usage
6
- # Replace with usage instructions
1
+ <% redirect do |target| %># <%= const.name %>::manifest <replace with manifest summary>
2
+ # <replace with command line description>
3
+
4
+ # <%= const.const_name %> Documentation
5
+ # This example FileTask counts the specified letters
6
+ # in a source file and writes the counts to a target
7
+ # file as YAML.
7
8
  #
8
- class <%= class_name_without_nesting %> < Tap::FileTask
9
- # use config to set task configurations
10
- # configs have accessors by default
11
-
12
- config :key, 'value' # a sample config
13
-
14
- # process defines what the task does; use the
15
- # same number of inputs to enque the task
16
- # as specified here
17
- def process(filepath)
9
+ class <%= const.const_name %> < Tap::FileTask
10
+
11
+ # <config file documentation>
12
+ config :letters, ['a','e','i','o','u'], &c.array # a list of letters to count
18
13
 
19
- # infer an output filepath relative to the :data directory,
20
- # (this is convenient for testing) while changing the
21
- # basename of filepath to 'yml'. See FileTask#filepath
22
- # for filepaths based on the task name.
23
- target = app.filepath(:data, basename(filepath, '.yml') )
14
+ def process(source, target)
24
15
 
25
- # prepare ensures the parent directory for
26
- # output exists, and that output does not;
27
- # any existing file is backed up and reverts
28
- # in the event of an error
16
+ # prepare ensures the parent directory for target
17
+ # exists and, if necessary, backs up the existing
18
+ # target file (which is restored on error)
29
19
  prepare(target)
30
-
20
+
31
21
  # now perform the task...
32
- array = File.read(filepath).split(/\r?\n/)
22
+ str = File.read(source)
23
+ letter_count = letters.collect do |letter|
24
+ str.count(letter)
25
+ end
26
+
33
27
  File.open(target, "wb") do |file|
34
- file << array.to_yaml
28
+ file << letter_count.to_yaml
35
29
  end
36
-
30
+
37
31
  target
38
32
  end
39
-
40
- end
33
+ end <% module_nest(const.nesting, ' ') { target } end %>
@@ -1,31 +1,27 @@
1
- require File.join(File.dirname(__FILE__), '<%= '../' * class_nesting_depth %>tap_test_helper.rb')
2
- require '<%= class_path.empty? ? file_name : File.join(class_path, file_name) %>'
1
+ require File.join(File.dirname(__FILE__), '<%= '../' * const.nesting_depth %>tap_test_helper.rb')
2
+ require '<%= const.path %>'
3
3
 
4
- class <%= class_name %>Test < Test::Unit::TestCase
4
+ class <%= const.name %>Test < Test::Unit::TestCase
5
5
  acts_as_tap_test
6
6
 
7
- def test_<%= file_name.underscore %>
8
- # assert_expected_result_files provides a list of the
9
- # files in '<%= class_name_without_nesting.underscore %>/test_<%= file_name.underscore %>/input'
10
- # and expects that the block makes a list of output
11
- # files in '<%= class_name_without_nesting.underscore %>/test_<%= file_name.underscore %>/output'
12
- #
13
- # These outputs are compared by content with the
14
- # files in '<%= class_name_without_nesting.underscore %>/test_<%= file_name.underscore %>/expected'
15
- #
16
- # The output directory is cleaned up by default. To
17
- # preserve it, set the KEEP_OUTPUTS env variable:
18
- #
7
+ def test_<%= const.basename %>
8
+ # Use assert_files to test file transform tasks. The block
9
+ # recieves the method input files and compares the results
10
+ # to the method expected files.
11
+
12
+ # Generated files are often placed in method output, as it
13
+ # is cleaned up each test. To keep output files, set the
14
+ # KEEP_OUTPUTS variable:
19
15
  # % rake test keep_outputs=true
20
-
21
- t = <%= class_name %>.new
16
+
17
+ t = <%= const.name %>.new
22
18
  assert_files do |input_files|
23
- input_files.each {|file| t.enq(file)}
24
-
25
- with_config :directories => {:data => 'output'} do
26
- app.run
19
+ input_files.each do |source|
20
+ target = method_filepath(:output, 'result.yml')
21
+ t.enq(source, target)
27
22
  end
28
-
23
+
24
+ app.run
29
25
  app.results(t)
30
26
  end
31
27
  end
@@ -1,41 +1,55 @@
1
1
  require 'tap/root'
2
2
 
3
3
  module Tap::Generator::Generators
4
- class RootGenerator < Rails::Generator::NamedBase # :nodoc:
5
- def initialize(*args)
6
- super(*args)
7
- Tap::App.instance.root = File.join(Tap::App.instance[:root], class_path, file_name)
8
- @destination_root = Tap::App.instance[:root]
9
- end
10
-
11
- def manifest
12
- record do |m|
13
- # directories
14
- m.directory "lib"
15
- #m.directory "config"
16
- m.directory "test"
17
-
18
- # remove these -- they will be created from
19
- # a server generator in the future
20
- #m.directory "server/config"
21
- #m.directory "server/test"
22
- #m.directory "server/lib/tasks"
4
+
5
+ # :startdoc::generator a basic tap directory structure
6
+ #
7
+ # Generates a tap root directory structure:
8
+ #
9
+ # root
10
+ # |- Rakefile
11
+ # |- lib
12
+ # |- sample.gemspec
13
+ # |- tap.yml
14
+ # |- tapfile.rb
15
+ # `- test
16
+ # |- tap_test_helper.rb
17
+ # |- tap_test_suite.rb
18
+ # `- tapfile_test.rb
19
+ #
20
+ class RootGenerator < Tap::Generator::Base
23
21
 
24
- # files
25
- template_dir = File.dirname(__FILE__) + "/templates"
26
- Dir.glob(template_dir + "/**/*").each do |fname|
27
- next if File.directory?(fname)
28
-
29
- # skip server files for now... later
30
- # the files will simply be removed
31
- next if fname =~ /server/
32
- next if fname =~ /config/
33
- next if fname =~ /process_tap_request/
22
+ # ::args ROOT, PROJECT_NAME=basename(ROOT)
23
+ def manifest(m, root, project_name=File.basename(root))
24
+ project_name = 'project' if project_name == '.'
25
+ r = Tap::Root.new(root)
34
26
 
35
- fname = Tap::Root.relative_filepath(template_dir, fname)
36
- m.template fname, fname
27
+ m.directory r.root
28
+ m.directory r['lib']
29
+
30
+ template_files do |source, target|
31
+ case
32
+ when File.directory?(source)
33
+ m.directory r[target]
34
+ when target == 'gemspec'
35
+ m.template r[project_name + '.gemspec'], source, :project_name => project_name
36
+ when target == 'tapfile'
37
+ m.template r['tapfile.rb'], source, :project_name => project_name
38
+ else
39
+ m.template r[target], source, :project_name => project_name
37
40
  end
38
41
  end
42
+
43
+ # m.file(r['tap.yml']) do |file|
44
+ # Tap::App.configurations.format_str(:doc, file) do |templater|
45
+ # next unless templater.receiver == Tap::Root
46
+ #
47
+ # templater.configurations.each do |(key, config)|
48
+ # config.default = nil if key.to_s == 'root'
49
+ # end
50
+ # end
51
+ # Tap::Env.configurations.format_str(:doc, file)
52
+ # end
39
53
  end
40
54
  end
41
55
  end
@@ -3,61 +3,84 @@ require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rake/gempackagetask'
5
5
 
6
- # tasks
7
- desc 'Default: Run tests.'
8
- task :default => :test
6
+ require 'tap/constants'
7
+ require 'tap/patches/rake/testtask.rb'
9
8
 
10
- desc 'Run tests.'
11
- Rake::TestTask.new(:test) do |t|
9
+ #
10
+ # Gem specification
11
+ #
12
+
13
+ def gemspec
14
+ data = File.read('<%= project_name %>.gemspec')
15
+ spec = nil
16
+ Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
17
+ spec
18
+ end
19
+
20
+ Rake::GemPackageTask.new(gemspec) do |pkg|
21
+ pkg.need_tar = true
22
+ end
23
+
24
+ desc 'Prints the gemspec manifest.'
25
+ task :print_manifest do
26
+ # collect files from the gemspec, labeling
27
+ # with true or false corresponding to the
28
+ # file existing or not
29
+ files = gemspec.files.inject({}) do |files, file|
30
+ files[File.expand_path(file)] = [File.exists?(file), file]
31
+ files
32
+ end
12
33
 
13
- # Here the current load paths are used to define the load
14
- # paths in the test. This is convenient for development
15
- # but doesn't have to be here. Note the patch is to
16
- # allow spaces in the lib paths, as you find on Windows.
17
- require 'tap/patches/rake/testtask'
18
- t.libs = $: + ['lib']
34
+ # gather non-rdoc/pkg files for the project
35
+ # and add to the files list if they are not
36
+ # included already (marking by the absence
37
+ # of a label)
38
+ Dir.glob("**/*").each do |file|
39
+ next if file =~ /^(rdoc|pkg)/ || File.directory?(file)
40
+
41
+ path = File.expand_path(file)
42
+ files[path] = ["", file] unless files.has_key?(path)
43
+ end
19
44
 
20
- t.pattern = 'test/**/*_test.rb'
21
- t.verbose = true
22
- t.warning = true
45
+ # sort and output the results
46
+ files.values.sort_by {|exists, file| file }.each do |entry|
47
+ puts "%-5s : %s" % entry
48
+ end
23
49
  end
24
50
 
51
+ #
52
+ # Documentation tasks
53
+ #
54
+
25
55
  desc 'Generate documentation.'
26
56
  Rake::RDocTask.new(:rdoc) do |rdoc|
27
- # options to specify TDoc
28
- require 'tap/support/tdoc'
29
- rdoc.template = 'tap/support/tdoc/tdoc_html_template'
30
- rdoc.options << '--fmt' << 'tdoc'
57
+ spec = gemspec
31
58
 
32
59
  rdoc.rdoc_dir = 'rdoc'
33
- rdoc.title = '<%= file_name %>'
34
- rdoc.template = 'tap/support/tdoc/tdoc_html_template'
60
+ rdoc.title = '<%= project_name %>'
35
61
  rdoc.options << '--line-numbers' << '--inline-source'
36
- rdoc.rdoc_files.include('ReadMe.txt')
37
- rdoc.rdoc_files.include('lib/**/*.rb')
62
+ rdoc.rdoc_files.include( spec.extra_rdoc_files )
63
+ rdoc.rdoc_files.include( spec.files.select {|file| file =~ /^lib.*\.rb$/} )
64
+
65
+ # Using Tdoc to template your Rdoc will result in configurations being
66
+ # listed with documentation in a subsection following attributes. Not
67
+ # necessary, but nice.
68
+ require 'tap/support/tdoc'
69
+ rdoc.template = 'tap/support/tdoc/tdoc_html_template'
70
+ rdoc.options << '--fmt' << 'tdoc'
38
71
  end
39
72
 
40
73
  #
41
- # Gem specification
74
+ # Test tasks
42
75
  #
43
76
 
44
- spec = Gem::Specification.new do |s|
45
- s.name = "<%= file_name %>"
46
- s.version = "0.0.1"
47
- s.author = "Your Name Here"
48
- #s.email = "your.email@pubfactory.edu"
49
- #s.homepage = "http://rubyforge.org/projects/gemname/"
50
- s.platform = Gem::Platform::RUBY
51
- s.summary = "Add Description"
52
- s.files = Dir.glob("{test,lib}/**/*") + ["Rakefile", "ReadMe.txt"]
53
- s.require_path = "lib"
54
- s.test_file = "test/tap_test_suite.rb"
55
-
56
- s.has_rdoc = true
57
- s.extra_rdoc_files = ["ReadMe.txt"]
58
- s.add_dependency("tap", ">= <%= Tap::VERSION %>")
77
+ desc 'Default: Run tests.'
78
+ task :default => :test
79
+
80
+ desc 'Run tests.'
81
+ Rake::TestTask.new(:test) do |t|
82
+ t.test_files = Dir.glob( File.join('test', ENV['pattern'] || '**/*_test.rb') )
83
+ t.verbose = true
84
+ t.warning = true
59
85
  end
60
86
 
61
- Rake::GemPackageTask.new(spec) do |pkg|
62
- pkg.need_tar = true
63
- end