tap 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +37 -30
- data/MIT-LICENSE +1 -1
- data/README +92 -44
- data/bin/tap +62 -75
- data/cmd/console.rb +42 -0
- data/cmd/destroy.rb +16 -0
- data/cmd/generate.rb +16 -0
- data/cmd/run.rb +126 -0
- data/doc/Class Reference +362 -0
- data/doc/Command Reference +153 -0
- data/doc/Tutorial +237 -0
- data/lib/tap.rb +6 -45
- data/lib/tap/app.rb +126 -500
- data/lib/tap/constants.rb +2 -29
- data/lib/tap/env.rb +555 -250
- data/lib/tap/file_task.rb +60 -103
- data/lib/tap/generator/base.rb +109 -0
- data/lib/tap/generator/destroy.rb +37 -0
- data/lib/tap/generator/generate.rb +61 -0
- data/lib/tap/generator/generators/command/command_generator.rb +16 -12
- data/lib/tap/generator/generators/command/templates/command.erb +13 -19
- data/lib/tap/generator/generators/config/config_generator.rb +18 -27
- data/lib/tap/generator/generators/config/templates/doc.erb +12 -0
- data/lib/tap/generator/generators/config/templates/nodoc.erb +8 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -11
- data/lib/tap/generator/generators/file_task/templates/file.txt +11 -2
- data/lib/tap/generator/generators/file_task/templates/result.yml +6 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +24 -31
- data/lib/tap/generator/generators/file_task/templates/test.erb +18 -22
- data/lib/tap/generator/generators/root/root_generator.rb +45 -31
- data/lib/tap/generator/generators/root/templates/Rakefile +64 -41
- data/lib/tap/generator/generators/root/templates/gemspec +27 -0
- data/lib/tap/generator/generators/root/templates/tapfile +8 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
- data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +15 -0
- data/lib/tap/generator/generators/task/task_generator.rb +21 -28
- data/lib/tap/generator/generators/task/templates/task.erb +13 -23
- data/lib/tap/generator/generators/task/templates/test.erb +15 -18
- data/lib/tap/generator/manifest.rb +14 -0
- data/lib/tap/patches/rake/rake_test_loader.rb +0 -0
- data/lib/tap/patches/rake/testtask.rb +0 -0
- data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -0
- data/lib/tap/patches/ruby19/parsedate.rb +0 -0
- data/lib/tap/root.rb +260 -21
- data/lib/tap/support/aggregator.rb +11 -11
- data/lib/tap/support/assignments.rb +172 -0
- data/lib/tap/support/audit.rb +20 -18
- data/lib/tap/support/batchable.rb +21 -10
- data/lib/tap/support/batchable_class.rb +107 -0
- data/lib/tap/support/class_configuration.rb +154 -239
- data/lib/tap/support/command_line.rb +97 -102
- data/lib/tap/support/comment.rb +270 -0
- data/lib/tap/support/configurable.rb +86 -65
- data/lib/tap/support/configurable_class.rb +296 -0
- data/lib/tap/support/configuration.rb +122 -0
- data/lib/tap/support/constant.rb +70 -0
- data/lib/tap/support/constant_utils.rb +127 -0
- data/lib/tap/support/declarations.rb +111 -0
- data/lib/tap/support/executable.rb +30 -17
- data/lib/tap/support/executable_queue.rb +0 -0
- data/lib/tap/support/framework.rb +71 -0
- data/lib/tap/support/framework_class.rb +199 -0
- data/lib/tap/support/instance_configuration.rb +147 -0
- data/lib/tap/support/lazydoc.rb +428 -0
- data/lib/tap/support/manifest.rb +89 -0
- data/lib/tap/support/run_error.rb +0 -0
- data/lib/tap/support/shell_utils.rb +33 -9
- data/lib/tap/support/summary.rb +30 -0
- data/lib/tap/support/tdoc.rb +339 -134
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -0
- data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -0
- data/lib/tap/support/templater.rb +180 -0
- data/lib/tap/support/validation.rb +409 -76
- data/lib/tap/support/versions.rb +5 -3
- data/lib/tap/task.rb +78 -174
- data/lib/tap/tasks/dump.rb +56 -0
- data/lib/tap/tasks/rake.rb +93 -0
- data/lib/tap/test.rb +3 -3
- data/lib/tap/test/env_vars.rb +2 -2
- data/lib/tap/test/file_methods.rb +19 -20
- data/lib/tap/test/script_methods.rb +144 -0
- data/lib/tap/test/subset_methods.rb +1 -1
- data/lib/tap/test/tap_methods.rb +28 -62
- data/lib/tap/workflow.rb +22 -39
- metadata +48 -179
- data/Basic Overview +0 -151
- data/Command Reference +0 -99
- data/Rakefile +0 -127
- data/Tutorial +0 -287
- data/lib/tap/cmd/console.rb +0 -31
- data/lib/tap/cmd/destroy.rb +0 -20
- data/lib/tap/cmd/generate.rb +0 -20
- data/lib/tap/cmd/run.rb +0 -151
- data/lib/tap/dump.rb +0 -57
- data/lib/tap/generator.rb +0 -91
- data/lib/tap/generator/generators/command/USAGE +0 -6
- data/lib/tap/generator/generators/config/USAGE +0 -21
- data/lib/tap/generator/generators/config/templates/config.erb +0 -1
- data/lib/tap/generator/generators/file_task/USAGE +0 -3
- data/lib/tap/generator/generators/file_task/templates/file.yml +0 -3
- data/lib/tap/generator/generators/generator/USAGE +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +0 -21
- data/lib/tap/generator/generators/generator/templates/generator.erb +0 -32
- data/lib/tap/generator/generators/generator/templates/usage.erb +0 -1
- data/lib/tap/generator/generators/root/USAGE +0 -0
- data/lib/tap/generator/generators/root/templates/ReadMe.txt +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +0 -80
- data/lib/tap/generator/generators/task/USAGE +0 -3
- data/lib/tap/generator/generators/workflow/USAGE +0 -0
- data/lib/tap/generator/generators/workflow/templates/task.erb +0 -16
- data/lib/tap/generator/generators/workflow/templates/test.erb +0 -7
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +0 -6
- data/lib/tap/generator/options.rb +0 -26
- data/lib/tap/generator/usage.rb +0 -26
- data/lib/tap/support/batchable_methods.rb +0 -34
- data/lib/tap/support/command_line_methods.rb +0 -76
- data/lib/tap/support/configurable_methods.rb +0 -224
- data/lib/tap/support/logger.rb +0 -88
- data/lib/tap/support/rake.rb +0 -43
- data/lib/tap/support/tdoc/config_attr.rb +0 -362
- data/test/app/config/another/task.yml +0 -1
- data/test/app/config/batch.yml +0 -2
- data/test/app/config/empty.yml +0 -0
- data/test/app/config/erb.yml +0 -2
- data/test/app/config/some/task.yml +0 -1
- data/test/app/config/template.yml +0 -2
- data/test/app/config/version-0.1.yml +0 -1
- data/test/app/config/version.yml +0 -1
- data/test/app/lib/app_test_task.rb +0 -3
- data/test/app_test.rb +0 -1849
- data/test/env/test_configure/recurse_a.yml +0 -2
- data/test/env/test_configure/recurse_b.yml +0 -2
- data/test/env/test_configure/tap.yml +0 -23
- data/test/env/test_load_env_config/dir/tap.yml +0 -3
- data/test/env/test_load_env_config/recurse_a.yml +0 -2
- data/test/env/test_load_env_config/recurse_b.yml +0 -2
- data/test/env/test_load_env_config/tap.yml +0 -3
- data/test/env_test.rb +0 -198
- data/test/file_task/config/batch.yml +0 -2
- data/test/file_task/config/configured.yml +0 -1
- data/test/file_task/old_file_one.txt +0 -0
- data/test/file_task/old_file_two.txt +0 -0
- data/test/file_task_test.rb +0 -1291
- data/test/root/alt_lib/alt_module.rb +0 -4
- data/test/root/file.txt +0 -0
- data/test/root/glob/one.txt +0 -0
- data/test/root/glob/two.txt +0 -0
- data/test/root/lib/absolute_alt_filepath.rb +0 -2
- data/test/root/lib/alternative_filepath.rb +0 -2
- data/test/root/lib/another_module.rb +0 -2
- data/test/root/lib/nested/some_module.rb +0 -4
- data/test/root/lib/no_module_included.rb +0 -0
- data/test/root/lib/some/module.rb +0 -4
- data/test/root/lib/some_class.rb +0 -2
- data/test/root/lib/some_module.rb +0 -3
- data/test/root/load_path/load_path_module.rb +0 -2
- data/test/root/load_path/skip_module.rb +0 -2
- data/test/root/mtime/older.txt +0 -0
- data/test/root/unload/full_path.rb +0 -2
- data/test/root/unload/loaded_by_nested.rb +0 -2
- data/test/root/unload/nested/nested_load.rb +0 -6
- data/test/root/unload/nested/nested_with_ext.rb +0 -4
- data/test/root/unload/nested/relative_path.rb +0 -4
- data/test/root/unload/older.rb +0 -2
- data/test/root/unload/unload_base.rb +0 -9
- data/test/root/versions/another.yml +0 -0
- data/test/root/versions/file-0.1.2.yml +0 -0
- data/test/root/versions/file-0.1.yml +0 -0
- data/test/root/versions/file.yml +0 -0
- data/test/root_test.rb +0 -718
- data/test/support/aggregator_test.rb +0 -99
- data/test/support/audit_test.rb +0 -445
- data/test/support/batchable_test.rb +0 -74
- data/test/support/class_configuration_test.rb +0 -331
- data/test/support/command_line_test.rb +0 -58
- data/test/support/configurable/config/configured.yml +0 -2
- data/test/support/configurable_test.rb +0 -295
- data/test/support/executable_queue_test.rb +0 -103
- data/test/support/executable_test.rb +0 -38
- data/test/support/logger_test.rb +0 -31
- data/test/support/rake_test.rb +0 -37
- data/test/support/shell_utils_test.rb +0 -24
- data/test/support/tdoc_test.rb +0 -370
- data/test/support/validation_test.rb +0 -54
- data/test/support/versions_test.rb +0 -103
- data/test/tap_test_helper.rb +0 -57
- data/test/tap_test_suite.rb +0 -7
- data/test/task/config/batch.yml +0 -2
- data/test/task/config/batched.yml +0 -2
- data/test/task/config/configured.yml +0 -1
- data/test/task/config/example.yml +0 -1
- data/test/task_base_test.rb +0 -24
- data/test/task_syntax_test.rb +0 -300
- data/test/task_test.rb +0 -320
- data/test/test/env_vars_test.rb +0 -48
- data/test/test/file_methods/test_assert_files/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +0 -1
- data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods_doc/test_sub/expected/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/expected/two.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/two.txt +0 -1
- data/test/test/file_methods_doc_test.rb +0 -29
- data/test/test/file_methods_test.rb +0 -275
- data/test/test/subset_methods_test.rb +0 -171
- data/test/test/tap_methods/test_assert_files/expected/task/name/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/expected/task/name/b.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/b.txt +0 -1
- data/test/test/tap_methods_test.rb +0 -399
- data/test/workflow_test.rb +0 -120
- data/vendor/rails_generator.rb +0 -56
- data/vendor/rails_generator/base.rb +0 -263
- data/vendor/rails_generator/commands.rb +0 -581
- data/vendor/rails_generator/generated_attribute.rb +0 -42
- data/vendor/rails_generator/lookup.rb +0 -209
- data/vendor/rails_generator/manifest.rb +0 -53
- data/vendor/rails_generator/options.rb +0 -143
- data/vendor/rails_generator/scripts.rb +0 -83
- data/vendor/rails_generator/scripts/destroy.rb +0 -7
- data/vendor/rails_generator/scripts/generate.rb +0 -7
- data/vendor/rails_generator/scripts/update.rb +0 -12
- data/vendor/rails_generator/simple_logger.rb +0 -46
- data/vendor/rails_generator/spec.rb +0 -44
@@ -1,32 +0,0 @@
|
|
1
|
-
class <%= class_name_without_nesting %>Generator < Rails::Generator::NamedBase
|
2
|
-
attr_accessor :app
|
3
|
-
|
4
|
-
def initialize(*args)
|
5
|
-
super(*args)
|
6
|
-
@app = Tap::App.instance
|
7
|
-
@destination_root = app[:root]
|
8
|
-
end
|
9
|
-
|
10
|
-
def manifest
|
11
|
-
record do |m|
|
12
|
-
# Use statements like these to make directories you need.
|
13
|
-
# Note directories will be created relative to @destination_root (ie app[:root])
|
14
|
-
target_dir = 'target'
|
15
|
-
m.directory target_dir
|
16
|
-
|
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")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= class_name %> Usage
|
File without changes
|
File without changes
|
@@ -1,80 +0,0 @@
|
|
1
|
-
######################################################
|
2
|
-
# App Configurations:
|
3
|
-
#
|
4
|
-
# These are configurations that directly affect the application,
|
5
|
-
# including the directory structure options, and logging.
|
6
|
-
#
|
7
|
-
######################################################
|
8
|
-
|
9
|
-
# You can set an alternate root, but this is
|
10
|
-
# an odd and perhaps unwise thing to do
|
11
|
-
#root:
|
12
|
-
|
13
|
-
# Specify aliases for directories relative to root.
|
14
|
-
#directories:
|
15
|
-
#lib: path/to/lib
|
16
|
-
#lib/generators: path/to/lib/generators
|
17
|
-
#...
|
18
|
-
|
19
|
-
# Specify aliases for absolute paths
|
20
|
-
#absolute_paths:
|
21
|
-
#log: /path/to/logs
|
22
|
-
#...
|
23
|
-
|
24
|
-
# Specify options
|
25
|
-
#options:
|
26
|
-
#debug: true # full error output, increased logging
|
27
|
-
#quiet: true # supresses logging
|
28
|
-
#... # you can add your own options
|
29
|
-
|
30
|
-
# Specify logging options
|
31
|
-
#logger:
|
32
|
-
#device: # STDOUT by default
|
33
|
-
#level: 1 # [DEBUG, INFO, WARN, ERROR, FATAL, ANY]
|
34
|
-
#datetime_format: %H:%M:%S # Hour:Minute:Second
|
35
|
-
|
36
|
-
# Map task names to task classes here. The example causes
|
37
|
-
# app.task('some/task_name') to intialize a Tap::FileTask
|
38
|
-
# with that name. Any number of mappings can be specified.
|
39
|
-
#map:
|
40
|
-
# some/task_name: Tap::FileTask
|
41
|
-
# CapsAreOk: Tap::Task
|
42
|
-
|
43
|
-
######################################################
|
44
|
-
# Environment Configurations:
|
45
|
-
#
|
46
|
-
# These are configurations that affect the execution environment
|
47
|
-
# for Tap and are NOT passed to the application itself.
|
48
|
-
#
|
49
|
-
# All paths are resolved to the directories setup above.
|
50
|
-
#
|
51
|
-
######################################################
|
52
|
-
|
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.
|
56
|
-
#load_paths:
|
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
|
65
|
-
|
66
|
-
# Designate paths for discovering generators.
|
67
|
-
#generator_paths:
|
68
|
-
# - lib/generators
|
69
|
-
|
70
|
-
# Specify gems to add to the environment. Versions may be specified.
|
71
|
-
#gems:
|
72
|
-
# - gem_name
|
73
|
-
# - gem_with_version > 1.0.0
|
74
|
-
|
75
|
-
# Specify code to execute before and after Tap executes
|
76
|
-
#before: |
|
77
|
-
# puts "beginning..."
|
78
|
-
# Tap::Env.instance.discover_gems
|
79
|
-
#after: |
|
80
|
-
# puts "done!"
|
File without changes
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# == Description
|
2
|
-
#
|
3
|
-
# === Usage
|
4
|
-
# Replace with your command line usage instructions
|
5
|
-
#
|
6
|
-
class <%= class_name_without_nesting %> < Tap::Workflow
|
7
|
-
protected
|
8
|
-
|
9
|
-
def workflow
|
10
|
-
# Define the workflow entry and exit points,
|
11
|
-
# as well as the workflow logic.
|
12
|
-
self.entry_point = Tap::Task.new
|
13
|
-
|
14
|
-
# app.sequence(entry_point, 'another/task')
|
15
|
-
end
|
16
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Tap
|
2
|
-
module Generator
|
3
|
-
module Options # :nodoc:
|
4
|
-
protected
|
5
|
-
|
6
|
-
# Adapted from code in 'rails/rails_generator/options.rb'
|
7
|
-
def add_general_options!(opt)
|
8
|
-
opt.separator ''
|
9
|
-
opt.separator 'General Options:'
|
10
|
-
|
11
|
-
opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
|
12
|
-
opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
|
13
|
-
opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
|
14
|
-
opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
|
15
|
-
opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
|
16
|
-
opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
|
17
|
-
opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
|
18
|
-
options[:svn] = `svn status`.inject({}) do |opt, e|
|
19
|
-
opt[e.chomp[7..-1]] = true
|
20
|
-
opt
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/tap/generator/usage.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'tap/generator/options'
|
2
|
-
|
3
|
-
module Tap
|
4
|
-
module Generator
|
5
|
-
module Usage # :nodoc:
|
6
|
-
include Options
|
7
|
-
|
8
|
-
protected
|
9
|
-
|
10
|
-
# Adapted from code in 'rails/rails_generator/scripts.rb'
|
11
|
-
def usage_message
|
12
|
-
usage = "\nInstalled Generators\n"
|
13
|
-
Rails::Generator::Base.sources.each do |source|
|
14
|
-
label = source.label.to_s.capitalize
|
15
|
-
names = source.names
|
16
|
-
usage << " #{label}: #{names.join(', ')}\n" unless names.empty?
|
17
|
-
end
|
18
|
-
|
19
|
-
usage << <<end_blurb
|
20
|
-
|
21
|
-
end_blurb
|
22
|
-
return usage
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Tap
|
2
|
-
module Support
|
3
|
-
|
4
|
-
# BatchableMethods encapsulates class methods related to Batchable.
|
5
|
-
module BatchableMethods
|
6
|
-
|
7
|
-
# Merges the batches for the specified objects. All objects
|
8
|
-
# sharing the individual object batches will be affected, even
|
9
|
-
# if they are not listed explicitly as an input.
|
10
|
-
#
|
11
|
-
# t1 = Tap::Task.new
|
12
|
-
# t2 = Tap::Task.new
|
13
|
-
# t3 = t2.initialize_batch_obj
|
14
|
-
#
|
15
|
-
# Batchable.batch(t1, t2)
|
16
|
-
# t3.batch # => [t1,t2,t3]
|
17
|
-
#
|
18
|
-
# Returns the new batch.
|
19
|
-
def batch(*batchables)
|
20
|
-
merged = []
|
21
|
-
batches = batchables.collect {|batchable| batchable.batch }.uniq
|
22
|
-
batches.each do |batch|
|
23
|
-
merged.concat(batch)
|
24
|
-
batch.clear
|
25
|
-
end
|
26
|
-
merged.uniq!
|
27
|
-
batches.each {|batch| batch.concat(merged) }
|
28
|
-
merged
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module Tap
|
2
|
-
module Support
|
3
|
-
autoload(:TDoc, 'tap/support/tdoc')
|
4
|
-
autoload(:CommandLine, 'tap/support/command_line')
|
5
|
-
|
6
|
-
# Under Construction
|
7
|
-
module CommandLineMethods
|
8
|
-
|
9
|
-
# Returns the TDoc documentation for self.
|
10
|
-
def tdoc
|
11
|
-
@tdoc ||= Tap::Support::TDoc[self]
|
12
|
-
end
|
13
|
-
|
14
|
-
# EXPERIMENTAL
|
15
|
-
def help(opts=configurations.to_opts)
|
16
|
-
return "could not find help for '#{self}'" if tdoc == nil
|
17
|
-
|
18
|
-
sections = tdoc.comment_sections(/Description|Usage/i, true)
|
19
|
-
%Q{#{self}
|
20
|
-
#{sections["Description"]}
|
21
|
-
Usage:
|
22
|
-
#{sections["Usage"]}
|
23
|
-
Options:
|
24
|
-
#{Tap::Support::CommandLine.usage_options(opts)}
|
25
|
-
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
# EXPERIMENTAL
|
30
|
-
def argv_enq(app=App.instance, &block)
|
31
|
-
if block_given?
|
32
|
-
@argv_enq_block = block
|
33
|
-
return
|
34
|
-
end
|
35
|
-
return @argv_enq_block.call(app) if @argv_enq_block ||= nil
|
36
|
-
|
37
|
-
config = {}
|
38
|
-
opts = configurations.to_opts
|
39
|
-
opts << ['--help', nil, GetoptLong::NO_ARGUMENT, "Print this help."]
|
40
|
-
opts << ['--debug', nil, GetoptLong::NO_ARGUMENT, "Trace execution and debug"]
|
41
|
-
opts << ['--use', nil, GetoptLong::REQUIRED_ARGUMENT, "Loads inputs from file."]
|
42
|
-
opts << ['--iterate', nil, GetoptLong::NO_ARGUMENT, "Iterates over inputs."]
|
43
|
-
|
44
|
-
iterate = false
|
45
|
-
Tap::Support::CommandLine.handle_options(*opts) do |opt, value|
|
46
|
-
case opt
|
47
|
-
when '--help'
|
48
|
-
puts help(opts)
|
49
|
-
exit
|
50
|
-
|
51
|
-
when '--debug'
|
52
|
-
app.options.debug = true
|
53
|
-
|
54
|
-
when '--use'
|
55
|
-
hash = YAML.load_file(value)
|
56
|
-
hash.values.each do |args|
|
57
|
-
ARGV.concat(args)
|
58
|
-
end
|
59
|
-
|
60
|
-
when '--iterate'
|
61
|
-
iterate = true
|
62
|
-
|
63
|
-
else
|
64
|
-
key = configurations.opt_map(opt)
|
65
|
-
config[key] = YAML.load(value)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# instantiate and configure task
|
70
|
-
task = new(ARGV.shift, config, app)
|
71
|
-
iterate ? ARGV.each {|input| task.enq(input) } : task.enq(*ARGV)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
@@ -1,224 +0,0 @@
|
|
1
|
-
module Tap
|
2
|
-
module Support
|
3
|
-
|
4
|
-
# ConfigurableMethods encapsulates all class methods used to declare
|
5
|
-
# configurations in Tasks. ConfigurableMethods extends classes that
|
6
|
-
# include Tap::Support::Configurable.
|
7
|
-
#
|
8
|
-
# class ConfigurableClass
|
9
|
-
# include Configurable
|
10
|
-
#
|
11
|
-
# config :one, 'one'
|
12
|
-
# config :two, 'two'
|
13
|
-
# config :three, 'three'
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# ConfigurableClass.new.config # => {:one => 'one', :two => 'two', :three => 'three'}
|
17
|
-
#
|
18
|
-
# See the 'Configuration' section in the Tap::Task documentation for
|
19
|
-
# more details on how Configurable works in practice.
|
20
|
-
module ConfigurableMethods
|
21
|
-
|
22
|
-
# A Tap::Support::ClassConfiguration holding the class configurations.
|
23
|
-
attr_reader :configurations
|
24
|
-
|
25
|
-
# When subclassed, the configurations are duplicated and passed to
|
26
|
-
# the child class where they can be extended/modified without affecting
|
27
|
-
# the configurations of the parent class.
|
28
|
-
def inherited(child)
|
29
|
-
super
|
30
|
-
child.instance_variable_set(:@configurations, ClassConfiguration.new(child, @configurations))
|
31
|
-
child.instance_variable_set(:@source_files, source_files.dup)
|
32
|
-
end
|
33
|
-
|
34
|
-
# EXPERIMENTAL
|
35
|
-
attr_reader :source_files # :nodoc:
|
36
|
-
|
37
|
-
# EXPERIMENTAL
|
38
|
-
# Identifies source files for TDoc documentation.
|
39
|
-
def source_file(arg) # :nodoc:
|
40
|
-
source_files << arg
|
41
|
-
end
|
42
|
-
|
43
|
-
# Declares a configuration without any accessors.
|
44
|
-
#
|
45
|
-
# With no keys specified, sets config to make no
|
46
|
-
# accessors for each new configuration.
|
47
|
-
def declare_config(*keys)
|
48
|
-
if keys.empty?
|
49
|
-
self.config_mode = :none
|
50
|
-
else
|
51
|
-
keys.each {|key| configurations.add(key)}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Creates a configuration writer for the input keys. Works like
|
56
|
-
# attr_writer, except the value is written to config, rather than
|
57
|
-
# a local variable. In addition, the config will be validated
|
58
|
-
# using validate_config upon setting the value.
|
59
|
-
#
|
60
|
-
# With no keys specified, sets config to create config_writer
|
61
|
-
# for each new configuration.
|
62
|
-
def config_writer(*keys)
|
63
|
-
if keys.empty?
|
64
|
-
self.config_mode = :config_writer
|
65
|
-
else
|
66
|
-
keys.each do |key|
|
67
|
-
configurations.add(key)
|
68
|
-
define_config_writer(key)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Creates a configuration reader for the input keys. Works like
|
74
|
-
# attr_reader, except the value is read from config, rather than
|
75
|
-
# a local variable.
|
76
|
-
#
|
77
|
-
# With no keys specified, sets config to create a config_reader
|
78
|
-
# for each new configuration.
|
79
|
-
def config_reader(*keys)
|
80
|
-
if keys.empty?
|
81
|
-
self.config_mode = :config_reader
|
82
|
-
else
|
83
|
-
keys.each do |key|
|
84
|
-
configurations.add(key)
|
85
|
-
define_config_reader(key)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Creates configuration accessors for the input keys. Works like
|
91
|
-
# attr_accessor, except the value is read from and written to config,
|
92
|
-
# rather than a local variable.
|
93
|
-
#
|
94
|
-
# With no keys specified, sets config to create a config_accessor
|
95
|
-
# for each new configuration.
|
96
|
-
def config_accessor(*keys)
|
97
|
-
if keys.empty?
|
98
|
-
self.config_mode = :config_accessor
|
99
|
-
else
|
100
|
-
keys.each do |key|
|
101
|
-
configurations.add(key)
|
102
|
-
define_config_reader(key)
|
103
|
-
define_config_writer(key)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Sets a class configuration. Configurations are inherited, but can
|
109
|
-
# be overridden or added in subclasses. Accessors are created by
|
110
|
-
# default, but this behavior can be modified by use of the other
|
111
|
-
# config methods.
|
112
|
-
#
|
113
|
-
# class SampleClass
|
114
|
-
# include Configurable
|
115
|
-
#
|
116
|
-
# config :key, 'value'
|
117
|
-
# config_reader
|
118
|
-
# config :reader_only
|
119
|
-
# end
|
120
|
-
#
|
121
|
-
# t = SampleClass.new
|
122
|
-
# t.respond_to?(:reader_only) # => true
|
123
|
-
# t.respond_to?(:reader_only=) # => false
|
124
|
-
#
|
125
|
-
# t.config # => {:key => 'value', :reader_only => nil}
|
126
|
-
# t.key # => 'value'
|
127
|
-
# t.key = 'another'
|
128
|
-
# t.config # => {:key => 'another', :reader_only => nil}
|
129
|
-
#
|
130
|
-
# A block can be specified for validation/pre-processing. All inputs
|
131
|
-
# set through the config accessors, as well as the instance config=
|
132
|
-
# method are processed by the block before they set the value in the
|
133
|
-
# config hash. The config value will be set to the return of the block.
|
134
|
-
#
|
135
|
-
# The Tap::Support::Validation module provides methods to perform
|
136
|
-
# common checks and transformations. These can be accessed through
|
137
|
-
# the class method 'c':
|
138
|
-
#
|
139
|
-
# class ValidatingClass
|
140
|
-
# include Configurable
|
141
|
-
#
|
142
|
-
# config :one, 'one', &c.check(String)
|
143
|
-
# config :two, 'two' do |v|
|
144
|
-
# v.upcase
|
145
|
-
# end
|
146
|
-
# end
|
147
|
-
#
|
148
|
-
# t = ValidatingClass.new
|
149
|
-
#
|
150
|
-
# # note the default values ARE processed
|
151
|
-
# t.config # => {:one => 'one', :two => 'TWO'}
|
152
|
-
# t.one = 1 # => ValidationError
|
153
|
-
# t.config = {:one => 1} # => ValidationError
|
154
|
-
#
|
155
|
-
# t.config = {:one => 'str', :two => 'str'}
|
156
|
-
# t.config # => {:one => 'str', :two => 'STR'}
|
157
|
-
#
|
158
|
-
def config(key, value=nil, &validation)
|
159
|
-
configurations.add(key, value, &validation)
|
160
|
-
|
161
|
-
case config_mode
|
162
|
-
when :config_accessor
|
163
|
-
define_config_writer(key)
|
164
|
-
define_config_reader(key)
|
165
|
-
when :config_writer
|
166
|
-
define_config_writer(key)
|
167
|
-
when :config_reader
|
168
|
-
define_config_reader(key)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def config_merge(klass)
|
173
|
-
configurations.merge(klass.configurations) do |key|
|
174
|
-
case config_mode
|
175
|
-
when :config_accessor
|
176
|
-
define_config_writer(key)
|
177
|
-
define_config_reader(key)
|
178
|
-
when :config_writer
|
179
|
-
define_config_writer(key)
|
180
|
-
when :config_reader
|
181
|
-
define_config_reader(key)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
# Returns the default name for the class: class.to_s.underscore
|
187
|
-
def default_name
|
188
|
-
@default_name ||= to_s.underscore
|
189
|
-
end
|
190
|
-
|
191
|
-
protected
|
192
|
-
|
193
|
-
attr_writer :config_mode
|
194
|
-
|
195
|
-
# Tracks the current configuration mode, to determine what
|
196
|
-
# in any accessors should be generated for the configuration.
|
197
|
-
# (default :config_accessor)
|
198
|
-
def config_mode
|
199
|
-
@config_mode ||= :config_accessor
|
200
|
-
end
|
201
|
-
|
202
|
-
# Alias for Tap::Support::Validation
|
203
|
-
def c
|
204
|
-
Validation
|
205
|
-
end
|
206
|
-
|
207
|
-
private
|
208
|
-
|
209
|
-
def define_config_reader(name, key=name) # :nodoc:
|
210
|
-
key = key.to_sym
|
211
|
-
define_method(name) do
|
212
|
-
config[key]
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
def define_config_writer(name, key=name) # :nodoc:
|
217
|
-
key = key.to_sym
|
218
|
-
define_method("#{name}=") do |value|
|
219
|
-
set_config(key, value)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|