tap 0.8.0 → 0.9.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 (185) hide show
  1. data/Basic Overview +151 -0
  2. data/Command Reference +99 -0
  3. data/History +24 -0
  4. data/MIT-LICENSE +1 -1
  5. data/README +29 -57
  6. data/Rakefile +30 -37
  7. data/Tutorial +243 -191
  8. data/bin/tap +66 -35
  9. data/lib/tap.rb +47 -29
  10. data/lib/tap/app.rb +700 -342
  11. data/lib/tap/{script → cmd}/console.rb +0 -0
  12. data/lib/tap/{script → cmd}/destroy.rb +0 -0
  13. data/lib/tap/{script → cmd}/generate.rb +0 -0
  14. data/lib/tap/cmd/run.rb +156 -0
  15. data/lib/tap/constants.rb +4 -0
  16. data/lib/tap/dump.rb +57 -0
  17. data/lib/tap/env.rb +316 -0
  18. data/lib/tap/file_task.rb +106 -109
  19. data/lib/tap/generator.rb +4 -1
  20. data/lib/tap/generator/generators/command/USAGE +6 -0
  21. data/lib/tap/generator/generators/command/command_generator.rb +17 -0
  22. data/lib/tap/generator/generators/{script/templates/script.erb → command/templates/command.erb} +10 -10
  23. data/lib/tap/generator/generators/config/USAGE +21 -0
  24. data/lib/tap/generator/generators/config/config_generator.rb +17 -7
  25. data/lib/tap/generator/generators/file_task/USAGE +3 -0
  26. data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -0
  27. data/lib/tap/generator/generators/file_task/templates/file.txt +2 -0
  28. data/lib/tap/generator/generators/file_task/templates/file.yml +3 -0
  29. data/lib/tap/generator/generators/file_task/templates/task.erb +26 -20
  30. data/lib/tap/generator/generators/file_task/templates/test.erb +20 -10
  31. data/lib/tap/generator/generators/generator/generator_generator.rb +1 -1
  32. data/lib/tap/generator/generators/generator/templates/generator.erb +21 -12
  33. data/lib/tap/generator/generators/root/templates/Rakefile +33 -24
  34. data/lib/tap/generator/generators/root/templates/tap.yml +28 -31
  35. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +1 -0
  36. data/lib/tap/generator/generators/task/USAGE +3 -0
  37. data/lib/tap/generator/generators/task/task_generator.rb +18 -5
  38. data/lib/tap/generator/generators/task/templates/task.erb +7 -12
  39. data/lib/tap/generator/generators/task/templates/test.erb +10 -11
  40. data/lib/tap/generator/generators/workflow/templates/task.erb +1 -1
  41. data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
  42. data/lib/tap/patches/rake/rake_test_loader.rb +8 -0
  43. data/lib/tap/patches/rake/testtask.rb +55 -0
  44. data/lib/tap/patches/ruby19/backtrace_filter.rb +51 -0
  45. data/lib/tap/patches/ruby19/parsedate.rb +16 -0
  46. data/lib/tap/root.rb +172 -67
  47. data/lib/tap/script.rb +70 -336
  48. data/lib/tap/support/aggregator.rb +55 -0
  49. data/lib/tap/support/audit.rb +281 -280
  50. data/lib/tap/support/batchable.rb +59 -0
  51. data/lib/tap/support/class_configuration.rb +279 -0
  52. data/lib/tap/support/configurable.rb +92 -0
  53. data/lib/tap/support/configurable_methods.rb +296 -0
  54. data/lib/tap/support/executable.rb +98 -0
  55. data/lib/tap/support/executable_queue.rb +82 -0
  56. data/lib/tap/support/logger.rb +9 -15
  57. data/lib/tap/support/rake.rb +43 -54
  58. data/lib/tap/support/run_error.rb +32 -13
  59. data/lib/tap/support/shell_utils.rb +47 -0
  60. data/lib/tap/support/tdoc.rb +9 -8
  61. data/lib/tap/support/tdoc/config_attr.rb +40 -16
  62. data/lib/tap/support/validation.rb +77 -0
  63. data/lib/tap/support/versions.rb +36 -36
  64. data/lib/tap/task.rb +276 -482
  65. data/lib/tap/test.rb +20 -261
  66. data/lib/tap/test/env_vars.rb +7 -5
  67. data/lib/tap/test/file_methods.rb +126 -121
  68. data/lib/tap/test/subset_methods.rb +86 -45
  69. data/lib/tap/test/tap_methods.rb +271 -0
  70. data/lib/tap/workflow.rb +174 -46
  71. data/test/app/config/another/task.yml +1 -0
  72. data/test/app/config/erb.yml +2 -1
  73. data/test/app/config/some/task.yml +1 -0
  74. data/test/app/config/template.yml +2 -6
  75. data/test/app_test.rb +1241 -1008
  76. data/test/env/test_configure/recurse_a.yml +2 -0
  77. data/test/env/test_configure/recurse_b.yml +2 -0
  78. data/test/env/test_configure/tap.yml +23 -0
  79. data/test/env/test_load_env_config/dir/tap.yml +3 -0
  80. data/test/env/test_load_env_config/recurse_a.yml +2 -0
  81. data/test/env/test_load_env_config/recurse_b.yml +2 -0
  82. data/test/env/test_load_env_config/tap.yml +3 -0
  83. data/test/env_test.rb +198 -0
  84. data/test/file_task_test.rb +70 -53
  85. data/{lib/tap/generator/generators/package/USAGE → test/root/file.txt} +0 -0
  86. data/test/root_test.rb +621 -454
  87. data/test/script_test.rb +38 -174
  88. data/test/support/aggregator_test.rb +99 -0
  89. data/test/support/audit_test.rb +409 -416
  90. data/test/support/batchable_test.rb +74 -0
  91. data/test/support/{task_configuration_test.rb → class_configuration_test.rb} +106 -47
  92. data/test/{task/config/overriding.yml → support/configurable/config/configured.yml} +0 -0
  93. data/test/support/configurable_test.rb +295 -0
  94. data/test/support/executable_queue_test.rb +103 -0
  95. data/test/support/executable_test.rb +38 -0
  96. data/test/support/logger_test.rb +17 -17
  97. data/test/support/rake_test.rb +4 -2
  98. data/test/support/shell_utils_test.rb +24 -0
  99. data/test/support/tdoc_test.rb +265 -258
  100. data/test/support/validation_test.rb +54 -0
  101. data/test/support/versions_test.rb +38 -38
  102. data/test/tap_test_helper.rb +19 -5
  103. data/test/tap_test_suite.rb +5 -2
  104. data/test/task_base_test.rb +13 -104
  105. data/test/task_syntax_test.rb +300 -0
  106. data/test/task_test.rb +258 -381
  107. data/test/test/env_vars_test.rb +40 -40
  108. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/one.txt +0 -0
  109. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/two.txt +0 -0
  110. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/one.txt +0 -0
  111. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/two.txt +0 -0
  112. data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/one.txt +0 -0
  113. data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/two.txt +0 -0
  114. data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +1 -0
  115. data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_different_content}/expected/two.txt +0 -0
  116. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +1 -0
  117. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +1 -0
  118. data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_missing_expected_file}/expected/one.txt +0 -0
  119. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +1 -0
  120. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +1 -0
  121. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +1 -0
  122. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +1 -0
  123. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +1 -0
  124. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +1 -0
  125. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +1 -0
  126. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +1 -0
  127. data/test/test/file_methods_doc/test_sub/expected/one.txt +1 -0
  128. data/test/test/file_methods_doc/test_sub/expected/two.txt +1 -0
  129. data/test/test/file_methods_doc/test_sub/input/one.txt +1 -0
  130. data/test/test/file_methods_doc/test_sub/input/two.txt +1 -0
  131. data/test/test/file_methods_doc_test.rb +29 -0
  132. data/test/test/file_methods_test.rb +214 -143
  133. data/test/test/subset_methods_test.rb +111 -115
  134. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/a.txt +0 -0
  135. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/b.txt +0 -0
  136. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/a.txt +0 -0
  137. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/b.txt +0 -0
  138. data/test/test/tap_methods_test.rb +399 -0
  139. data/test/workflow_test.rb +101 -91
  140. metadata +86 -70
  141. data/lib/tap/generator/generators/package/package_generator.rb +0 -38
  142. data/lib/tap/generator/generators/package/templates/package.erb +0 -186
  143. data/lib/tap/generator/generators/script/USAGE +0 -0
  144. data/lib/tap/generator/generators/script/script_generator.rb +0 -17
  145. data/lib/tap/script/run.rb +0 -154
  146. data/lib/tap/support/batch_queue.rb +0 -162
  147. data/lib/tap/support/combinator.rb +0 -114
  148. data/lib/tap/support/task_configuration.rb +0 -169
  149. data/lib/tap/support/template.rb +0 -81
  150. data/lib/tap/support/templater.rb +0 -155
  151. data/lib/tap/version.rb +0 -4
  152. data/test/app/config/addition_template.yml +0 -6
  153. data/test/app_class_test.rb +0 -33
  154. data/test/check/binding_eval.rb +0 -23
  155. data/test/check/define_method_check.rb +0 -22
  156. data/test/check/dependencies_check.rb +0 -175
  157. data/test/check/inheritance_check.rb +0 -22
  158. data/test/support/batch_queue_test.rb +0 -320
  159. data/test/support/combinator_test.rb +0 -249
  160. data/test/support/template_test.rb +0 -122
  161. data/test/support/templater/erb.txt +0 -2
  162. data/test/support/templater/erb.yml +0 -2
  163. data/test/support/templater/somefile.txt +0 -2
  164. data/test/support/templater_test.rb +0 -192
  165. data/test/task/config/template.yml +0 -4
  166. data/test/task_class_test.rb +0 -170
  167. data/test/task_execute_test.rb +0 -262
  168. data/test/test/file_methods/test_assert_expected/expected/file.txt +0 -1
  169. data/test/test/file_methods/test_assert_expected/expected/folder/file.txt +0 -1
  170. data/test/test/file_methods/test_assert_expected/input/file.txt +0 -1
  171. data/test/test/file_methods/test_assert_expected/input/folder/file.txt +0 -1
  172. data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
  173. data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
  174. data/test/test/file_methods/test_file_compare/expected/output_1.txt +0 -3
  175. data/test/test/file_methods/test_file_compare/expected/output_2.txt +0 -1
  176. data/test/test/file_methods/test_file_compare/input/input_1.txt +0 -3
  177. data/test/test/file_methods/test_file_compare/input/input_2.txt +0 -3
  178. data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
  179. data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
  180. data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
  181. data/test/test/file_methods/test_yml_compare/expected/output_1.yml +0 -6
  182. data/test/test/file_methods/test_yml_compare/expected/output_2.yml +0 -6
  183. data/test/test/file_methods/test_yml_compare/input/input_1.yml +0 -4
  184. data/test/test/file_methods/test_yml_compare/input/input_2.yml +0 -4
  185. data/test/test_test.rb +0 -373
@@ -0,0 +1,3 @@
1
+ Description:
2
+ Generates a new FileTask and test files. Pass the task name,
3
+ either CamelCased or under_scored.
@@ -2,5 +2,21 @@ require 'tap/generator/generators/task/task_generator'
2
2
 
3
3
  module Tap::Generator::Generators
4
4
  class FileTaskGenerator < TaskGenerator # :nodoc:
5
+
6
+ def task_manifest(m)
7
+ return unless options[:test]
8
+
9
+ test_path = @app.relative_filepath(:root, @app[:test])
10
+ m.directory File.join(test_path, class_name.underscore)
11
+
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
+
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")
19
+ end
20
+
5
21
  end
6
22
  end
@@ -0,0 +1,3 @@
1
+ ---
2
+ - Line One
3
+ - Line Two
@@ -1,34 +1,40 @@
1
1
  # == Description
2
- # Replace with a description for <%= class_name_without_nesting %>
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.
3
5
  # === Usage
4
6
  # Replace with usage instructions
5
7
  #
6
8
  class <%= class_name_without_nesting %> < Tap::FileTask
7
- # uncomment to:
8
- # - pass all inputs to process at once
9
- # - define a task that takes no inputs
10
-
11
- #do_not_iterate
12
-
13
9
  # use config to set task configurations
14
10
  # configs have accessors by default
15
11
 
16
- #config :key, 'value' # config documentation
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)
17
18
 
18
- def process(input)
19
- # The process logic goes here.
20
- output = filepath(:data, input)
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') )
21
24
 
22
- # prepare ensures the parent directory for
23
- # output exists, and marks it for rollback
25
+ # prepare ensures the parent directory for
26
+ # output exists, and that output does not;
27
+ # any existing file is backed up and reverts
24
28
  # in the event of an error
25
- prepare(output)
26
-
27
- File.open(input) do |source|
28
- File.open(output, "w") do |target|
29
- # ... do something ...
30
- end
29
+ prepare(target)
30
+
31
+ # now perform the task...
32
+ array = File.read(filepath).split(/\r?\n/)
33
+ File.open(target, "wb") do |file|
34
+ file << array.to_yaml
31
35
  end
36
+
37
+ target
32
38
  end
33
39
 
34
- end
40
+ end
@@ -1,23 +1,33 @@
1
1
  require File.join(File.dirname(__FILE__), '<%= '../' * class_nesting_depth %>tap_test_helper.rb')
2
2
  require '<%= class_path.empty? ? file_name : File.join(class_path, file_name) %>'
3
3
 
4
- class <%= class_name_without_nesting %>Test < Test::Unit::TestCase
4
+ class <%= class_name %>Test < Test::Unit::TestCase
5
5
  acts_as_tap_test
6
6
 
7
7
  def test_<%= file_name.underscore %>
8
- # this test will make input/expected directories for the
9
- # test_<%= file_name.underscore %> the first time it is
10
- # run. assert_expected_result_files runs t with all the
11
- # input files and returns true only if the expected and
12
- # output files are equal
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'
13
12
  #
14
- # output files are cleaned up by default. to preserve
15
- # them use:
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:
16
18
  #
17
- # % tap run test keep_outputs=true
19
+ # % rake test keep_outputs=true
18
20
 
19
21
  t = <%= class_name %>.new
20
- assert_expected_result_files(t)
22
+ assert_files do |input_files|
23
+ input_files.each {|file| t.enq(file)}
24
+
25
+ with_config :directories => {:data => 'output'} do
26
+ app.run
27
+ end
28
+
29
+ app.results(t)
30
+ end
21
31
  end
22
32
 
23
33
  end
@@ -10,7 +10,7 @@ module Tap::Generator::Generators
10
10
 
11
11
  def manifest
12
12
  record do |m|
13
- generators_root = @app.relative_filepath(:root, @app[:generators])
13
+ generators_root = @app.relative_filepath(:root, @app['generators'])
14
14
  m.directory File.join(generators_root, file_name, "templates")
15
15
 
16
16
  m.template "generator.erb", File.join(generators_root, file_name, file_name + "_generator.rb")
@@ -1,23 +1,32 @@
1
1
  class <%= class_name_without_nesting %>Generator < Rails::Generator::NamedBase
2
+ attr_accessor :app
3
+
2
4
  def initialize(*args)
3
- super(*args)
4
- @destination_root = Tap::App.instance[:root]
5
- @app = Tap::App.instance
5
+ super(*args)
6
+ @app = Tap::App.instance
7
+ @destination_root = app[:root]
6
8
  end
7
9
 
8
10
  def manifest
9
11
  record do |m|
10
12
  # Use statements like these to make directories you need.
11
- # Note directories will be created relative to @destination_root
12
- # (ie @app[:root]) so the target dir must be a relative filepath
13
- #target_dir = @app.relative_filepath(:root, @app[:target])
14
- #m.directory target_dir
13
+ # Note directories will be created relative to @destination_root (ie app[:root])
14
+ target_dir = 'target'
15
+ m.directory target_dir
15
16
 
16
- # These statements would create the following files:
17
- # templates/ruby_file.erb => target_dir/class_name.rb
18
- # tempaltes/text_file.erb => target_dir/class_name.txt
19
- #m.template "ruby_file.erb", File.join(target_dir, class_name.underscore + ".rb"), :class_nesting => class_nesting
20
- #m.template "text_file.erb", File.join(target_dir, class_name.underscore + ".txt")
17
+ # These statements use the templates to create the following files:
18
+ # templates/ruby_file.erb => target_dir/class_name.rb
19
+ # templates/text_file.erb => target_dir/class_name.txt
20
+ #
21
+ # In templates, use class_name_without_nesting in conjunction with
22
+ # the :class_nesting option to properly indent nested classes, like:
23
+ #
24
+ # [ruby_file.erb]
25
+ # class <%= class_name_without_nesting %>
26
+ # end
27
+ #
28
+ m.template "ruby_file.erb", File.join(target_dir, class_name.underscore + ".rb"), :class_nesting => class_nesting
29
+ m.template "text_file.erb", File.join(target_dir, class_name.underscore + ".txt")
21
30
  end
22
31
  end
23
32
  end
@@ -9,21 +9,29 @@ task :default => :test
9
9
 
10
10
  desc 'Run tests.'
11
11
  Rake::TestTask.new(:test) do |t|
12
+
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']
19
+
12
20
  t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
21
+ t.verbose = true
14
22
  t.warning = true
15
23
  end
16
24
 
17
25
  desc 'Generate documentation.'
18
- Rake::RDocTask.new(:rdoc) do |rdoc|
26
+ Rake::RDocTask.new(:rdoc) do |rdoc|
19
27
  # options to specify TDoc
20
- require 'tap/support/tdoc'
21
- rdoc.template = 'tap/support/tdoc/tdoc_html_template'
22
- rdoc.options << '--fmt' << 'tdoc'
23
-
24
- rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = '<%= file_name %>'
26
- rdoc.template = 'tap/support/tdoc/tdoc_html_template'
28
+ require 'tap/support/tdoc'
29
+ rdoc.template = 'tap/support/tdoc/tdoc_html_template'
30
+ rdoc.options << '--fmt' << 'tdoc'
31
+
32
+ rdoc.rdoc_dir = 'rdoc'
33
+ rdoc.title = '<%= file_name %>'
34
+ rdoc.template = 'tap/support/tdoc/tdoc_html_template'
27
35
  rdoc.options << '--line-numbers' << '--inline-source'
28
36
  rdoc.rdoc_files.include('ReadMe.txt')
29
37
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -32,23 +40,24 @@ end
32
40
  #
33
41
  # Gem specification
34
42
  #
43
+
35
44
  spec = Gem::Specification.new do |s|
36
- s.name = "<%= file_name %>"
37
- s.version = "0.0.1"
38
- s.author = "Your Name Here"
39
- #s.email = "your.email@pubfactory.edu"
40
- #s.homepage = "http://rubyforge.org/projects/gemname/"
41
- s.platform = Gem::Platform::RUBY
42
- s.summary = "Add Description"
43
- s.files = Dir.glob("{test,lib}/**/*") + ["Rakefile", "ReadMe.txt"]
44
- s.require_path = "lib"
45
- s.test_file = "test/tap_test_suite.rb"
46
-
47
- s.has_rdoc = true
48
- s.extra_rdoc_files = ["ReadMe.txt"]
49
- s.add_dependency("tap", ">= <%= Tap::VERSION %>")
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 %>")
50
59
  end
51
60
 
52
61
  Rake::GemPackageTask.new(spec) do |pkg|
53
- pkg.need_tar = true
62
+ pkg.need_tar = true
54
63
  end
@@ -1,9 +1,8 @@
1
1
  ######################################################
2
2
  # App Configurations:
3
3
  #
4
- # These are configurations that directly affect the
5
- # application, including the directory structure
6
- # options, and logging.
4
+ # These are configurations that directly affect the application,
5
+ # including the directory structure options, and logging.
7
6
  #
8
7
  ######################################################
9
8
 
@@ -11,27 +10,24 @@
11
10
  # an odd and perhaps unwise thing to do
12
11
  #root:
13
12
 
14
- # Uncomment to specify aliases for directories relative to root.
15
- # Access using: app['lib'] # => root/alt_lib
16
- # By default: app['lib'] # => root/lib
13
+ # Specify aliases for directories relative to root.
17
14
  #directories:
18
- #lib: alt_lib
15
+ #lib: path/to/lib
16
+ #lib/generators: path/to/lib/generators
19
17
  #...
20
18
 
21
- # Uncomment to specify aliases for absolute paths
22
- # Access using: app['log'] # => /path/to/logs
19
+ # Specify aliases for absolute paths
23
20
  #absolute_paths:
24
21
  #log: /path/to/logs
25
22
  #...
26
23
 
27
- # Uncomment to specify options.
28
- # Access using: app.options.debug # => true
24
+ # Specify options
29
25
  #options:
30
26
  #debug: true # full error output, increased logging
31
27
  #quiet: true # supresses logging
32
28
  #... # you can add your own options
33
29
 
34
- # Specify logging options here.
30
+ # Specify logging options
35
31
  #logger:
36
32
  #device: # STDOUT by default
37
33
  #level: 1 # [DEBUG, INFO, WARN, ERROR, FATAL, ANY]
@@ -44,33 +40,34 @@
44
40
  # some/task_name: Tap::FileTask
45
41
  # CapsAreOk: Tap::Task
46
42
 
47
-
48
43
  ######################################################
49
- # Script Configurations:
44
+ # Environment Configurations:
45
+ #
46
+ # These are configurations that affect the execution environment
47
+ # for Tap and are NOT passed to the application itself.
50
48
  #
51
- # These are configurations that affect the execution
52
- # environment for Tap and are NOT passed to the
53
- # application itself.
49
+ # All paths are resolved to the directories setup above.
54
50
  #
55
51
  ######################################################
56
52
 
57
- # Designate load paths here for automatic loading and
58
- # reloading of tasks through the active_support
59
- # Dependencies module. The default is 'lib'. Paths
60
- # are resolved to the aliases setup above,
61
- # 'lib' => app['lib']
53
+ # Designate load paths here for automatic loading of modules
54
+ # through the active_support Dependencies module.
55
+ # load_paths are also added to $LOAD_PATH.
62
56
  #load_paths:
63
- # - 'lib'
57
+ # - lib
58
+
59
+ # Specifies load_once_paths for Dependencies.
60
+ #load_once_paths:
61
+
62
+ # Designate paths for discovering and executing commands.
63
+ #command_paths:
64
+ # - cmd
64
65
 
65
- # Designate script paths for discovering and executing
66
- # commands. The default is 'script'. Paths are resolved
67
- # to the aliases setup above, 'script' => app['script']
68
- #script_paths:
69
- # - 'script'
66
+ # Designate paths for discovering generators.
67
+ #generator_paths:
68
+ # - lib/generators
70
69
 
71
- # Specify gems that contain load_paths and script_paths
72
- # that you likewise want to be automatically loaded.
73
- # Specify versions directly.
70
+ # Specify gems to add to the environment. Versions may be specified.
74
71
  #gems:
75
72
  # - gem_name
76
73
  # - gem_with_version > 1.0.0
@@ -1,2 +1,3 @@
1
+ require 'rubygems'
1
2
  require 'tap'
2
3
  require 'tap/test'
@@ -0,0 +1,3 @@
1
+ Description:
2
+ Generates a new Task and test files. Pass the task name,
3
+ either CamelCased or under_scored.
@@ -10,12 +10,25 @@ module Tap::Generator::Generators
10
10
  record do |m|
11
11
  lib_path = @app.relative_filepath(:root, @app[:lib])
12
12
  m.directory File.join(lib_path, class_path)
13
- m.template "task.erb", File.join(lib_path, class_name.underscore + ".rb"), :class_nesting => class_nesting
14
-
15
- test_path = @app.relative_filepath(:root, @app[:test])
16
- m.directory File.join(test_path, class_path)
17
- m.template "test.erb", File.join(test_path, class_name.underscore + "_test.rb")
13
+ m.template "task.erb", File.join(lib_path, class_name.underscore + ".rb"), :class_nesting => class_nesting
14
+
15
+ if options[:test]
16
+ test_path = @app.relative_filepath(:root, @app[:test])
17
+ m.directory File.join(test_path, class_path)
18
+ m.template "test.erb", File.join(test_path, class_name.underscore + "_test.rb")
19
+ end
20
+
21
+ task_manifest(m)
18
22
  end
19
23
  end
24
+
25
+ def task_manifest(m)
26
+ end
27
+
28
+ def add_options!(opt)
29
+ options[:test] = true
30
+ opt.on(nil, '--[no-]test', 'Generates the task without test files.') { |value| options[:test] = value }
31
+ end
32
+
20
33
  end
21
34
  end
@@ -5,25 +5,20 @@
5
5
  # Replace with usage instructions
6
6
  #
7
7
  class <%= class_name_without_nesting %> < Tap::Task
8
- # uncomment to:
9
- # - pass all inputs to process at once
10
- # - define a task that takes no inputs
11
-
12
- #do_not_iterate
13
-
14
8
  # use config to set task configurations
15
9
  # configs have accessors by default
16
10
 
17
- config :label, 'input' # a label for output
11
+ config :key, 'value' # a sample config
18
12
 
13
+ # process defines what the task does; use the
14
+ # same number of inputs to enque the task
15
+ # as specified here
19
16
  def process(input)
20
- # the process logic goes here.
21
-
22
17
  # use log to record information
23
- log label, input
18
+ result = "#{input} was processed with #{key}"
19
+ log self.name, result
24
20
 
25
- # the return of process is the task output
26
- "#{label}: #{input} was processed"
21
+ result
27
22
  end
28
23
 
29
24
  end