bahuvrihi-tap 0.10.3 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tap +1 -1
- data/cgi/run.rb +43 -22
- data/cmd/run.rb +3 -6
- data/cmd/server.rb +4 -0
- data/doc/Class Reference +1 -10
- data/lib/tap.rb +1 -3
- data/lib/tap/app.rb +172 -341
- data/lib/tap/constants.rb +1 -1
- data/lib/tap/exe.rb +48 -3
- data/lib/tap/generator/base.rb +4 -0
- data/lib/tap/generator/destroy.rb +6 -2
- data/lib/tap/generator/generate.rb +22 -16
- data/lib/tap/generator/generators/root/root_generator.rb +3 -3
- data/lib/tap/parser.rb +435 -0
- data/lib/tap/support/combinator.rb +73 -0
- data/lib/tap/support/declarations.rb +15 -11
- data/lib/tap/support/dependable.rb +73 -0
- data/lib/tap/support/executable.rb +16 -62
- data/lib/tap/support/gems/rack.rb +33 -19
- data/lib/tap/support/parsers/server.rb +39 -9
- data/lib/tap/support/templater.rb +1 -1
- data/lib/tap/task.rb +46 -6
- data/lib/tap/test/tap_methods.rb +1 -0
- data/template/index.erb +2 -1
- metadata +4 -3
- data/lib/tap/support/parsers/command_line.rb +0 -90
- data/lib/tap/support/run_error.rb +0 -39
@@ -65,7 +65,7 @@ module Tap
|
|
65
65
|
# {'key' => 'value'}.to_yaml # => "--- \nkey: value\n"
|
66
66
|
# yamlize {'key' => 'value'} # => "key: value"
|
67
67
|
def yamlize(object)
|
68
|
-
|
68
|
+
object == nil ? "~" : object.to_yaml[4...-1].strip
|
69
69
|
end
|
70
70
|
|
71
71
|
# Nest the return of the block in the nesting lines.
|
data/lib/tap/task.rb
CHANGED
@@ -179,6 +179,8 @@ module Tap
|
|
179
179
|
super
|
180
180
|
end
|
181
181
|
|
182
|
+
# Returns an instance of self; the instance is a kind of 'global'
|
183
|
+
# instance used in class-level dependencies. See depends_on.
|
182
184
|
def instance
|
183
185
|
@instance ||= new
|
184
186
|
end
|
@@ -216,8 +218,7 @@ module Tap
|
|
216
218
|
#
|
217
219
|
# Register documentation
|
218
220
|
#
|
219
|
-
|
220
|
-
const_name = current == Object ? subclass_const : "#{current}::#{subclass_const}"
|
221
|
+
const_name = subclass.to_s
|
221
222
|
caller.each_with_index do |line, index|
|
222
223
|
case line
|
223
224
|
when /\/tap\/support\/declarations.rb/ then next
|
@@ -334,6 +335,9 @@ module Tap
|
|
334
335
|
Tap::Support::Templater.new(DEFAULT_HELP_TEMPLATE, :task_class => self).build
|
335
336
|
end
|
336
337
|
|
338
|
+
# Sets a class-level dependency. When task class B depends_on another task
|
339
|
+
# class A, instances of B are initialized to depend on A.instance, with the
|
340
|
+
# specified arguments. Returns self.
|
337
341
|
def depends_on(dependency_class, *args)
|
338
342
|
unless dependency_class.respond_to?(:instance)
|
339
343
|
raise ArgumentError, "dependency_class does not respond to instance: #{dependency_class}"
|
@@ -349,6 +353,7 @@ module Tap
|
|
349
353
|
|
350
354
|
define_method(name) do
|
351
355
|
index = Support::Executable.index(dependency_class.instance, args)
|
356
|
+
Support::Executable.resolve([index])
|
352
357
|
Support::Executable.results[index]._current
|
353
358
|
end
|
354
359
|
|
@@ -394,8 +399,8 @@ module Tap
|
|
394
399
|
end
|
395
400
|
|
396
401
|
def define_dependencies(dependencies)
|
397
|
-
dependencies.each do |name, dependency_class,
|
398
|
-
dependency(name, dependency_class, *args)
|
402
|
+
dependencies.each do |name, dependency_class, args|
|
403
|
+
dependency(name, dependency_class, *(args ? args : []))
|
399
404
|
end if dependencies
|
400
405
|
end
|
401
406
|
|
@@ -435,7 +440,6 @@ module Tap
|
|
435
440
|
@task_block = (task_block == nil ? default_task_block : task_block)
|
436
441
|
|
437
442
|
@_method_name = :execute
|
438
|
-
@multithread = false
|
439
443
|
@on_complete_block = nil
|
440
444
|
@dependencies = []
|
441
445
|
|
@@ -468,9 +472,39 @@ module Tap
|
|
468
472
|
app.queue.enq(self, inputs)
|
469
473
|
end
|
470
474
|
|
471
|
-
batch_function :enq
|
475
|
+
batch_function :enq
|
472
476
|
batch_function(:on_complete) {}
|
473
477
|
|
478
|
+
# Convenience method, equivalent to:
|
479
|
+
# self.app.sequence([self] + tasks)
|
480
|
+
def sequence(*tasks)
|
481
|
+
app.sequence([self] + tasks)
|
482
|
+
end
|
483
|
+
|
484
|
+
# Convenience method, equivalent to:
|
485
|
+
# self.app.fork(self, targets)
|
486
|
+
def fork(*targets)
|
487
|
+
app.fork(self, targets)
|
488
|
+
end
|
489
|
+
|
490
|
+
# Convenience method, equivalent to:
|
491
|
+
# self.app.merge(self, sources)
|
492
|
+
def merge(*sources)
|
493
|
+
app.merge(self, sources)
|
494
|
+
end
|
495
|
+
|
496
|
+
# Convenience method, equivalent to:
|
497
|
+
# self.app.sync_merge(self, sources)
|
498
|
+
def sync_merge(*sources)
|
499
|
+
app.sync_merge(self, sources)
|
500
|
+
end
|
501
|
+
|
502
|
+
# Convenience method, equivalent to:
|
503
|
+
# self.app.switch(self, targets, &block)
|
504
|
+
def switch(*targets, &block)
|
505
|
+
app.switch(self, targets, &block)
|
506
|
+
end
|
507
|
+
|
474
508
|
# Executes self with the given inputs. Execute provides hooks for subclasses
|
475
509
|
# to insert standard execution code: before_execute, on_execute_error,
|
476
510
|
# and after_execute. Override any/all of these methods as needed.
|
@@ -549,6 +583,12 @@ module Tap
|
|
549
583
|
name.to_s
|
550
584
|
end
|
551
585
|
|
586
|
+
# Provides an abbreviated version of the default inspect, with only
|
587
|
+
# the task class, object_id, name, and configurations listed.
|
588
|
+
def inspect
|
589
|
+
"#<#{self.class.to_s}:#{object_id} #{name} #{config.to_hash.inspect} >"
|
590
|
+
end
|
591
|
+
|
552
592
|
protected
|
553
593
|
|
554
594
|
# Hook to set a default task block. By default, nil.
|
data/lib/tap/test/tap_methods.rb
CHANGED
@@ -148,6 +148,7 @@ module Tap
|
|
148
148
|
expected.each_with_index do |exp_record, i|
|
149
149
|
case exp_record
|
150
150
|
when ExpMerge
|
151
|
+
flunk "empty merge #{(nesting + [i]).join(':')}" if exp_record.empty?
|
151
152
|
exp_record.each_with_index do |exp_audit, j|
|
152
153
|
assert_audit_records_equal(exp_audit, actual[i][j], nesting + [i,j])
|
153
154
|
end
|
data/template/index.erb
CHANGED
@@ -28,7 +28,8 @@
|
|
28
28
|
<% task_manifest.each do |(task_key, const)|
|
29
29
|
lazydoc = Tap::Support::Lazydoc[const.require_path]
|
30
30
|
lazydoc.resolve
|
31
|
-
summary = lazydoc[const.name]['manifest']
|
31
|
+
summary = lazydoc[const.name]['manifest']
|
32
|
+
summary = summary.subject if summary.kind_of?(Tap::Support::Comment)
|
32
33
|
%>
|
33
34
|
<li><a href="run?task=<%= task_key %>"><%= const.name %></a> <%= summary %></li>
|
34
35
|
<% end %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bahuvrihi-tap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Chiang
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/tap/generator/generators/task/templates/task.erb
|
71
71
|
- lib/tap/generator/generators/task/templates/test.erb
|
72
72
|
- lib/tap/generator/manifest.rb
|
73
|
+
- lib/tap/parser.rb
|
73
74
|
- lib/tap/patches/rake/rake_test_loader.rb
|
74
75
|
- lib/tap/patches/rake/testtask.rb
|
75
76
|
- lib/tap/patches/ruby19/backtrace_filter.rb
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- lib/tap/support/batchable.rb
|
87
88
|
- lib/tap/support/batchable_class.rb
|
88
89
|
- lib/tap/support/class_configuration.rb
|
90
|
+
- lib/tap/support/combinator.rb
|
89
91
|
- lib/tap/support/command_line.rb
|
90
92
|
- lib/tap/support/comment.rb
|
91
93
|
- lib/tap/support/configurable.rb
|
@@ -94,6 +96,7 @@ files:
|
|
94
96
|
- lib/tap/support/constant.rb
|
95
97
|
- lib/tap/support/constant_utils.rb
|
96
98
|
- lib/tap/support/declarations.rb
|
99
|
+
- lib/tap/support/dependable.rb
|
97
100
|
- lib/tap/support/executable.rb
|
98
101
|
- lib/tap/support/executable_queue.rb
|
99
102
|
- lib/tap/support/gems/rake.rb
|
@@ -104,9 +107,7 @@ files:
|
|
104
107
|
- lib/tap/support/lazydoc.rb
|
105
108
|
- lib/tap/support/manifest.rb
|
106
109
|
- lib/tap/support/parsers/base.rb
|
107
|
-
- lib/tap/support/parsers/command_line.rb
|
108
110
|
- lib/tap/support/parsers/server.rb
|
109
|
-
- lib/tap/support/run_error.rb
|
110
111
|
- lib/tap/support/shell_utils.rb
|
111
112
|
- lib/tap/support/tdoc.rb
|
112
113
|
- lib/tap/support/tdoc/tdoc_html_generator.rb
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'tap/support/parsers/base'
|
2
|
-
|
3
|
-
module Tap
|
4
|
-
module Support
|
5
|
-
module Parsers
|
6
|
-
class CommandLine < Base
|
7
|
-
class << self
|
8
|
-
def parse_sequence(str, count=0)
|
9
|
-
seq = []
|
10
|
-
seq << count if str[0] == ?:
|
11
|
-
str.split(/:+/).each do |n|
|
12
|
-
seq << n.to_i unless n.empty?
|
13
|
-
end
|
14
|
-
seq << count + 1 if str[-1] == ?:
|
15
|
-
[seq.shift, seq]
|
16
|
-
end
|
17
|
-
|
18
|
-
def pairs_regexp(l, r)
|
19
|
-
/\A--(\d*)#{Regexp.escape(l)}([\d,]*)#{Regexp.escape(r)}\z/
|
20
|
-
end
|
21
|
-
|
22
|
-
def parse_pairs(lead, str, count=0)
|
23
|
-
bracket = []
|
24
|
-
str.split(/,+/).each do |n|
|
25
|
-
bracket << n.to_i unless n.empty?
|
26
|
-
end
|
27
|
-
|
28
|
-
[lead.empty? ? count : lead.to_i, bracket]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
ROUND = /\A--(\+(\d+)|\+*)\z/
|
33
|
-
SEQUENCE = /\A--(\d*(:\d*)+)\z/
|
34
|
-
FORK = pairs_regexp("[", "]")
|
35
|
-
MERGE = pairs_regexp("{", "}")
|
36
|
-
SYNC_MERGE = pairs_regexp("(", ")")
|
37
|
-
INVALID = /\A--(\z|[^A-Za-z])/
|
38
|
-
|
39
|
-
def initialize(argv)
|
40
|
-
@sequences = []
|
41
|
-
@forks = []
|
42
|
-
@merges = []
|
43
|
-
@sync_merges = []
|
44
|
-
|
45
|
-
current = []
|
46
|
-
current_round = []
|
47
|
-
@argvs = []
|
48
|
-
@rounds = [current_round]
|
49
|
-
|
50
|
-
argv.each do |arg|
|
51
|
-
unless arg =~ INVALID
|
52
|
-
current << arg
|
53
|
-
next
|
54
|
-
end
|
55
|
-
|
56
|
-
# for peformance split to match
|
57
|
-
# most arguments just once.
|
58
|
-
unless current.empty?
|
59
|
-
current_round << @argvs.length
|
60
|
-
@argvs << current
|
61
|
-
current = []
|
62
|
-
end
|
63
|
-
|
64
|
-
case arg
|
65
|
-
when ROUND
|
66
|
-
current_round = (@rounds[$2 ? $2.to_i : $1.length] ||= [])
|
67
|
-
when SEQUENCE
|
68
|
-
@sequences << CommandLine.parse_sequence($1, @argvs.length-1)
|
69
|
-
when FORK
|
70
|
-
@forks << CommandLine.parse_pairs($1, $2, @argvs.length-1)
|
71
|
-
when MERGE
|
72
|
-
@merges << CommandLine.parse_pairs($1, $2, @argvs.length-1)
|
73
|
-
when SYNC_MERGE
|
74
|
-
@sync_merges << CommandLine.parse_pairs($1, $2, @argvs.length-1)
|
75
|
-
else
|
76
|
-
raise ArgumentError, "invalid argument: #{arg}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
unless current.empty?
|
81
|
-
current_round << @argvs.length
|
82
|
-
@argvs << current
|
83
|
-
end
|
84
|
-
@rounds.delete_if {|round| round.nil? || round.empty? }
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Tap
|
2
|
-
module Support
|
3
|
-
# Raised when an exception is raised during App#run. All errors generated during
|
4
|
-
# termination are collected into the RunError.
|
5
|
-
class RunError < RuntimeError
|
6
|
-
attr_reader :errors
|
7
|
-
|
8
|
-
def initialize(errors)
|
9
|
-
@errors = errors
|
10
|
-
@backtrace = nil
|
11
|
-
end
|
12
|
-
|
13
|
-
#The join of all the error messages.
|
14
|
-
def message
|
15
|
-
lines = []
|
16
|
-
errors.each_with_index do |error, i|
|
17
|
-
lines << "\nRunError [#{i}] #{error.class} #{error.message}"
|
18
|
-
end
|
19
|
-
lines.join + "\n"
|
20
|
-
end
|
21
|
-
|
22
|
-
#The join of all the error backtraces.
|
23
|
-
def backtrace
|
24
|
-
# backtrace gets called every time RunError is re-raised, leading to multiple
|
25
|
-
# repeats of the error backtraces. This ensures the additional backtrace
|
26
|
-
# information is only added once.
|
27
|
-
return @backtrace unless @backtrace == nil
|
28
|
-
return nil unless @backtrace = super
|
29
|
-
|
30
|
-
errors.each_with_index do |error, i|
|
31
|
-
@backtrace [-1] += "\n\n---------------------- RunError [#{i}] ----------------------\n#{error.class} #{error.message}"
|
32
|
-
@backtrace.concat(error.backtrace || ["missing backtrace"])
|
33
|
-
end
|
34
|
-
@backtrace
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|