tap 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/History +35 -1
  2. data/MIT-LICENSE +1 -1
  3. data/README +16 -15
  4. data/bin/tap +1 -1
  5. data/cmd/console.rb +4 -3
  6. data/cmd/manifest.rb +2 -2
  7. data/cmd/run.rb +12 -15
  8. data/doc/Class Reference +120 -117
  9. data/doc/Command Reference +27 -27
  10. data/doc/Syntax Reference +55 -111
  11. data/doc/Tutorial +69 -26
  12. data/lib/tap.rb +3 -8
  13. data/lib/tap/app.rb +122 -146
  14. data/lib/tap/constants.rb +2 -2
  15. data/lib/tap/env.rb +178 -252
  16. data/lib/tap/exe.rb +67 -30
  17. data/lib/tap/file_task.rb +224 -411
  18. data/lib/tap/generator/arguments.rb +13 -0
  19. data/lib/tap/generator/base.rb +112 -30
  20. data/lib/tap/generator/destroy.rb +36 -13
  21. data/lib/tap/generator/generate.rb +69 -48
  22. data/lib/tap/generator/generators/command/templates/command.erb +3 -3
  23. data/lib/tap/generator/generators/config/config_generator.rb +82 -10
  24. data/lib/tap/generator/generators/generator/generator_generator.rb +16 -6
  25. data/lib/tap/generator/generators/generator/templates/task.erb +2 -2
  26. data/lib/tap/generator/generators/generator/templates/test.erb +26 -0
  27. data/lib/tap/generator/generators/root/root_generator.rb +24 -13
  28. data/lib/tap/generator/generators/root/templates/Rakefile +4 -4
  29. data/lib/tap/generator/generators/root/templates/{tapfile → Rapfile} +6 -6
  30. data/lib/tap/generator/generators/root/templates/gemspec +0 -1
  31. data/lib/tap/generator/generators/task/task_generator.rb +3 -3
  32. data/lib/tap/generator/generators/task/templates/test.erb +1 -1
  33. data/lib/tap/generator/manifest.rb +7 -1
  34. data/lib/tap/generator/preview.rb +76 -0
  35. data/lib/tap/root.rb +222 -156
  36. data/lib/tap/spec.rb +41 -0
  37. data/lib/tap/support/aggregator.rb +25 -28
  38. data/lib/tap/support/audit.rb +278 -357
  39. data/lib/tap/support/constant.rb +2 -1
  40. data/lib/tap/support/constant_manifest.rb +28 -25
  41. data/lib/tap/support/dependency.rb +1 -1
  42. data/lib/tap/support/executable.rb +52 -183
  43. data/lib/tap/support/executable_queue.rb +50 -20
  44. data/lib/tap/support/gems.rb +1 -1
  45. data/lib/tap/support/intern.rb +0 -6
  46. data/lib/tap/support/join.rb +49 -83
  47. data/lib/tap/support/joins.rb +0 -3
  48. data/lib/tap/support/joins/switch.rb +13 -11
  49. data/lib/tap/support/joins/sync_merge.rb +25 -50
  50. data/lib/tap/support/manifest.rb +1 -0
  51. data/lib/tap/support/node.rb +140 -20
  52. data/lib/tap/support/parser.rb +56 -42
  53. data/lib/tap/support/schema.rb +183 -157
  54. data/lib/tap/support/templater.rb +9 -1
  55. data/lib/tap/support/versions.rb +39 -0
  56. data/lib/tap/task.rb +150 -177
  57. data/lib/tap/tasks/dump.rb +4 -4
  58. data/lib/tap/tasks/load.rb +29 -29
  59. data/lib/tap/test.rb +66 -53
  60. data/lib/tap/test/env_vars.rb +3 -3
  61. data/lib/tap/test/extensions.rb +11 -17
  62. data/lib/tap/test/file_test.rb +74 -132
  63. data/lib/tap/test/file_test_class.rb +4 -1
  64. data/lib/tap/test/regexp_escape.rb +2 -2
  65. data/lib/tap/test/script_test.rb +2 -2
  66. data/lib/tap/test/subset_test.rb +6 -6
  67. data/lib/tap/test/tap_test.rb +28 -154
  68. metadata +30 -51
  69. data/bin/rap +0 -118
  70. data/cgi/run.rb +0 -97
  71. data/lib/tap/declarations.rb +0 -229
  72. data/lib/tap/generator/generators/config/templates/doc.erb +0 -12
  73. data/lib/tap/generator/generators/config/templates/nodoc.erb +0 -8
  74. data/lib/tap/generator/generators/file_task/file_task_generator.rb +0 -27
  75. data/lib/tap/generator/generators/file_task/templates/file.txt +0 -11
  76. data/lib/tap/generator/generators/file_task/templates/result.yml +0 -6
  77. data/lib/tap/generator/generators/file_task/templates/task.erb +0 -33
  78. data/lib/tap/generator/generators/file_task/templates/test.erb +0 -29
  79. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +0 -5
  80. data/lib/tap/patches/optparse/summarize.rb +0 -62
  81. data/lib/tap/support/assignments.rb +0 -173
  82. data/lib/tap/support/class_configuration.rb +0 -182
  83. data/lib/tap/support/combinator.rb +0 -125
  84. data/lib/tap/support/configurable.rb +0 -113
  85. data/lib/tap/support/configurable_class.rb +0 -271
  86. data/lib/tap/support/configuration.rb +0 -170
  87. data/lib/tap/support/gems/rake.rb +0 -111
  88. data/lib/tap/support/instance_configuration.rb +0 -173
  89. data/lib/tap/support/joins/fork.rb +0 -19
  90. data/lib/tap/support/joins/merge.rb +0 -22
  91. data/lib/tap/support/joins/sequence.rb +0 -21
  92. data/lib/tap/support/lazy_attributes.rb +0 -45
  93. data/lib/tap/support/lazydoc.rb +0 -386
  94. data/lib/tap/support/lazydoc/comment.rb +0 -503
  95. data/lib/tap/support/lazydoc/config.rb +0 -17
  96. data/lib/tap/support/lazydoc/definition.rb +0 -36
  97. data/lib/tap/support/lazydoc/document.rb +0 -152
  98. data/lib/tap/support/lazydoc/method.rb +0 -24
  99. data/lib/tap/support/tdoc.rb +0 -409
  100. data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -38
  101. data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -42
  102. data/lib/tap/support/validation.rb +0 -479
  103. data/lib/tap/tasks/rake.rb +0 -57
data/bin/rap DELETED
@@ -1,118 +0,0 @@
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
- Dir.glob('[TtRr]apfile{,.rb}').each do |task_file|
16
- task_file = File.expand_path(task_file)
17
- next unless File.file?(task_file)
18
-
19
- env.loads.unshift(task_file)
20
- end
21
-
22
- rescue(Tap::Env::ConfigError)
23
- # catch errors and exit gracefully
24
- # (errors usu from gem loading errors)
25
- puts $!.message
26
- exit(1)
27
- end
28
-
29
- #
30
- # setup after script
31
- #
32
-
33
- at_exit do
34
- begin
35
- eval(env.after) if env.after != nil
36
- rescue(Exception)
37
- puts "Error in after script."
38
- env.handle_error($!)
39
- exit(1)
40
- end
41
- end
42
-
43
- #
44
- # run before script
45
- #
46
-
47
- begin
48
- eval(env.before) if env.before != nil
49
- rescue(Exception)
50
- puts "Error in before script."
51
- env.handle_error($!)
52
- exit(1)
53
- end
54
-
55
- #
56
- # run rap
57
- #
58
-
59
- module Tap
60
- module Tasks
61
- autoload(:Rake, 'tap/tasks/rake')
62
- end
63
- end
64
-
65
- begin
66
- env.activate
67
-
68
- case ARGV[0]
69
- when '--help', nil, '-T'
70
- rap_template = %Q{<% if count > 1 && !entries.empty? %>
71
- <%= env_name %>:
72
- <% end %>
73
- <% entries.each do |name, const| %>
74
- <% desc = if const.require_path == nil # should be a declaration %>
75
- <% manifest = const.constantize.manifest %>
76
- <% next if manifest == nil || manifest.subject.to_s.empty? %>
77
- <% manifest %>
78
- <% else %>
79
- <% const.document[const.name]['manifest'] %>
80
- <% end %>
81
- <% desc = desc.subject.to_s if desc.kind_of?(Tap::Support::Lazydoc::Comment) %>
82
- <%= name.ljust(width) %><%= desc.empty? ? '' : ' # ' %><%= desc %>
83
- <% end %>}
84
-
85
- puts Tap::Support::Lazydoc.usage(__FILE__)
86
- puts
87
- puts "=== tap tasks ==="
88
- puts env.summarize(:tasks, rap_template)
89
- puts
90
- puts "=== rake tasks ==="
91
- Tap::Tasks::Rake.new.enq('-T')
92
- Tap::App.instance.run
93
-
94
- # this is not currently reached as rake exits on -T
95
- puts
96
- puts "version #{Tap::VERSION} -- #{Tap::WEBSITE}"
97
- exit
98
- else
99
- queues = env.build(ARGV) do |args|
100
- warn "warning: implict rake for [#{args.join(' ')}]"
101
- Tap::Tasks::Rake
102
- end
103
- ARGV.clear
104
-
105
- if queues.empty?
106
- puts "no task specified"
107
- exit
108
- end
109
-
110
- env.set_signals
111
- env.run(queues)
112
- end
113
-
114
- rescue
115
- env.handle_error($!)
116
- end
117
-
118
- exit(0)
data/cgi/run.rb DELETED
@@ -1,97 +0,0 @@
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 parse_schema(params)
18
- argh = pair_parse(params)
19
-
20
- parser = Parser.new
21
- parser.parse(argh['nodes'] || [])
22
- parser.parse(argh['joins'] || [])
23
- parser.schema
24
- end
25
-
26
- def pair_parse(params)
27
- pairs = {}
28
- params.each_pair do |key, values|
29
- next if key == nil
30
- key = key.chomp("%w") if key =~ /%w$/
31
-
32
- slot = pairs[key] ||= []
33
- values.each do |value|
34
- value = value.respond_to?(:read) ? value.read : value
35
- if $~
36
- slot.concat(Shellwords.shellwords(value))
37
- else
38
- slot << value
39
- end
40
- end
41
- end
42
-
43
- UrlEncodedPairParser.new(pairs).result
44
- end
45
- end
46
- end
47
- end
48
-
49
- cgi = CGI.new("html3") # add HTML generation methods
50
- cgi.out() do
51
- case cgi.request_method
52
- when /GET/i
53
- schema = Tap::Support::Server.parse_schema(cgi.params).compact
54
- env.render('run.erb', :env => env, :schema => schema)
55
-
56
- when /POST/i
57
- action = cgi.params['action'][0]
58
- case action
59
- when 'add'
60
- index = cgi.params['index'][0].to_i - 1
61
- sources = cgi.params['sources'].flatten.collect {|source| source.to_i }
62
- targets = cgi.params['targets'].flatten.collect {|target| target.to_i }
63
-
64
- lines = []
65
- cgi.params['tasc'].select do |name|
66
- name && !name.empty?
67
- end.each do |name|
68
- index += 1
69
- targets << index
70
- lines << env.render('run/node.erb', :env => env, :node => Tap::Support::Node.new([name]), :index => index )
71
- end
72
-
73
- join = case
74
- when sources.length > 1 && targets.length == 1
75
- Tap::Support::Schema::Utils.format_merge(sources, targets, {})
76
- when sources.length == 1 && targets.length > 0
77
- Tap::Support::Schema::Utils.format_fork(sources, targets, {})
78
- else nil
79
- end
80
-
81
- lines << env.render('run/join.erb', :env => env, :join => join) if join
82
- lines.join("\n")
83
-
84
- when 'remove'
85
-
86
- else
87
- # run
88
- cgi.pre do
89
- schema = Tap::Support::Server.parse_schema(cgi.params)
90
- schema.compact.dump.to_yaml
91
- #env.build(schema)
92
- end
93
- end
94
- else
95
- raise ArgumentError, "unhandled request method: #{cgi.request_method}"
96
- end
97
- end
@@ -1,229 +0,0 @@
1
- require File.dirname(__FILE__) + "/../tap"
2
- autoload(:OpenStruct, 'ostruct')
3
-
4
- module Tap
5
- #--
6
- # more thought needs to go into extending Tap with Declarations
7
- # and there should be some discussion on why include works at
8
- # the top level (for main/Object) while extend should be used
9
- # in all other cases.
10
- module Declarations
11
- Lazydoc = Tap::Support::Lazydoc
12
- include Tap::Support::ShellUtils
13
-
14
- module Lazydoc
15
- class Declaration < Comment
16
- attr_accessor :desc
17
-
18
- def resolve(lines)
19
- super
20
-
21
- @subject = case
22
- when content.empty? || content[0][0].to_s !~ /^::desc(.*)/
23
- desc.to_s
24
- else
25
- content[0].shift
26
- $1.strip
27
- end
28
-
29
- self
30
- end
31
- end
32
- end
33
-
34
- module Rakish
35
- def new(*args)
36
- @instance ||= super
37
- @instance.app.dependencies.register(@instance)
38
- @instance
39
- end
40
- end
41
-
42
- def self.extended(base)
43
- declaration_base = base.to_s
44
- case declaration_base
45
- when "Object", "Tap", "main"
46
- declaration_base = ""
47
- end
48
-
49
- base.instance_variable_set(:@declaration_base, declaration_base.underscore)
50
- base.instance_variable_set(:@current_desc, nil)
51
- end
52
-
53
- def self.env
54
- @env ||= Tap::Env.instance_for(Dir.pwd)
55
- end
56
-
57
- def declaration_env
58
- @declaration_env ||= Declarations.env
59
- end
60
-
61
- attr_writer :declaration_base
62
-
63
- def declaration_base
64
- @declaration_base ||= ''
65
- end
66
-
67
- attr_writer :current_desc
68
-
69
- def current_desc
70
- @current_desc ||= nil
71
- end
72
-
73
- def task(*args, &block)
74
- const_name, configs, dependencies, arg_names = resolve_args(args)
75
- task_class = declare(const_name, configs, dependencies) do |*inputs|
76
- # collect inputs to make a rakish-args object
77
- args = {}
78
- arg_names.each do |arg_name|
79
- break if inputs.empty?
80
- args[arg_name] = inputs.shift
81
- end
82
- args = OpenStruct.new(args)
83
-
84
- # execute each block assciated with this task
85
- self.class::BLOCKS.each do |task_block|
86
- case task_block.arity
87
- when 0 then task_block.call()
88
- when 1 then task_block.call(self)
89
- else task_block.call(self, args)
90
- end
91
- end
92
-
93
- nil
94
- end
95
- register_doc(task_class, arg_names)
96
-
97
- # add the block to the task
98
- unless task_class.const_defined?(:BLOCKS)
99
- task_class.const_set(:BLOCKS, [])
100
- end
101
- task_class::BLOCKS << block unless block == nil
102
- task_class.instance
103
- end
104
-
105
- def namespace(name, &block)
106
- current_base = declaration_base
107
- @declaration_base = File.join(current_base, name.to_s.underscore)
108
- yield
109
- @declaration_base = current_base
110
- end
111
-
112
- def desc(str)
113
- self.current_desc = str
114
- end
115
-
116
- protected
117
-
118
- # Resolve the arguments for a task/rule. Returns an array of
119
- # [task_name, configs, needs, arg_names].
120
- #
121
- # Adapted from Rake 0.8.3
122
- # Changes:
123
- # - no :needs support for the trailing Hash (which is now config)
124
- def resolve_args(args)
125
- task_name = args.shift
126
- arg_names = args
127
- configs = {}
128
- needs = []
129
-
130
- if task_name.is_a?(Hash)
131
- hash = task_name
132
- task_name = hash.keys[0]
133
- needs = hash[task_name]
134
- end
135
-
136
- if arg_names.last.is_a?(Hash)
137
- configs = arg_names.pop
138
- end
139
-
140
- needs = needs.respond_to?(:to_ary) ? needs.to_ary : [needs]
141
- needs = needs.compact.collect do |need|
142
- unless need.kind_of?(Class)
143
- name = normalize_name(need).camelize
144
- need = Support::Constant.constantize(name) do |base, constants|
145
- declare(name)
146
- end
147
- end
148
-
149
- unless need.ancestors.include?(Tap::Task)
150
- raise ArgumentError, "not a task: #{need}"
151
- end
152
-
153
- need
154
- end
155
-
156
- [normalize_name(task_name), configs, needs, arg_names]
157
- end
158
-
159
- def normalize_name(name)
160
- name.to_s.underscore.tr(":", "/")
161
- end
162
-
163
- def declare(name, configs={}, dependencies=[], &block)
164
- const_name = File.join(declaration_base, name).camelize
165
-
166
- # generate the subclass
167
- subclass = Support::Constant.constantize(const_name) do |base, constants|
168
- constants.each do |const|
169
- # nesting Tasks into Tasks is required for
170
- # namespaces with the same name as a task
171
- base = base.const_set(const, Class.new(Tap::Task))
172
- end
173
- base
174
- end
175
-
176
- subclass.extend Rakish
177
-
178
- configs.each_pair do |key, value|
179
- subclass.send(:config, key, value)
180
- end
181
-
182
- dependencies.each do |dependency|
183
- dependency_name = File.basename(dependency.default_name)
184
- subclass.send(:depends_on, dependency_name, dependency)
185
- end
186
-
187
- if block_given?
188
- subclass.send(:undef_method, :process) if subclass.method_defined?(:process)
189
- subclass.send(:define_method, :process, &block)
190
- end
191
-
192
- # update any dependencies in instance
193
- subclass.dependencies.each do |dependency|
194
- subclass.instance.depends_on(dependency.instance)
195
- end
196
-
197
- # register the subclass in the manifest
198
- manifest = declaration_env.tasks
199
- const_name = subclass.to_s
200
- unless manifest.entries.any? {|const| const.name == const_name }
201
- manifest.entries << Tap::Support::Constant.new(const_name)
202
- end
203
-
204
- subclass
205
- end
206
-
207
- def register_doc(task_class, arg_names)
208
-
209
- # register documentation
210
- caller[1] =~ Lazydoc::CALLER_REGEXP
211
- task_class.source_file = File.expand_path($1)
212
- manifest = task_class.lazydoc(false).register($3.to_i - 1, Lazydoc::Declaration)
213
- manifest.desc = current_desc
214
- task_class.manifest = manifest
215
-
216
- self.current_desc = nil
217
-
218
- if arg_names
219
- comment = Lazydoc::Comment.new
220
- comment.subject = arg_names.collect {|name| name.to_s.upcase }.join(' ')
221
- task_class.args = comment
222
- end
223
-
224
- task_class
225
- end
226
- end
227
-
228
- extend Declarations
229
- end
@@ -1,12 +0,0 @@
1
- ###############################################################################
2
- # <%= receiver %> configuration<%= configurations.length > 1 ? 's' : '' %>
3
- ###############################################################################
4
- <% configurations.each do |key, config| %>
5
-
6
- <% Lazydoc::Comment.wrap(config.desc.to_s, 50, 2).each do |line| %>
7
- # <%= line %>
8
- <% end %>
9
- <%= config.default == nil ? '#' : '' %><%= yamlize({key.to_s => config.default}) %>
10
-
11
- <% end %>
12
-