tap 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Basic Overview b/data/Basic → Overview +0 -0
- data/Command Reference b/data/Command → Reference +0 -0
- data/History +14 -4
- data/MIT-LICENSE +0 -0
- data/README +0 -0
- data/Rakefile +0 -0
- data/Tutorial +0 -0
- data/bin/tap +11 -14
- data/lib/tap.rb +10 -1
- data/lib/tap/app.rb +1 -1
- data/lib/tap/cmd/console.rb +2 -6
- data/lib/tap/cmd/destroy.rb +0 -0
- data/lib/tap/cmd/generate.rb +0 -0
- data/lib/tap/cmd/run.rb +72 -77
- data/lib/tap/constants.rb +33 -2
- data/lib/tap/dump.rb +0 -0
- data/lib/tap/env.rb +40 -21
- data/lib/tap/file_task.rb +0 -0
- data/lib/tap/generator.rb +0 -0
- data/lib/tap/generator/generators/command/USAGE +0 -0
- data/lib/tap/generator/generators/command/command_generator.rb +0 -0
- data/lib/tap/generator/generators/command/templates/command.erb +2 -6
- data/lib/tap/generator/generators/config/USAGE +0 -0
- data/lib/tap/generator/generators/config/config_generator.rb +0 -0
- data/lib/tap/generator/generators/config/templates/config.erb +0 -0
- data/lib/tap/generator/generators/file_task/USAGE +0 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +0 -0
- data/lib/tap/generator/generators/file_task/templates/file.txt +0 -0
- data/lib/tap/generator/generators/file_task/templates/file.yml +0 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +0 -0
- data/lib/tap/generator/generators/file_task/templates/test.erb +0 -0
- data/lib/tap/generator/generators/generator/USAGE +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +0 -0
- data/lib/tap/generator/generators/generator/templates/generator.erb +0 -0
- data/lib/tap/generator/generators/generator/templates/usage.erb +0 -0
- data/lib/tap/generator/generators/root/USAGE +0 -0
- data/lib/tap/generator/generators/root/root_generator.rb +0 -0
- data/lib/tap/generator/generators/root/templates/Rakefile +0 -0
- data/lib/tap/generator/generators/root/templates/ReadMe.txt +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +1 -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 +0 -0
- data/lib/tap/generator/generators/task/USAGE +0 -0
- data/lib/tap/generator/generators/task/task_generator.rb +0 -0
- data/lib/tap/generator/generators/task/templates/task.erb +0 -0
- data/lib/tap/generator/generators/task/templates/test.erb +0 -0
- data/lib/tap/generator/generators/workflow/USAGE +0 -0
- data/lib/tap/generator/generators/workflow/templates/task.erb +0 -0
- data/lib/tap/generator/generators/workflow/templates/test.erb +0 -0
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +0 -0
- data/lib/tap/generator/options.rb +0 -0
- data/lib/tap/generator/usage.rb +0 -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 +0 -0
- data/lib/tap/support/aggregator.rb +0 -0
- data/lib/tap/support/audit.rb +0 -0
- data/lib/tap/support/batchable.rb +2 -25
- data/lib/tap/support/batchable_methods.rb +34 -0
- data/lib/tap/support/class_configuration.rb +0 -0
- data/lib/tap/support/command_line.rb +103 -0
- data/lib/tap/support/command_line_methods.rb +76 -0
- data/lib/tap/support/configurable.rb +1 -0
- data/lib/tap/support/configurable_methods.rb +1 -73
- data/lib/tap/support/executable.rb +0 -0
- data/lib/tap/support/executable_queue.rb +0 -0
- data/lib/tap/support/logger.rb +0 -0
- data/lib/tap/support/rake.rb +0 -0
- data/lib/tap/support/run_error.rb +0 -0
- data/lib/tap/support/shell_utils.rb +0 -0
- data/lib/tap/support/tdoc.rb +0 -0
- data/lib/tap/support/tdoc/config_attr.rb +0 -0
- 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/validation.rb +0 -0
- data/lib/tap/support/versions.rb +0 -0
- data/lib/tap/task.rb +1 -0
- data/lib/tap/test.rb +0 -0
- data/lib/tap/test/env_vars.rb +0 -0
- data/lib/tap/test/file_methods.rb +1 -1
- data/lib/tap/test/subset_methods.rb +0 -0
- data/lib/tap/test/tap_methods.rb +0 -0
- data/lib/tap/workflow.rb +1 -0
- data/test/app/config/another/task.yml +0 -0
- data/test/app/config/batch.yml +0 -0
- data/test/app/config/empty.yml +0 -0
- data/test/app/config/erb.yml +0 -0
- data/test/app/config/some/task.yml +0 -0
- data/test/app/config/template.yml +0 -0
- data/test/app/config/version-0.1.yml +0 -0
- data/test/app/config/version.yml +0 -0
- data/test/app/lib/app_test_task.rb +0 -0
- data/test/app_test.rb +0 -0
- data/test/env/test_configure/recurse_a.yml +0 -0
- data/test/env/test_configure/recurse_b.yml +0 -0
- data/test/env/test_configure/tap.yml +0 -0
- data/test/env/test_load_env_config/dir/tap.yml +0 -0
- data/test/env/test_load_env_config/recurse_a.yml +0 -0
- data/test/env/test_load_env_config/recurse_b.yml +0 -0
- data/test/env/test_load_env_config/tap.yml +0 -0
- data/test/env_test.rb +0 -0
- data/test/file_task/config/batch.yml +0 -0
- data/test/file_task/config/configured.yml +0 -0
- 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 -0
- data/test/root/alt_lib/alt_module.rb +0 -0
- 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 -0
- data/test/root/lib/alternative_filepath.rb +0 -0
- data/test/root/lib/another_module.rb +0 -0
- data/test/root/lib/nested/some_module.rb +0 -0
- data/test/root/lib/no_module_included.rb +0 -0
- data/test/root/lib/some/module.rb +0 -0
- data/test/root/lib/some_class.rb +0 -0
- data/test/root/lib/some_module.rb +0 -0
- data/test/root/load_path/load_path_module.rb +0 -0
- data/test/root/load_path/skip_module.rb +0 -0
- data/test/root/mtime/older.txt +0 -0
- data/test/root/unload/full_path.rb +0 -0
- data/test/root/unload/loaded_by_nested.rb +0 -0
- data/test/root/unload/nested/nested_load.rb +0 -0
- data/test/root/unload/nested/nested_with_ext.rb +0 -0
- data/test/root/unload/nested/relative_path.rb +0 -0
- data/test/root/unload/older.rb +0 -0
- data/test/root/unload/unload_base.rb +0 -0
- 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 -0
- data/test/support/aggregator_test.rb +0 -0
- data/test/support/audit_test.rb +0 -0
- data/test/support/batchable_test.rb +0 -0
- data/test/support/class_configuration_test.rb +0 -0
- data/test/{script_test.rb → support/command_line_test.rb} +21 -21
- data/test/support/configurable/config/configured.yml +0 -0
- data/test/support/configurable_test.rb +0 -0
- data/test/support/executable_queue_test.rb +0 -0
- data/test/support/executable_test.rb +0 -0
- data/test/support/logger_test.rb +0 -0
- data/test/support/rake_test.rb +0 -0
- data/test/support/shell_utils_test.rb +0 -0
- data/test/support/tdoc_test.rb +0 -0
- data/test/support/validation_test.rb +0 -0
- data/test/support/versions_test.rb +0 -0
- data/test/tap_test_helper.rb +0 -0
- data/test/tap_test_suite.rb +0 -0
- data/test/task/config/batch.yml +0 -0
- data/test/task/config/batched.yml +0 -0
- data/test/task/config/configured.yml +0 -0
- data/test/task/config/example.yml +0 -0
- data/test/task_base_test.rb +0 -0
- data/test/task_syntax_test.rb +0 -0
- data/test/task_test.rb +0 -0
- data/test/test/env_vars_test.rb +0 -0
- data/test/test/file_methods/test_assert_files/expected/one.txt +0 -0
- data/test/test/file_methods/test_assert_files/expected/two.txt +0 -0
- data/test/test/file_methods/test_assert_files/input/one.txt +0 -0
- data/test/test/file_methods/test_assert_files/input/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/one.txt +0 -0
- data/test/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 +0 -0
- data/test/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 +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +0 -0
- data/test/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 +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +0 -0
- 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 -0
- data/test/test/file_methods_doc/test_sub/expected/two.txt +0 -0
- data/test/test/file_methods_doc/test_sub/input/one.txt +0 -0
- data/test/test/file_methods_doc/test_sub/input/two.txt +0 -0
- data/test/test/file_methods_doc_test.rb +0 -0
- data/test/test/file_methods_test.rb +0 -0
- data/test/test/subset_methods_test.rb +0 -0
- data/test/test/tap_methods/test_assert_files/expected/task/name/a.txt +0 -0
- data/test/test/tap_methods/test_assert_files/expected/task/name/b.txt +0 -0
- data/test/test/tap_methods/test_assert_files/input/a.txt +0 -0
- data/test/test/tap_methods/test_assert_files/input/b.txt +0 -0
- data/test/test/tap_methods_test.rb +0 -0
- data/test/workflow_test.rb +0 -0
- data/vendor/rails_generator.rb +0 -0
- data/vendor/rails_generator/base.rb +0 -0
- data/vendor/rails_generator/commands.rb +0 -0
- data/vendor/rails_generator/generated_attribute.rb +0 -0
- data/vendor/rails_generator/lookup.rb +0 -0
- data/vendor/rails_generator/manifest.rb +0 -0
- data/vendor/rails_generator/options.rb +0 -0
- data/vendor/rails_generator/scripts.rb +0 -0
- data/vendor/rails_generator/scripts/destroy.rb +0 -0
- data/vendor/rails_generator/scripts/generate.rb +0 -0
- data/vendor/rails_generator/scripts/update.rb +0 -0
- data/vendor/rails_generator/simple_logger.rb +0 -0
- data/vendor/rails_generator/spec.rb +0 -0
- metadata +7 -5
- data/lib/tap/script.rb +0 -96
data/lib/tap/file_task.rb
CHANGED
File without changes
|
data/lib/tap/generator.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -7,7 +7,6 @@
|
|
7
7
|
#
|
8
8
|
|
9
9
|
require 'tap'
|
10
|
-
require 'tap/script'
|
11
10
|
|
12
11
|
app = Tap::App.instance
|
13
12
|
|
@@ -19,13 +18,10 @@ opts = [
|
|
19
18
|
['--help', '-h', GetoptLong::NO_ARGUMENT, "Print this help."],
|
20
19
|
['--debug', nil, GetoptLong::NO_ARGUMENT, "Specifies debug mode."]]
|
21
20
|
|
22
|
-
Tap::
|
21
|
+
Tap::Support::CommandLine.handle_options(*opts) do |opt, value|
|
23
22
|
case opt
|
24
23
|
when '--help'
|
25
|
-
puts Tap::
|
26
|
-
puts
|
27
|
-
puts "Options:"
|
28
|
-
puts Tap::Script.usage_options(opts)
|
24
|
+
puts Tap::Support::CommandLine.command_help(__FILE__, opts)
|
29
25
|
exit
|
30
26
|
|
31
27
|
when '--debug'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/tap/generator/usage.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/tap/root.rb
CHANGED
File without changes
|
File without changes
|
data/lib/tap/support/audit.rb
CHANGED
File without changes
|
@@ -1,35 +1,12 @@
|
|
1
1
|
module Tap
|
2
2
|
module Support
|
3
|
-
|
3
|
+
|
4
4
|
# Batchable encapsulates the methods used to support batching
|
5
5
|
# of tasks. See the 'Batches' section in the Tap::Task
|
6
6
|
# documentation for more details on how Batchable works in
|
7
7
|
# practice.
|
8
8
|
module Batchable
|
9
|
-
|
10
|
-
# Merges the batches for the specified objects. All objects
|
11
|
-
# sharing the individual object batches will be affected, even
|
12
|
-
# if they are not listed explicitly as an input.
|
13
|
-
#
|
14
|
-
# t1 = Tap::Task.new
|
15
|
-
# t2 = Tap::Task.new
|
16
|
-
# t3 = t2.initialize_batch_obj
|
17
|
-
#
|
18
|
-
# Batchable.batch(t1, t2)
|
19
|
-
# t3.batch # => [t1,t2,t3]
|
20
|
-
#
|
21
|
-
# Returns the new batch.
|
22
|
-
def self.batch(*tasks)
|
23
|
-
merged = []
|
24
|
-
batches = tasks.collect {|task| task.batch }.uniq
|
25
|
-
batches.each do |batch|
|
26
|
-
merged.concat(batch)
|
27
|
-
batch.clear
|
28
|
-
end
|
29
|
-
merged.uniq!
|
30
|
-
batches.each {|batch| batch.concat(merged) }
|
31
|
-
merged
|
32
|
-
end
|
9
|
+
extend Support::BatchableMethods
|
33
10
|
|
34
11
|
# The object batch. (must be initializd by classes that
|
35
12
|
# include Batchable)
|
@@ -0,0 +1,34 @@
|
|
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
|
File without changes
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Tap
|
2
|
+
module Support
|
3
|
+
|
4
|
+
# Under Construction
|
5
|
+
module CommandLine
|
6
|
+
module_function
|
7
|
+
|
8
|
+
# Parses the input string as YAML, if the string matches the YAML document
|
9
|
+
# specifier (ie it begins with "---\s*\n"). Otherwise returns the string.
|
10
|
+
#
|
11
|
+
# str = {'key' => 'value'}.to_yaml # => "--- \nkey: value\n"
|
12
|
+
# Tap::Script.parse_yaml(str) # => {'key' => 'value'}
|
13
|
+
# Tap::Script.parse_yaml("str") # => "str"
|
14
|
+
def parse_yaml(str)
|
15
|
+
str =~ /\A---\s*\n/ ? YAML.load(str) : str
|
16
|
+
end
|
17
|
+
|
18
|
+
def split_argv(argv)
|
19
|
+
current = []
|
20
|
+
current_split = []
|
21
|
+
splits = [current_split]
|
22
|
+
|
23
|
+
argv.each do |arg|
|
24
|
+
if arg =~ /\A-{2}(\+*)\z/
|
25
|
+
current_split << current unless current.empty?
|
26
|
+
current = []
|
27
|
+
current_split = (splits[$1.length] ||= [])
|
28
|
+
else
|
29
|
+
current << arg
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
current_split << current unless current.empty?
|
34
|
+
splits.delete_if {|split| split.nil? || split.empty? }
|
35
|
+
splits
|
36
|
+
end
|
37
|
+
|
38
|
+
def next_arg(argv)
|
39
|
+
index = nil
|
40
|
+
argv.each_with_index do |arg, i|
|
41
|
+
if arg !~ /\A-/
|
42
|
+
index = i
|
43
|
+
break
|
44
|
+
end
|
45
|
+
end
|
46
|
+
index == nil ? nil : argv.delete_at(index)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Handles options using GetoptLong, and passes each option and
|
50
|
+
# value in ARGV to the block.
|
51
|
+
#
|
52
|
+
#--
|
53
|
+
# expect [long, <short>, type, desc]
|
54
|
+
#++
|
55
|
+
def handle_options(*options)
|
56
|
+
options = options.collect do |opt|
|
57
|
+
opt = opt[0..-2]
|
58
|
+
opt.compact
|
59
|
+
end
|
60
|
+
|
61
|
+
opts = GetoptLong.new(*options)
|
62
|
+
opts.quiet = true
|
63
|
+
opts.each do |opt, value|
|
64
|
+
yield(opt, value)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def command_help(program_file, opts)
|
69
|
+
lines = []
|
70
|
+
lines << usage(program_file, "Usage", "Description", :keep_headers => false)
|
71
|
+
unless opts.empty?
|
72
|
+
lines.concat ["Options:", usage_options(opts)]
|
73
|
+
end
|
74
|
+
lines.join("\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
def usage(program_file, *sections)
|
78
|
+
options = sections.last.kind_of?(Hash) ? sections.pop : {}
|
79
|
+
options = {:keep_headers => true}.merge(options)
|
80
|
+
comment = Tap::Support::TDoc.usage(program_file, sections, options[:keep_headers])
|
81
|
+
comment.rstrip + "\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
def usage_options(opts)
|
85
|
+
opt_lines = []
|
86
|
+
opts.each do |long, short, mode, desc|
|
87
|
+
|
88
|
+
if desc.kind_of?(Class) && desc.include?(Tap::Support::Configurable)
|
89
|
+
key = desc.configurations.opt_map(long)
|
90
|
+
default = PP.singleline_pp(desc.configurations.default[key], "")
|
91
|
+
config_attr = desc.tdoc.find_configuration_named(key.to_s)
|
92
|
+
desc = config_attr.desc
|
93
|
+
end
|
94
|
+
|
95
|
+
short = short == nil ? " " : "(#{short})"
|
96
|
+
opt_lines << " %-25s %s %s" % [long, short, desc]
|
97
|
+
end
|
98
|
+
opt_lines.join("\n")
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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
|
@@ -22,6 +22,7 @@ module Tap
|
|
22
22
|
include Batchable
|
23
23
|
|
24
24
|
def self.included(mod)
|
25
|
+
mod.extend Support::BatchableMethods
|
25
26
|
mod.extend Support::ConfigurableMethods
|
26
27
|
mod.instance_variable_set(:@configurations, Support::ClassConfiguration.new(mod))
|
27
28
|
mod.instance_variable_set(:@source_files, [])
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Tap
|
2
2
|
module Support
|
3
|
-
|
4
|
-
|
3
|
+
|
5
4
|
# ConfigurableMethods encapsulates all class methods used to declare
|
6
5
|
# configurations in Tasks. ConfigurableMethods extends classes that
|
7
6
|
# include Tap::Support::Configurable.
|
@@ -188,78 +187,7 @@ module Tap
|
|
188
187
|
def default_name
|
189
188
|
@default_name ||= to_s.underscore
|
190
189
|
end
|
191
|
-
|
192
|
-
# Alias for Batchable.batch
|
193
|
-
def batch(*batchables)
|
194
|
-
Batchable.batch(*batchables)
|
195
|
-
end
|
196
|
-
|
197
|
-
# Returns the TDoc documentation for self.
|
198
|
-
def tdoc
|
199
|
-
@tdoc ||= Tap::Support::TDoc[self]
|
200
|
-
end
|
201
|
-
|
202
|
-
# EXPERIMENTAL
|
203
|
-
def help(opts=configurations.to_opts) # :nodoc:
|
204
|
-
return "could not find help for '#{self}'" if tdoc == nil
|
205
|
-
|
206
|
-
sections = tdoc.comment_sections(/Description|Usage/i, true)
|
207
|
-
%Q{#{self}
|
208
|
-
|
209
|
-
#{sections["Description"]}
|
210
|
-
Usage:
|
211
|
-
#{sections["Usage"]}
|
212
|
-
Options:
|
213
|
-
#{Tap::Script.usage_options(opts)}
|
214
|
-
|
215
|
-
}
|
216
|
-
end
|
217
190
|
|
218
|
-
# EXPERIMENTAL
|
219
|
-
def argv_enq(app=App.instance, &block) # :nodoc:
|
220
|
-
if block_given?
|
221
|
-
@argv_enq_block = block
|
222
|
-
return
|
223
|
-
end
|
224
|
-
return @argv_enq_block.call(app) if @argv_enq_block ||= nil
|
225
|
-
|
226
|
-
config = {}
|
227
|
-
opts = configurations.to_opts
|
228
|
-
opts << ['--help', nil, GetoptLong::NO_ARGUMENT, "Print this help."]
|
229
|
-
opts << ['--debug', nil, GetoptLong::NO_ARGUMENT, "Trace execution and debug"]
|
230
|
-
opts << ['--use', nil, GetoptLong::REQUIRED_ARGUMENT, "Loads inputs from file."]
|
231
|
-
opts << ['--iterate', nil, GetoptLong::NO_ARGUMENT, "Iterates over inputs."]
|
232
|
-
|
233
|
-
iterate = false
|
234
|
-
Tap::Script.handle_options(*opts) do |opt, value|
|
235
|
-
case opt
|
236
|
-
when '--help'
|
237
|
-
puts help(opts)
|
238
|
-
exit
|
239
|
-
|
240
|
-
when '--debug'
|
241
|
-
app.options.debug = true
|
242
|
-
|
243
|
-
when '--use'
|
244
|
-
hash = YAML.load_file(value)
|
245
|
-
hash.values.each do |args|
|
246
|
-
ARGV.concat(args)
|
247
|
-
end
|
248
|
-
|
249
|
-
when '--iterate'
|
250
|
-
iterate = true
|
251
|
-
|
252
|
-
else
|
253
|
-
key = configurations.opt_map(opt)
|
254
|
-
config[key] = YAML.load(value)
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
# configure task
|
259
|
-
task = app.task(ARGV.shift, config)
|
260
|
-
iterate ? ARGV.each {|input| task.enq(input) } : task.enq(*ARGV)
|
261
|
-
end
|
262
|
-
|
263
191
|
protected
|
264
192
|
|
265
193
|
attr_writer :config_mode
|