tap 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +12 -0
- data/MIT-LICENSE +0 -2
- data/README +23 -32
- data/bin/rap +116 -0
- data/bin/tap +6 -9
- data/cgi/run.rb +67 -0
- data/cmd/console.rb +1 -1
- data/cmd/destroy.rb +4 -4
- data/cmd/generate.rb +4 -4
- data/cmd/manifest.rb +61 -53
- data/cmd/run.rb +8 -75
- data/doc/Class Reference +130 -121
- data/doc/Command Reference +76 -124
- data/doc/Syntax Reference +290 -0
- data/doc/Tutorial +305 -237
- data/lib/tap/app.rb +140 -467
- data/lib/tap/constants.rb +2 -2
- data/lib/tap/declarations.rb +211 -0
- data/lib/tap/env.rb +171 -193
- data/lib/tap/exe.rb +100 -21
- data/lib/tap/file_task.rb +3 -3
- data/lib/tap/generator/base.rb +1 -1
- data/lib/tap/generator/destroy.rb +10 -10
- data/lib/tap/generator/generate.rb +29 -18
- data/lib/tap/generator/generators/command/command_generator.rb +2 -2
- data/lib/tap/generator/generators/command/templates/command.erb +2 -2
- data/lib/tap/generator/generators/config/config_generator.rb +3 -3
- data/lib/tap/generator/generators/config/templates/doc.erb +1 -1
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +1 -1
- data/lib/tap/generator/generators/file_task/templates/task.erb +1 -1
- data/lib/tap/generator/generators/file_task/templates/test.erb +1 -1
- data/lib/tap/generator/generators/generator/generator_generator.rb +27 -0
- data/lib/tap/generator/generators/generator/templates/task.erb +27 -0
- data/lib/tap/generator/generators/root/root_generator.rb +13 -13
- data/lib/tap/generator/generators/root/templates/README +0 -0
- data/lib/tap/generator/generators/root/templates/Rakefile +2 -2
- data/lib/tap/generator/generators/root/templates/gemspec +4 -5
- data/lib/tap/generator/generators/root/templates/tapfile +11 -8
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
- data/lib/tap/generator/generators/task/task_generator.rb +1 -3
- data/lib/tap/generator/generators/task/templates/test.erb +1 -3
- data/lib/tap/patches/optparse/summarize.rb +62 -0
- data/lib/tap/root.rb +41 -29
- data/lib/tap/support/aggregator.rb +16 -3
- data/lib/tap/support/assignments.rb +10 -9
- data/lib/tap/support/audit.rb +58 -64
- data/lib/tap/support/class_configuration.rb +33 -44
- data/lib/tap/support/combinator.rb +125 -0
- data/lib/tap/support/configurable.rb +13 -14
- data/lib/tap/support/configurable_class.rb +21 -43
- data/lib/tap/support/configuration.rb +55 -9
- data/lib/tap/support/constant.rb +87 -13
- data/lib/tap/support/constant_manifest.rb +116 -0
- data/lib/tap/support/dependencies.rb +54 -0
- data/lib/tap/support/dependency.rb +44 -0
- data/lib/tap/support/executable.rb +247 -32
- data/lib/tap/support/executable_queue.rb +1 -1
- data/lib/tap/support/gems/rake.rb +29 -8
- data/lib/tap/support/gems.rb +10 -30
- data/lib/tap/support/instance_configuration.rb +29 -3
- data/lib/tap/support/intern.rb +46 -0
- data/lib/tap/support/join.rb +143 -0
- data/lib/tap/support/joins/fork.rb +19 -0
- data/lib/tap/support/joins/merge.rb +22 -0
- data/lib/tap/support/joins/sequence.rb +21 -0
- data/lib/tap/support/joins/switch.rb +25 -0
- data/lib/tap/support/joins/sync_merge.rb +63 -0
- data/lib/tap/support/joins.rb +15 -0
- data/lib/tap/support/lazy_attributes.rb +17 -2
- data/lib/tap/support/lazydoc/comment.rb +503 -0
- data/lib/tap/support/lazydoc/config.rb +17 -0
- data/lib/tap/support/lazydoc/definition.rb +36 -0
- data/lib/tap/support/lazydoc/document.rb +152 -0
- data/lib/tap/support/lazydoc/method.rb +24 -0
- data/lib/tap/support/lazydoc.rb +269 -343
- data/lib/tap/support/manifest.rb +121 -103
- data/lib/tap/support/minimap.rb +90 -0
- data/lib/tap/support/node.rb +56 -0
- data/lib/tap/support/parser.rb +436 -0
- data/lib/tap/support/schema.rb +359 -0
- data/lib/tap/support/shell_utils.rb +3 -5
- data/lib/tap/support/string_ext.rb +60 -0
- data/lib/tap/support/tdoc.rb +7 -2
- data/lib/tap/support/templater.rb +30 -16
- data/lib/tap/support/validation.rb +77 -8
- data/lib/tap/task.rb +431 -143
- data/lib/tap/tasks/dump.rb +15 -10
- data/lib/tap/tasks/load.rb +112 -0
- data/lib/tap/tasks/rake.rb +4 -41
- data/lib/tap/test/assertions.rb +38 -0
- data/lib/tap/test/env_vars.rb +1 -1
- data/lib/tap/test/extensions.rb +79 -0
- data/lib/tap/test/file_test.rb +420 -0
- data/lib/tap/test/file_test_class.rb +12 -0
- data/lib/tap/test/regexp_escape.rb +87 -0
- data/lib/tap/test/script_test.rb +46 -0
- data/lib/tap/test/script_tester.rb +115 -0
- data/lib/tap/test/subset_test.rb +260 -0
- data/lib/tap/test/subset_test_class.rb +99 -0
- data/lib/tap/test/{tap_methods.rb → tap_test.rb} +45 -43
- data/lib/tap/test/utils.rb +231 -0
- data/lib/tap/test.rb +53 -26
- data/lib/tap.rb +3 -20
- metadata +50 -27
- data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +0 -15
- data/lib/tap/patches/rake/rake_test_loader.rb +0 -8
- data/lib/tap/patches/rake/testtask.rb +0 -57
- data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -51
- data/lib/tap/patches/ruby19/parsedate.rb +0 -16
- data/lib/tap/support/batchable.rb +0 -47
- data/lib/tap/support/batchable_class.rb +0 -107
- data/lib/tap/support/command_line.rb +0 -98
- data/lib/tap/support/comment.rb +0 -270
- data/lib/tap/support/constant_utils.rb +0 -127
- data/lib/tap/support/declarations.rb +0 -111
- data/lib/tap/support/framework.rb +0 -83
- data/lib/tap/support/framework_class.rb +0 -180
- data/lib/tap/support/run_error.rb +0 -39
- data/lib/tap/support/summary.rb +0 -30
- data/lib/tap/test/file_methods.rb +0 -377
- data/lib/tap/test/script_methods/script_test.rb +0 -98
- data/lib/tap/test/script_methods.rb +0 -107
- data/lib/tap/test/subset_methods.rb +0 -420
- data/lib/tap/workflow.rb +0 -200
data/History
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 0.11.0 / 2008-10-20
|
2
|
+
|
3
|
+
Significant update to Tap with many internal reworks.
|
4
|
+
Major changes include:
|
5
|
+
|
6
|
+
* Addition of Parser/Schema
|
7
|
+
* Addition of rap and task declarations
|
8
|
+
* Removal of Workflow in preference of workflow
|
9
|
+
definitions within Task
|
10
|
+
* Refactoring of Test modules
|
11
|
+
* Expanded/updated documentation
|
12
|
+
|
1
13
|
== 0.10.1 / 2008-08-21
|
2
14
|
|
3
15
|
Update of Tap with a few improvements to manifests
|
data/MIT-LICENSE
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
Copyright (c) 2006-2008, Regents of the University of Colorado.
|
2
|
-
Developer:: Simon Chiang, Biomolecular Structure Program, Hansen Lab
|
3
|
-
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
4
2
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
6
4
|
software and associated documentation files (the "Software"), to deal in the Software
|
data/README
CHANGED
@@ -5,21 +5,22 @@ A framework for creating configurable, distributable tasks and workflows.
|
|
5
5
|
== Description
|
6
6
|
|
7
7
|
Tap tasks are designed to be easy to test, subclass, use in scripts, and run
|
8
|
-
from the command line. Tap provides methods to
|
9
|
-
|
10
|
-
libraries are readily shared as gems.
|
11
|
-
development, and bug tracking.
|
8
|
+
from the command line. Tap provides methods to join tasks into imperative
|
9
|
+
and dependecy-based workflows, utilize static config files, as well as dump
|
10
|
+
and reuse results. Task libraries are readily shared as gems.
|
12
11
|
|
13
|
-
|
12
|
+
Check out these links for tutorials, development, and bug tracking.
|
13
|
+
|
14
|
+
* {Tutorial}[link:files/doc/Tutorial.html], {Class}[link:files/doc/Class%20Reference.html], {Command}[link:files/doc/Command%20Reference.html], and {Syntax}[link:files/doc/Syntax%20Reference.html] References
|
14
15
|
* Website[http://tap.rubyforge.org]
|
15
|
-
* Lighthouse[http://bahuvrihi.lighthouseapp.com/projects/9908-tap-task-application/
|
16
|
+
* Lighthouse[http://bahuvrihi.lighthouseapp.com/projects/9908-tap-task-application/tickets]
|
16
17
|
* Github[http://github.com/bahuvrihi/tap/tree/master]
|
17
|
-
* Google Group[http://groups.google.com/group/ruby-on-tap]
|
18
|
+
* {Google Group}[http://groups.google.com/group/ruby-on-tap]
|
18
19
|
|
19
|
-
===
|
20
|
+
=== Features
|
20
21
|
|
21
22
|
- Tap and Rake[http://rake.rubyforge.org/] are targeted at different problems,
|
22
|
-
but play well together. See
|
23
|
+
but play well together. See the {Tutorial}[link:files/doc/Tutorial.html].
|
23
24
|
- Tap is tested on MRI (the standard Ruby interpreter, versions 1.8.6 and
|
24
25
|
1.9.0) and JRuby[http://jruby.codehaus.org/].
|
25
26
|
|
@@ -27,6 +28,8 @@ development, and bug tracking.
|
|
27
28
|
|
28
29
|
A simple task illustrates the usage of tap:
|
29
30
|
|
31
|
+
[lib/goodnight.rb]
|
32
|
+
|
30
33
|
# Goodnight::manifest your basic goodnight moon task
|
31
34
|
# Says goodnight with a configurable message.
|
32
35
|
class Goodnight < Tap::Task
|
@@ -46,6 +49,7 @@ Tap pulls documentation out of task classes to generate manifests:
|
|
46
49
|
goodnight # your basic goodnight moon task
|
47
50
|
tap:
|
48
51
|
dump # the default dump task
|
52
|
+
load # the default load task
|
49
53
|
rake # run rake tasks
|
50
54
|
|
51
55
|
And help:
|
@@ -66,39 +70,26 @@ And help:
|
|
66
70
|
--use FILE Loads inputs from file
|
67
71
|
|
68
72
|
|
69
|
-
Tasks are immediately available to run:
|
73
|
+
Tasks are immediately available to run through tap or rap:
|
70
74
|
|
71
75
|
% tap run -- goodnight moon
|
72
76
|
I[00:09:55] goodnight moon
|
73
77
|
|
74
|
-
|
75
|
-
% tap run -- goodnight moon --message hello
|
78
|
+
% rap goodnight moon --message hello
|
76
79
|
I[00:10:01] hello moon
|
77
|
-
|
78
|
-
Tap comes with generators and allows distribution of task libraries as gems.
|
79
|
-
This can be illustrated by installing the
|
80
|
-
{sample_tasks}[http://tap.rubyforge.org/sample_tasks] gem:
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
sample
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
copy # copies files
|
89
|
-
grep # search for lines matching a pattern
|
90
|
-
print_tree # print a directory tree
|
91
|
-
tap:
|
92
|
-
dump # the default dump task
|
93
|
-
rake # run rake tasks
|
81
|
+
Tap comes with generators. To get started:
|
82
|
+
|
83
|
+
% tap generate root sample
|
84
|
+
% cd sample
|
85
|
+
% tap generate task goodnight
|
86
|
+
% rap goodnight moon
|
94
87
|
|
95
88
|
=== Bugs/Known Issues
|
96
89
|
|
97
90
|
- Some inconsequential tests on JRuby fail due to bugs in JRuby itself.
|
98
|
-
-
|
99
|
-
|
100
|
-
- Despite the talk of workflows, the Workflow class should still be considered
|
101
|
-
in progress. Tasks themselves are stable.
|
91
|
+
- Joins, Parser, and Schema require additional documentation and may be
|
92
|
+
internally reworked. The workflow syntax should remain the same.
|
102
93
|
|
103
94
|
== Installation
|
104
95
|
|
data/bin/rap
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# usage: rap taskname {options} [args]
|
3
|
+
|
4
|
+
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
5
|
+
require 'tap/declarations'
|
6
|
+
|
7
|
+
# setup the environment
|
8
|
+
begin
|
9
|
+
|
10
|
+
# handle super options
|
11
|
+
$DEBUG = true if ARGV.delete('-d-')
|
12
|
+
env = Tap::Exe.instantiate
|
13
|
+
env.unshift(Tap::Declarations.env)
|
14
|
+
|
15
|
+
task_file = File.expand_path('Tapfile')
|
16
|
+
if File.exists?(task_file)
|
17
|
+
env.loads.unshift(task_file)
|
18
|
+
env.tasks.register(Dir.pwd, 'Tapfile')
|
19
|
+
end
|
20
|
+
|
21
|
+
rescue(Tap::Env::ConfigError)
|
22
|
+
# catch errors and exit gracefully
|
23
|
+
# (errors usu from gem loading errors)
|
24
|
+
puts $!.message
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# setup after script
|
30
|
+
#
|
31
|
+
|
32
|
+
at_exit do
|
33
|
+
begin
|
34
|
+
eval(env.after) if env.after != nil
|
35
|
+
rescue(Exception)
|
36
|
+
puts "Error in after script."
|
37
|
+
env.handle_error($!)
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# run before script
|
44
|
+
#
|
45
|
+
|
46
|
+
begin
|
47
|
+
eval(env.before) if env.before != nil
|
48
|
+
rescue(Exception)
|
49
|
+
puts "Error in before script."
|
50
|
+
env.handle_error($!)
|
51
|
+
exit(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# run rap
|
56
|
+
#
|
57
|
+
|
58
|
+
module Tap
|
59
|
+
module Tasks
|
60
|
+
autoload(:Rake, 'tap/tasks/rake')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
env.activate
|
66
|
+
|
67
|
+
case ARGV[0]
|
68
|
+
when '--help', nil, '-T'
|
69
|
+
rap_template = %Q{<% if count > 1 && !entries.empty? %>
|
70
|
+
<%= env_name %>:
|
71
|
+
<% end %>
|
72
|
+
<% entries.each do |name, const| %>
|
73
|
+
<% desc = if const.require_path == nil # should be a declaration %>
|
74
|
+
<% manifest = const.constantize.lazydoc[const.name]['manifest'] %>
|
75
|
+
<% next if manifest == nil || manifest.subject.empty? %>
|
76
|
+
<% manifest.subject %>
|
77
|
+
<% else %>
|
78
|
+
<% const.document[const.name]['manifest'] %>
|
79
|
+
<% end %>
|
80
|
+
<%= name.ljust(width) %><%= desc.empty? ? '' : ' # ' %><%= desc %>
|
81
|
+
<% end %>}
|
82
|
+
|
83
|
+
puts Tap::Support::Lazydoc.usage(__FILE__)
|
84
|
+
puts
|
85
|
+
puts "=== tap tasks ==="
|
86
|
+
puts env.summarize(:tasks, rap_template)
|
87
|
+
puts
|
88
|
+
puts "=== rake tasks ==="
|
89
|
+
Tap::Tasks::Rake.new.enq('-T')
|
90
|
+
Tap::App.instance.run
|
91
|
+
|
92
|
+
# this is not currently reached as rake exits on -T
|
93
|
+
puts
|
94
|
+
puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}"
|
95
|
+
exit
|
96
|
+
else
|
97
|
+
queues = env.build(ARGV) do |args|
|
98
|
+
warn "warning: implict rake for [#{args.join(' ')}]"
|
99
|
+
Tap::Tasks::Rake
|
100
|
+
end
|
101
|
+
ARGV.clear
|
102
|
+
|
103
|
+
if queues.empty?
|
104
|
+
puts "no task specified"
|
105
|
+
exit
|
106
|
+
end
|
107
|
+
|
108
|
+
env.set_signals
|
109
|
+
env.run(queues)
|
110
|
+
end
|
111
|
+
|
112
|
+
rescue
|
113
|
+
env.handle_error($!)
|
114
|
+
end
|
115
|
+
|
116
|
+
exit(0)
|
data/bin/tap
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
# usage: tap <command> {options} [args]
|
3
3
|
#
|
4
4
|
# examples:
|
@@ -6,19 +6,19 @@
|
|
6
6
|
# tap run taskname --option input # runs the 'taskname' task
|
7
7
|
#
|
8
8
|
# help:
|
9
|
-
# tap help
|
9
|
+
# tap --help # prints this help
|
10
10
|
# tap command --help # prints help for 'command'
|
11
11
|
#
|
12
12
|
|
13
13
|
require "#{File.dirname(__FILE__)}/../lib/tap.rb"
|
14
|
-
require 'tap/exe'
|
15
14
|
|
16
15
|
# setup the environment
|
17
16
|
begin
|
18
17
|
|
18
|
+
# handle super options
|
19
19
|
$DEBUG = true if ARGV.delete('-d-')
|
20
20
|
env = Tap::Exe.instantiate
|
21
|
-
|
21
|
+
|
22
22
|
rescue(Tap::Env::ConfigError)
|
23
23
|
# catch errors and exit gracefully
|
24
24
|
# (errors usu from gem loading errors)
|
@@ -58,11 +58,8 @@ end
|
|
58
58
|
|
59
59
|
begin
|
60
60
|
env.activate
|
61
|
-
env.
|
62
|
-
|
63
|
-
require 'tap/support/command_line'
|
64
|
-
|
65
|
-
puts Tap::Support::CommandLine.usage(__FILE__)
|
61
|
+
env.execute(ARGV) do
|
62
|
+
puts Tap::Support::Lazydoc.usage(__FILE__)
|
66
63
|
puts
|
67
64
|
puts "available commands:"
|
68
65
|
puts env.summarize(:commands)
|
data/cgi/run.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# ::summary
|
2
|
+
# runs a task
|
3
|
+
#
|
4
|
+
# ::description
|
5
|
+
#
|
6
|
+
############################
|
7
|
+
require 'cgi'
|
8
|
+
require "#{File.dirname(__FILE__)}/../vendor/url_encoded_pair_parser"
|
9
|
+
|
10
|
+
env = Tap::Env.instance
|
11
|
+
|
12
|
+
module Tap
|
13
|
+
module Support
|
14
|
+
module Server
|
15
|
+
module_function
|
16
|
+
|
17
|
+
def pair_parse(params)
|
18
|
+
pairs = {}
|
19
|
+
params.each_pair do |key, values|
|
20
|
+
key = key.chomp("%w") if key =~ /%w$/
|
21
|
+
|
22
|
+
slot = pairs[key] ||= []
|
23
|
+
values.each do |value|
|
24
|
+
value = value.respond_to?(:read) ? value.read : value
|
25
|
+
if $~
|
26
|
+
slot.concat(Shellwords.shellwords(value))
|
27
|
+
else
|
28
|
+
slot << value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
UrlEncodedPairParser.new(pairs).result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
cgi = CGI.new("html3") # add HTML generation methods
|
40
|
+
cgi.out() do
|
41
|
+
case cgi.request_method
|
42
|
+
when /GET/i
|
43
|
+
env.render('run.erb', :env => env, :tascs => [] )
|
44
|
+
|
45
|
+
when /POST/i
|
46
|
+
action = cgi.params['action'][0]
|
47
|
+
case action
|
48
|
+
when 'add'
|
49
|
+
index = cgi.params['index'][0].to_i - 1
|
50
|
+
cgi.params['selected_tasks'].collect do |task|
|
51
|
+
index += 1
|
52
|
+
tasc = env.tasks.search(task).constantize
|
53
|
+
env.render('run/task.erb', :tasc => tasc, :index => index )
|
54
|
+
end.join("\n")
|
55
|
+
|
56
|
+
when 'remove'
|
57
|
+
when 'update'
|
58
|
+
else
|
59
|
+
cgi.pre do
|
60
|
+
argh = Tap::Support::Server.pair_parse(cgi.params)
|
61
|
+
Tap::Support::Schema.parse(argh['schema']).dump.to_yaml
|
62
|
+
end
|
63
|
+
end
|
64
|
+
else
|
65
|
+
raise ArgumentError, "unhandled request method: #{cgi.request_method}"
|
66
|
+
end
|
67
|
+
end
|
data/cmd/console.rb
CHANGED
data/cmd/destroy.rb
CHANGED
@@ -3,14 +3,14 @@ require 'tap/generator/destroy'
|
|
3
3
|
|
4
4
|
env = Tap::Env.instance
|
5
5
|
|
6
|
-
if ARGV.empty? || ARGV == ['
|
7
|
-
puts env.summarize(:generators)
|
6
|
+
if ARGV.empty? || ARGV == ['--help']
|
7
|
+
puts env.summarize(:generators)
|
8
8
|
exit
|
9
9
|
end
|
10
10
|
|
11
11
|
name = ARGV.shift
|
12
|
-
const = env.search(
|
12
|
+
const = env.generators.search(name) or raise "unknown generator: #{name}"
|
13
13
|
|
14
14
|
generator_class = const.constantize
|
15
|
-
generator, argv = generator_class.
|
15
|
+
generator, argv = generator_class.parse(ARGV)
|
16
16
|
generator.extend(Tap::Generator::Destroy).process(*argv)
|
data/cmd/generate.rb
CHANGED
@@ -3,14 +3,14 @@ require 'tap/generator/generate'
|
|
3
3
|
|
4
4
|
env = Tap::Env.instance
|
5
5
|
|
6
|
-
if ARGV.empty? || ARGV == ['
|
7
|
-
puts env.summarize(:generators)
|
6
|
+
if ARGV.empty? || ARGV == ['--help']
|
7
|
+
puts env.summarize(:generators)
|
8
8
|
exit
|
9
9
|
end
|
10
10
|
|
11
11
|
name = ARGV.shift
|
12
|
-
const = env.search(
|
12
|
+
const = env.generators.search(name) or raise "unknown generator: #{name}"
|
13
13
|
|
14
14
|
generator_class = const.constantize
|
15
|
-
generator, argv = generator_class.
|
15
|
+
generator, argv = generator_class.parse(ARGV)
|
16
16
|
generator.extend(Tap::Generator::Generate).process(*argv)
|
data/cmd/manifest.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# tap manifest
|
2
2
|
#
|
3
|
-
# Prints information about
|
3
|
+
# Prints information about the current tap environment.
|
4
4
|
#
|
5
5
|
|
6
6
|
options = {}
|
@@ -10,85 +10,93 @@ OptionParser.new do |opts|
|
|
10
10
|
opts.separator "options:"
|
11
11
|
|
12
12
|
opts.on("-h", "--help", "Show this message") do
|
13
|
-
opts.banner =
|
13
|
+
opts.banner = Tap::Support::Lazydoc.usage(__FILE__)
|
14
14
|
puts opts
|
15
15
|
exit
|
16
16
|
end
|
17
17
|
|
18
|
-
opts.on("-
|
19
|
-
|
20
|
-
end
|
18
|
+
# opts.on("-t", "--tree", "Just print the env tree.") do
|
19
|
+
# options[:tree] = true
|
20
|
+
# end
|
21
21
|
|
22
|
-
opts.on("-r", "--require FILEPATH", "Require the specified file") do |value|
|
23
|
-
|
24
|
-
end
|
22
|
+
# opts.on("-r", "--require FILEPATH", "Require the specified file") do |value|
|
23
|
+
# require value
|
24
|
+
# end
|
25
25
|
|
26
26
|
end.parse!(ARGV)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
map = manifest.minimize.collect do |(key, path)|
|
33
|
-
path = case path
|
34
|
-
when Tap::Support::Constant then path.require_path
|
35
|
-
else path
|
36
|
-
end
|
37
|
-
|
38
|
-
width = key.length if width < key.length
|
39
|
-
[key, env.root.relative_filepath(:root, path) || path]
|
40
|
-
end.collect do |args|
|
41
|
-
"%-#{width}s (%s)" % args
|
42
|
-
end
|
43
|
-
|
44
|
-
map.unshift("") unless map.empty?
|
45
|
-
map
|
28
|
+
env = Tap::Env.instance
|
29
|
+
env_names = {}
|
30
|
+
env.manifest(:envs, true).minimize.each do |name, environment|
|
31
|
+
env_names[environment] = name
|
46
32
|
end
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
envs_manifest = if ARGV.empty?
|
51
|
-
env.manifest(:envs, true).minimize
|
34
|
+
filter = case
|
35
|
+
when ARGV.empty? then env_names.keys
|
52
36
|
else
|
53
37
|
ARGV.collect do |name|
|
54
|
-
entry = env.find(:envs, name, false)
|
55
|
-
|
56
|
-
|
38
|
+
unless entry = env.find(:envs, name, false)
|
39
|
+
raise "could not find an env matching: #{name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
entry[1]
|
57
43
|
end
|
58
44
|
end
|
59
45
|
|
60
|
-
|
61
|
-
|
62
|
-
|
46
|
+
template = %Q{#{'-' * 80}
|
47
|
+
<%= (env_name + ':').ljust(width) %> (<%= env.root.root %>)
|
48
|
+
<% manifests.each do |manifest_name, entries| %>
|
49
|
+
<%= manifest_name %>
|
50
|
+
<% entries.each do |name, path| %>
|
51
|
+
<%= name.ljust(width-4) %> (<%= path %>)
|
52
|
+
<% end %>
|
53
|
+
<% end %>
|
54
|
+
}
|
63
55
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
puts '-' * 80 unless options[:envs_only]
|
69
|
-
puts "%-#{width}s (%s)" % [env_name + ':', current.root.root]
|
70
|
-
|
71
|
-
next if options[:envs_only]
|
56
|
+
width = 10
|
57
|
+
summary = env.inspect(template) do |templater, share|
|
58
|
+
current = templater.env
|
59
|
+
next unless filter.include?(current)
|
72
60
|
|
73
61
|
manifest_keys = (Tap::Env.manifests.keys + current.manifests.keys).uniq
|
74
|
-
manifest_keys.
|
62
|
+
manifests = manifest_keys.collect do |name|
|
75
63
|
next if name == :envs
|
64
|
+
|
76
65
|
manifest = current.manifest(name, true)
|
77
66
|
next if manifest.empty?
|
78
67
|
|
79
|
-
|
68
|
+
entries = manifest.minimize.collect do |(entry, path)|
|
69
|
+
path = case path
|
70
|
+
when Tap::Support::Constant then path.require_path
|
71
|
+
else path
|
72
|
+
end
|
73
|
+
|
74
|
+
width = entry.length if width < entry.length
|
75
|
+
[entry, current.root.relative_filepath(:root, path) || path]
|
76
|
+
end
|
77
|
+
|
78
|
+
[name, entries]
|
80
79
|
end
|
80
|
+
templater.manifests = manifests.compact
|
81
|
+
templater.env_name = env_names[current]
|
82
|
+
|
83
|
+
width = templater.env_name.length if width < templater.env_name.length
|
84
|
+
share[:width] = width + 2
|
81
85
|
end
|
86
|
+
puts summary
|
82
87
|
|
83
88
|
if ARGV.empty?
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
puts("#{leader}#{env_name}")
|
89
|
+
tree = env.recursive_inspect("<%= leader %><%= env_name %> \n", 0, nil) do |templater, share, nesting_depth, last|
|
90
|
+
current = templater.env
|
91
|
+
|
92
|
+
templater.leader = nesting_depth == 0 ? "" : '| ' * (nesting_depth - 1) + (last == current ? "`- " : "|- ")
|
93
|
+
templater.env_name = env_names[current]
|
94
|
+
|
91
95
|
[nesting_depth + 1, current.envs[-1]]
|
92
96
|
end
|
97
|
+
|
98
|
+
puts '-' * 80
|
99
|
+
puts
|
100
|
+
puts tree
|
93
101
|
puts
|
94
102
|
end
|
data/cmd/run.rb
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
|
8
8
|
env = Tap::Env.instance
|
9
9
|
app = Tap::App.instance
|
10
|
-
cmdline = Tap::Support::CommandLine
|
11
10
|
|
12
11
|
#
|
13
12
|
# handle options
|
@@ -15,14 +14,13 @@ cmdline = Tap::Support::CommandLine
|
|
15
14
|
|
16
15
|
dump = false
|
17
16
|
OptionParser.new do |opts|
|
18
|
-
|
19
17
|
opts.separator ""
|
20
18
|
opts.separator "configurations:"
|
21
19
|
|
22
20
|
Tap::App.configurations.each do |receiver, key, config|
|
23
21
|
next if receiver == Tap::Root
|
24
22
|
|
25
|
-
opts.on(*
|
23
|
+
opts.on(*config.to_optparse_argv) do |value|
|
26
24
|
app.send(config.writer, value)
|
27
25
|
end
|
28
26
|
end
|
@@ -31,96 +29,31 @@ OptionParser.new do |opts|
|
|
31
29
|
opts.separator "options:"
|
32
30
|
|
33
31
|
opts.on("-h", "--help", "Show this message") do
|
34
|
-
opts.banner =
|
32
|
+
opts.banner = Tap::Support::Lazydoc.usage(__FILE__)
|
35
33
|
Tap::App.lazydoc.resolve
|
36
34
|
puts opts
|
37
35
|
exit
|
38
36
|
end
|
39
37
|
|
40
38
|
opts.on('-T', '--manifest', 'Print a list of available tasks') do |v|
|
41
|
-
puts env.summarize(:tasks)
|
39
|
+
puts env.summarize(:tasks)
|
42
40
|
exit
|
43
41
|
end
|
44
42
|
|
45
43
|
end.parse!(ARGV)
|
46
44
|
|
47
45
|
#
|
48
|
-
#
|
46
|
+
# build and run the argv
|
49
47
|
#
|
50
48
|
|
51
|
-
|
52
|
-
argvs.each do |argv|
|
53
|
-
ARGV.clear
|
54
|
-
ARGV.concat(argv)
|
55
|
-
|
56
|
-
unless td = cmdline.shift(ARGV)
|
57
|
-
# warn nil?
|
58
|
-
next
|
59
|
-
end
|
60
|
-
|
61
|
-
# attempt lookup the task class
|
62
|
-
const = env.search(:tasks, td) or raise "unknown task: #{td}"
|
63
|
-
task_class = const.constantize or raise "unknown task: #{td}"
|
64
|
-
|
65
|
-
# now let the class handle the argv
|
66
|
-
task, argv = task_class.instantiate(ARGV, app)
|
67
|
-
task.enq *argv.collect! {|str| cmdline.parse_yaml(str) }
|
68
|
-
end
|
69
|
-
|
70
|
-
app.queue.clear
|
71
|
-
end
|
49
|
+
queues = env.build(ARGV)
|
72
50
|
ARGV.clear
|
73
51
|
|
74
|
-
|
75
|
-
if rounds.empty?
|
52
|
+
if queues.empty?
|
76
53
|
puts "no task specified"
|
77
54
|
exit
|
78
55
|
end
|
79
56
|
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
# info signal -- Note: some systems do
|
85
|
-
# not support the INFO signal
|
86
|
-
# (windows, fedora, at least)
|
87
|
-
signals = Signal.list.keys
|
88
|
-
if signals.include?("INFO")
|
89
|
-
Signal.trap("INFO") do
|
90
|
-
puts app.info
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# interuption signal
|
95
|
-
if signals.include?("INT")
|
96
|
-
Signal.trap("INT") do
|
97
|
-
puts " interrupted!"
|
98
|
-
# prompt for decision
|
99
|
-
while true
|
100
|
-
print "stop, terminate, exit, or resume? (s/t/e/r):"
|
101
|
-
case gets.strip
|
102
|
-
when /s(top)?/i
|
103
|
-
app.stop
|
104
|
-
break
|
105
|
-
when /t(erminate)?/i
|
106
|
-
app.terminate
|
107
|
-
break
|
108
|
-
when /e(xit)?/i
|
109
|
-
exit
|
110
|
-
when /r(esume)?/i
|
111
|
-
break
|
112
|
-
else
|
113
|
-
puts "unexpected response..."
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# enque tasks and run!
|
121
|
-
#
|
57
|
+
env.set_signals
|
58
|
+
env.run(queues)
|
122
59
|
|
123
|
-
rounds.each_with_index do |queue, i|
|
124
|
-
app.queue.concat(queue)
|
125
|
-
app.run
|
126
|
-
end
|