tap 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Basic Overview +151 -0
- data/Command Reference +99 -0
- data/History +24 -0
- data/MIT-LICENSE +1 -1
- data/README +29 -57
- data/Rakefile +30 -37
- data/Tutorial +243 -191
- data/bin/tap +66 -35
- data/lib/tap.rb +47 -29
- data/lib/tap/app.rb +700 -342
- data/lib/tap/{script → cmd}/console.rb +0 -0
- data/lib/tap/{script → cmd}/destroy.rb +0 -0
- data/lib/tap/{script → cmd}/generate.rb +0 -0
- data/lib/tap/cmd/run.rb +156 -0
- data/lib/tap/constants.rb +4 -0
- data/lib/tap/dump.rb +57 -0
- data/lib/tap/env.rb +316 -0
- data/lib/tap/file_task.rb +106 -109
- data/lib/tap/generator.rb +4 -1
- data/lib/tap/generator/generators/command/USAGE +6 -0
- data/lib/tap/generator/generators/command/command_generator.rb +17 -0
- data/lib/tap/generator/generators/{script/templates/script.erb → command/templates/command.erb} +10 -10
- data/lib/tap/generator/generators/config/USAGE +21 -0
- data/lib/tap/generator/generators/config/config_generator.rb +17 -7
- data/lib/tap/generator/generators/file_task/USAGE +3 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -0
- data/lib/tap/generator/generators/file_task/templates/file.txt +2 -0
- data/lib/tap/generator/generators/file_task/templates/file.yml +3 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +26 -20
- data/lib/tap/generator/generators/file_task/templates/test.erb +20 -10
- data/lib/tap/generator/generators/generator/generator_generator.rb +1 -1
- data/lib/tap/generator/generators/generator/templates/generator.erb +21 -12
- data/lib/tap/generator/generators/root/templates/Rakefile +33 -24
- data/lib/tap/generator/generators/root/templates/tap.yml +28 -31
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +1 -0
- data/lib/tap/generator/generators/task/USAGE +3 -0
- data/lib/tap/generator/generators/task/task_generator.rb +18 -5
- data/lib/tap/generator/generators/task/templates/task.erb +7 -12
- data/lib/tap/generator/generators/task/templates/test.erb +10 -11
- data/lib/tap/generator/generators/workflow/templates/task.erb +1 -1
- data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
- data/lib/tap/patches/rake/rake_test_loader.rb +8 -0
- data/lib/tap/patches/rake/testtask.rb +55 -0
- data/lib/tap/patches/ruby19/backtrace_filter.rb +51 -0
- data/lib/tap/patches/ruby19/parsedate.rb +16 -0
- data/lib/tap/root.rb +172 -67
- data/lib/tap/script.rb +70 -336
- data/lib/tap/support/aggregator.rb +55 -0
- data/lib/tap/support/audit.rb +281 -280
- data/lib/tap/support/batchable.rb +59 -0
- data/lib/tap/support/class_configuration.rb +279 -0
- data/lib/tap/support/configurable.rb +92 -0
- data/lib/tap/support/configurable_methods.rb +296 -0
- data/lib/tap/support/executable.rb +98 -0
- data/lib/tap/support/executable_queue.rb +82 -0
- data/lib/tap/support/logger.rb +9 -15
- data/lib/tap/support/rake.rb +43 -54
- data/lib/tap/support/run_error.rb +32 -13
- data/lib/tap/support/shell_utils.rb +47 -0
- data/lib/tap/support/tdoc.rb +9 -8
- data/lib/tap/support/tdoc/config_attr.rb +40 -16
- data/lib/tap/support/validation.rb +77 -0
- data/lib/tap/support/versions.rb +36 -36
- data/lib/tap/task.rb +276 -482
- data/lib/tap/test.rb +20 -261
- data/lib/tap/test/env_vars.rb +7 -5
- data/lib/tap/test/file_methods.rb +126 -121
- data/lib/tap/test/subset_methods.rb +86 -45
- data/lib/tap/test/tap_methods.rb +271 -0
- data/lib/tap/workflow.rb +174 -46
- data/test/app/config/another/task.yml +1 -0
- data/test/app/config/erb.yml +2 -1
- data/test/app/config/some/task.yml +1 -0
- data/test/app/config/template.yml +2 -6
- data/test/app_test.rb +1241 -1008
- data/test/env/test_configure/recurse_a.yml +2 -0
- data/test/env/test_configure/recurse_b.yml +2 -0
- data/test/env/test_configure/tap.yml +23 -0
- data/test/env/test_load_env_config/dir/tap.yml +3 -0
- data/test/env/test_load_env_config/recurse_a.yml +2 -0
- data/test/env/test_load_env_config/recurse_b.yml +2 -0
- data/test/env/test_load_env_config/tap.yml +3 -0
- data/test/env_test.rb +198 -0
- data/test/file_task_test.rb +70 -53
- data/{lib/tap/generator/generators/package/USAGE → test/root/file.txt} +0 -0
- data/test/root_test.rb +621 -454
- data/test/script_test.rb +38 -174
- data/test/support/aggregator_test.rb +99 -0
- data/test/support/audit_test.rb +409 -416
- data/test/support/batchable_test.rb +74 -0
- data/test/support/{task_configuration_test.rb → class_configuration_test.rb} +106 -47
- data/test/{task/config/overriding.yml → support/configurable/config/configured.yml} +0 -0
- data/test/support/configurable_test.rb +295 -0
- data/test/support/executable_queue_test.rb +103 -0
- data/test/support/executable_test.rb +38 -0
- data/test/support/logger_test.rb +17 -17
- data/test/support/rake_test.rb +4 -2
- data/test/support/shell_utils_test.rb +24 -0
- data/test/support/tdoc_test.rb +265 -258
- data/test/support/validation_test.rb +54 -0
- data/test/support/versions_test.rb +38 -38
- data/test/tap_test_helper.rb +19 -5
- data/test/tap_test_suite.rb +5 -2
- data/test/task_base_test.rb +13 -104
- data/test/task_syntax_test.rb +300 -0
- data/test/task_test.rb +258 -381
- data/test/test/env_vars_test.rb +40 -40
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/one.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/two.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/one.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/two.txt +0 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/one.txt +0 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +1 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_different_content}/expected/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +1 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_missing_expected_file}/expected/one.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +1 -0
- data/test/test/file_methods_doc/test_sub/expected/one.txt +1 -0
- data/test/test/file_methods_doc/test_sub/expected/two.txt +1 -0
- data/test/test/file_methods_doc/test_sub/input/one.txt +1 -0
- data/test/test/file_methods_doc/test_sub/input/two.txt +1 -0
- data/test/test/file_methods_doc_test.rb +29 -0
- data/test/test/file_methods_test.rb +214 -143
- data/test/test/subset_methods_test.rb +111 -115
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/a.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/b.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/a.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/b.txt +0 -0
- data/test/test/tap_methods_test.rb +399 -0
- data/test/workflow_test.rb +101 -91
- metadata +86 -70
- data/lib/tap/generator/generators/package/package_generator.rb +0 -38
- data/lib/tap/generator/generators/package/templates/package.erb +0 -186
- data/lib/tap/generator/generators/script/USAGE +0 -0
- data/lib/tap/generator/generators/script/script_generator.rb +0 -17
- data/lib/tap/script/run.rb +0 -154
- data/lib/tap/support/batch_queue.rb +0 -162
- data/lib/tap/support/combinator.rb +0 -114
- data/lib/tap/support/task_configuration.rb +0 -169
- data/lib/tap/support/template.rb +0 -81
- data/lib/tap/support/templater.rb +0 -155
- data/lib/tap/version.rb +0 -4
- data/test/app/config/addition_template.yml +0 -6
- data/test/app_class_test.rb +0 -33
- data/test/check/binding_eval.rb +0 -23
- data/test/check/define_method_check.rb +0 -22
- data/test/check/dependencies_check.rb +0 -175
- data/test/check/inheritance_check.rb +0 -22
- data/test/support/batch_queue_test.rb +0 -320
- data/test/support/combinator_test.rb +0 -249
- data/test/support/template_test.rb +0 -122
- data/test/support/templater/erb.txt +0 -2
- data/test/support/templater/erb.yml +0 -2
- data/test/support/templater/somefile.txt +0 -2
- data/test/support/templater_test.rb +0 -192
- data/test/task/config/template.yml +0 -4
- data/test/task_class_test.rb +0 -170
- data/test/task_execute_test.rb +0 -262
- data/test/test/file_methods/test_assert_expected/expected/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/expected/folder/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/input/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/input/folder/file.txt +0 -1
- data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
- data/test/test/file_methods/test_file_compare/expected/output_1.txt +0 -3
- data/test/test/file_methods/test_file_compare/expected/output_2.txt +0 -1
- data/test/test/file_methods/test_file_compare/input/input_1.txt +0 -3
- data/test/test/file_methods/test_file_compare/input/input_2.txt +0 -3
- data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods/test_yml_compare/expected/output_1.yml +0 -6
- data/test/test/file_methods/test_yml_compare/expected/output_2.yml +0 -6
- data/test/test/file_methods/test_yml_compare/input/input_1.yml +0 -4
- data/test/test/file_methods/test_yml_compare/input/input_2.yml +0 -4
- data/test/test_test.rb +0 -373
@@ -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
|
@@ -1,34 +1,40 @@
|
|
1
1
|
# == Description
|
2
|
-
# Replace with a 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.
|
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
|
-
|
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
|
-
|
19
|
-
#
|
20
|
-
|
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
|
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(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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 <%=
|
4
|
+
class <%= class_name %>Test < Test::Unit::TestCase
|
5
5
|
acts_as_tap_test
|
6
6
|
|
7
7
|
def test_<%= file_name.underscore %>
|
8
|
-
#
|
9
|
-
# test_<%= file_name.underscore
|
10
|
-
#
|
11
|
-
#
|
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
|
-
#
|
15
|
-
#
|
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
|
-
# %
|
19
|
+
# % rake test keep_outputs=true
|
18
20
|
|
19
21
|
t = <%= class_name %>.new
|
20
|
-
|
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[
|
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
|
-
@
|
5
|
-
@
|
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
|
-
|
13
|
-
|
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
|
17
|
-
# templates/ruby_file.erb
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
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
|
-
#
|
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
|
-
#
|
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:
|
15
|
+
#lib: path/to/lib
|
16
|
+
#lib/generators: path/to/lib/generators
|
19
17
|
#...
|
20
18
|
|
21
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
58
|
-
#
|
59
|
-
#
|
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
|
-
# -
|
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
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#script_paths:
|
69
|
-
# - 'script'
|
66
|
+
# Designate paths for discovering generators.
|
67
|
+
#generator_paths:
|
68
|
+
# - lib/generators
|
70
69
|
|
71
|
-
# Specify gems
|
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
|
@@ -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
|
-
|
16
|
-
|
17
|
-
|
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 :
|
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
|
-
|
18
|
+
result = "#{input} was processed with #{key}"
|
19
|
+
log self.name, result
|
24
20
|
|
25
|
-
|
26
|
-
"#{label}: #{input} was processed"
|
21
|
+
result
|
27
22
|
end
|
28
23
|
|
29
24
|
end
|