bahuvrihi-tap 0.10.7 → 0.10.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/MIT-LICENSE +0 -2
  2. data/README +20 -31
  3. data/bin/rap +18 -8
  4. data/cgi/run.rb +47 -37
  5. data/cmd/console.rb +1 -1
  6. data/cmd/destroy.rb +3 -3
  7. data/cmd/generate.rb +3 -3
  8. data/cmd/manifest.rb +61 -53
  9. data/cmd/run.rb +1 -1
  10. data/doc/Class Reference +119 -110
  11. data/doc/Command Reference +76 -123
  12. data/doc/Syntax Reference +290 -0
  13. data/doc/Tutorial +307 -237
  14. data/lib/tap.rb +1 -12
  15. data/lib/tap/app.rb +46 -71
  16. data/lib/tap/constants.rb +1 -1
  17. data/lib/tap/declarations.rb +110 -100
  18. data/lib/tap/env.rb +141 -173
  19. data/lib/tap/exe.rb +5 -5
  20. data/lib/tap/file_task.rb +2 -2
  21. data/lib/tap/generator/base.rb +0 -4
  22. data/lib/tap/generator/destroy.rb +8 -12
  23. data/lib/tap/generator/generate.rb +19 -14
  24. data/lib/tap/generator/generators/command/command_generator.rb +1 -1
  25. data/lib/tap/generator/generators/config/config_generator.rb +3 -3
  26. data/lib/tap/generator/generators/file_task/file_task_generator.rb +1 -1
  27. data/lib/tap/generator/generators/generator/generator_generator.rb +27 -0
  28. data/lib/tap/generator/generators/generator/templates/task.erb +27 -0
  29. data/lib/tap/generator/generators/root/root_generator.rb +12 -12
  30. data/lib/tap/generator/generators/root/templates/Rakefile +1 -2
  31. data/lib/tap/generator/generators/root/templates/tapfile +11 -8
  32. data/lib/tap/generator/generators/task/task_generator.rb +1 -3
  33. data/lib/tap/generator/generators/task/templates/test.erb +1 -3
  34. data/lib/tap/root.rb +4 -2
  35. data/lib/tap/support/aggregator.rb +16 -3
  36. data/lib/tap/support/assignments.rb +10 -9
  37. data/lib/tap/support/audit.rb +58 -62
  38. data/lib/tap/support/class_configuration.rb +32 -43
  39. data/lib/tap/support/combinator.rb +7 -7
  40. data/lib/tap/support/configurable.rb +13 -14
  41. data/lib/tap/support/configurable_class.rb +6 -30
  42. data/lib/tap/support/configuration.rb +36 -9
  43. data/lib/tap/support/constant.rb +75 -13
  44. data/lib/tap/support/constant_manifest.rb +115 -0
  45. data/lib/tap/support/dependencies.rb +27 -67
  46. data/lib/tap/support/dependency.rb +44 -0
  47. data/lib/tap/support/executable.rb +78 -109
  48. data/lib/tap/support/executable_queue.rb +1 -1
  49. data/lib/tap/support/gems.rb +6 -0
  50. data/lib/tap/support/gems/rack.rb +197 -84
  51. data/lib/tap/support/instance_configuration.rb +29 -3
  52. data/lib/tap/support/intern.rb +46 -0
  53. data/lib/tap/support/join.rb +67 -11
  54. data/lib/tap/support/joins.rb +2 -0
  55. data/lib/tap/support/joins/fork.rb +1 -0
  56. data/lib/tap/support/joins/merge.rb +3 -1
  57. data/lib/tap/support/joins/sequence.rb +2 -2
  58. data/lib/tap/support/joins/switch.rb +3 -1
  59. data/lib/tap/support/joins/sync_merge.rb +6 -0
  60. data/lib/tap/support/lazy_attributes.rb +16 -1
  61. data/lib/tap/support/lazydoc.rb +21 -21
  62. data/lib/tap/support/lazydoc/comment.rb +59 -55
  63. data/lib/tap/support/lazydoc/definition.rb +36 -0
  64. data/lib/tap/support/lazydoc/document.rb +37 -13
  65. data/lib/tap/support/manifest.rb +120 -131
  66. data/lib/tap/support/minimap.rb +90 -0
  67. data/lib/tap/support/node.rb +4 -6
  68. data/lib/tap/support/parser.rb +63 -6
  69. data/lib/tap/support/schema.rb +11 -2
  70. data/lib/tap/support/shell_utils.rb +3 -5
  71. data/lib/tap/support/string_ext.rb +60 -0
  72. data/lib/tap/support/tdoc.rb +2 -2
  73. data/lib/tap/support/templater.rb +29 -15
  74. data/lib/tap/support/validation.rb +22 -11
  75. data/lib/tap/task.rb +155 -156
  76. data/lib/tap/tasks/load.rb +95 -8
  77. data/lib/tap/test/extensions.rb +2 -1
  78. data/lib/tap/test/script_tester.rb +7 -1
  79. data/template/index.erb +39 -32
  80. metadata +13 -13
  81. data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +0 -15
  82. data/lib/tap/patches/rake/rake_test_loader.rb +0 -8
  83. data/lib/tap/patches/rake/testtask.rb +0 -57
  84. data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -51
  85. data/lib/tap/patches/ruby19/parsedate.rb +0 -16
  86. data/lib/tap/spec.rb +0 -42
  87. data/lib/tap/spec/adapter.rb +0 -25
  88. data/lib/tap/spec/inheritable_class_test_root.rb +0 -9
  89. data/lib/tap/support/constant_utils.rb +0 -127
  90. data/lib/tap/support/summary.rb +0 -30
@@ -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 generate and utilize config
9
- files, join tasks into workflows, as well as dump and reuse results. Task
10
- libraries are readily shared as gems. Check out the links for tutorials,
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
- * {Tutorial}[link:files/doc/Tutorial.html], {Class}[link:files/doc/Class%20Reference.html] and {Command}[link:files/doc/Command%20Reference.html] Reference
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/overview]
16
+ * Lighthouse[http://bahuvrihi.lighthouseapp.com/projects/9908-tap-task-application/tickets]
16
17
  * Github[http://github.com/bahuvrihi/tap/tree/master]
17
18
  * {Google Group}[http://groups.google.com/group/ruby-on-tap]
18
19
 
19
- === Additional Notes:
20
+ === Features
20
21
 
21
22
  - Tap and Rake[http://rake.rubyforge.org/] are targeted at different problems,
22
- but play well together. See Tap::Tasks::Rake to use rake tasks in tap.
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
 
@@ -46,6 +47,7 @@ Tap pulls documentation out of task classes to generate manifests:
46
47
  goodnight # your basic goodnight moon task
47
48
  tap:
48
49
  dump # the default dump task
50
+ load # the default load task
49
51
  rake # run rake tasks
50
52
 
51
53
  And help:
@@ -66,39 +68,26 @@ And help:
66
68
  --use FILE Loads inputs from file
67
69
 
68
70
 
69
- Tasks are immediately available to run:
71
+ Tasks are immediately available to run through tap or rap:
70
72
 
71
73
  % tap run -- goodnight moon
72
74
  I[00:09:55] goodnight moon
73
75
 
74
-
75
- % tap run -- goodnight moon --message hello
76
+ % rap goodnight moon --message hello
76
77
  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
78
 
82
- % gem install sample_tasks
83
- % tap run -T
84
- sample:
85
- goodnight # your basic goodnight moon task
86
- sample_tasks:
87
- concat # concatenate files with formatting
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
79
+ Tap comes with generators. To get started:
80
+
81
+ % tap generate root sample
82
+ % cd sample
83
+ % tap generate task goodnight
84
+ % rap goodnight moon
94
85
 
95
86
  === Bugs/Known Issues
96
87
 
97
88
  - Some inconsequential tests on JRuby fail due to bugs in JRuby itself.
98
- - Several patches are required so that Tap runs properly on MRI 1.9.0. These
99
- will likely resolve themselves as 1.9.0 becomes stable.
100
- - Despite the talk of workflows, the Workflow class should still be considered
101
- in progress. Tasks themselves are stable.
89
+ - Joins, Parser, and Schema require additional documentation and may be
90
+ internally reworked. The workflow syntax should remain the same.
102
91
 
103
92
  == Installation
104
93
 
data/bin/rap CHANGED
@@ -10,12 +10,12 @@ begin
10
10
  # handle super options
11
11
  $DEBUG = true if ARGV.delete('-d-')
12
12
  env = Tap::Exe.instantiate
13
-
14
- # add the DEFAULT_TASK_FILE if it exists
13
+ env.unshift(Tap::Declarations.env)
14
+
15
15
  task_file = File.expand_path('Tapfile')
16
16
  if File.exists?(task_file)
17
17
  env.loads.unshift(task_file)
18
- env.manifest(:tasks).search_paths << [Dir.pwd, task_file]
18
+ env.tasks.register(Dir.pwd, task_file)
19
19
  end
20
20
 
21
21
  rescue(Tap::Env::ConfigError)
@@ -66,14 +66,24 @@ begin
66
66
 
67
67
  case ARGV[0]
68
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
+
69
83
  puts Tap::Support::Lazydoc.usage(__FILE__)
70
84
  puts
71
85
  puts "=== tap tasks ==="
72
- str = env.summarize(:tasks) do |const|
73
- const.document.resolve
74
- const.document[const.name]['manifest'].subject
75
- end
76
- puts str
86
+ puts env.summarize(:tasks, rap_template)
77
87
  puts
78
88
  puts "=== rake tasks ==="
79
89
  Tap::Tasks::Rake.new.enq('-T')
data/cgi/run.rb CHANGED
@@ -6,52 +6,62 @@
6
6
  ############################
7
7
  require 'cgi'
8
8
  require "#{File.dirname(__FILE__)}/../vendor/url_encoded_pair_parser"
9
- require "tap/support/parsers/server"
10
9
 
11
- server = Tap::Env.instance
10
+ env = Tap::Env.instance
12
11
 
13
- require 'tap/tasks/dump'
14
- task_attributes = {
15
- :tasc => Tap::Tasks::Dump,
16
- :config => {},
17
- :inputs => []
18
- }
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
19
38
 
20
39
  cgi = CGI.new("html3") # add HTML generation methods
21
40
  cgi.out() do
22
41
  case cgi.request_method
23
42
  when /GET/i
24
- server.cgi_template('run',
25
- :server => server,
26
- :workflow => {},
27
- :tasks => [task_attributes])
28
-
29
- when /POST/i
30
- argh = UrlEncodedPairParser.new(cgi.params.to_a).result
31
- argh = Tap::Support::Parsers::Server.compact(argh)
32
- parser = Tap::Support::Parsers::Server.new(argh)
43
+ env.render('run.erb', :env => env, :tascs => [] )
33
44
 
34
- case cgi['action']
35
- when /ADD/i
36
- cgi.pre { parser.to_yaml }
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")
37
55
 
38
- when /REMOVE/i
39
- "remove"
40
- when /RUN/i
41
- "run"
42
-
43
- # argh = UrlEncodedPairParser.new(cgi.params.to_a).result
44
- # queues = Tap::Support::Parsers::Server.new(argh).build(Tap::Env.instance, Tap::App.instance)
45
-
46
- # if queues.empty?
47
- # end
48
-
49
- # queues.each_with_index do |queue, i|
50
- # app.queue.concat(queue)
51
- # app.run
52
- # end
53
- else raise ArgumentError, "unhandled request action: #{cgi['action']}"
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
54
63
  end
55
- else raise ArgumentError, "unhandled request method: #{cgi.request_method}"
64
+ else
65
+ raise ArgumentError, "unhandled request method: #{cgi.request_method}"
56
66
  end
57
67
  end
@@ -12,7 +12,7 @@ OptionParser.new do |opts|
12
12
  opts.separator "options:"
13
13
 
14
14
  opts.on("-h", "--help", "Show this message") do
15
- opts.banner = Tap::Support::CommandLine.usage(__FILE__)
15
+ opts.banner = Tap::Support::Lazydoc.usage(__FILE__)
16
16
  puts opts
17
17
  exit
18
18
  end
@@ -3,13 +3,13 @@ require 'tap/generator/destroy'
3
3
 
4
4
  env = Tap::Env.instance
5
5
 
6
- if ARGV.empty? || ARGV == ['-T']
7
- puts env.summarize(:generators) {|const| const.document[const.name]['generator'] }
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(:generators, name) or raise "unknown generator: #{name}"
12
+ const = env.generators.search(name) or raise "unknown generator: #{name}"
13
13
 
14
14
  generator_class = const.constantize
15
15
  generator, argv = generator_class.parse(ARGV)
@@ -3,13 +3,13 @@ require 'tap/generator/generate'
3
3
 
4
4
  env = Tap::Env.instance
5
5
 
6
- if ARGV.empty? || ARGV == ['-T']
7
- puts env.summarize(:generators) {|const| const.document[const.name]['generator'] }
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(:generators, name) or raise "unknown generator: #{name}"
12
+ const = env.generators.search(name) or raise "unknown generator: #{name}"
13
13
 
14
14
  generator_class = const.constantize
15
15
  generator, argv = generator_class.parse(ARGV)
@@ -1,6 +1,6 @@
1
1
  # tap manifest
2
2
  #
3
- # Prints information about each env.
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 = cmdline.usage(__FILE__)
13
+ opts.banner = Tap::Support::Lazydoc.usage(__FILE__)
14
14
  puts opts
15
15
  exit
16
16
  end
17
17
 
18
- opts.on("-e", "--envs_only", "Only list environments") do
19
- options[:envs_only] = true
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
- require value
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
- # Simply a method to collect and format paths for
29
- # the specified manifest.
30
- def collect_map(env, manifest)
31
- width = 10
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
- # Collect remaining args as
49
- env = Tap::Env.instance
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
- raise "could not find an env matching: #{name}" if entry == nil
56
- entry
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
- width = 10
61
- envs_manifest.each {|(env_name, e)| width = env_name.length if width < env_name.length}
62
- width += 2
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
- env.each do |current|
65
- env_name, current = envs_manifest.find {|(env_name, e)| e == current }
66
- next if env_name == nil
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.each do |name|
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
- puts " %-10s %s" % [name, collect_map(current, manifest).join("\n ")]
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
- puts '-' * 80
85
- puts
86
- env.recursive_each(0, nil) do |current, nesting_depth, last_env|
87
- env_name, current = envs_manifest.find {|(env_name, e)| e == current }
88
-
89
- leader = nesting_depth == 0 ? "" : '| ' * (nesting_depth - 1) + (last_env == current ? "`- " : "|- ")
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
@@ -36,7 +36,7 @@ OptionParser.new do |opts|
36
36
  end
37
37
 
38
38
  opts.on('-T', '--manifest', 'Print a list of available tasks') do |v|
39
- puts env.summarize(:tasks) {|const| const.document[const.name]['manifest'] }
39
+ puts env.summarize(:tasks)
40
40
  exit
41
41
  end
42
42