bahuvrihi-tap 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/History +69 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +119 -0
  4. data/bin/tap +114 -0
  5. data/cmd/console.rb +42 -0
  6. data/cmd/destroy.rb +16 -0
  7. data/cmd/generate.rb +16 -0
  8. data/cmd/run.rb +126 -0
  9. data/doc/Class Reference +362 -0
  10. data/doc/Command Reference +153 -0
  11. data/doc/Tutorial +237 -0
  12. data/lib/tap.rb +32 -0
  13. data/lib/tap/app.rb +720 -0
  14. data/lib/tap/constants.rb +8 -0
  15. data/lib/tap/env.rb +640 -0
  16. data/lib/tap/file_task.rb +547 -0
  17. data/lib/tap/generator/base.rb +109 -0
  18. data/lib/tap/generator/destroy.rb +37 -0
  19. data/lib/tap/generator/generate.rb +61 -0
  20. data/lib/tap/generator/generators/command/command_generator.rb +21 -0
  21. data/lib/tap/generator/generators/command/templates/command.erb +32 -0
  22. data/lib/tap/generator/generators/config/config_generator.rb +26 -0
  23. data/lib/tap/generator/generators/config/templates/doc.erb +12 -0
  24. data/lib/tap/generator/generators/config/templates/nodoc.erb +8 -0
  25. data/lib/tap/generator/generators/file_task/file_task_generator.rb +27 -0
  26. data/lib/tap/generator/generators/file_task/templates/file.txt +11 -0
  27. data/lib/tap/generator/generators/file_task/templates/result.yml +6 -0
  28. data/lib/tap/generator/generators/file_task/templates/task.erb +33 -0
  29. data/lib/tap/generator/generators/file_task/templates/test.erb +29 -0
  30. data/lib/tap/generator/generators/root/root_generator.rb +55 -0
  31. data/lib/tap/generator/generators/root/templates/Rakefile +86 -0
  32. data/lib/tap/generator/generators/root/templates/gemspec +27 -0
  33. data/lib/tap/generator/generators/root/templates/tapfile +8 -0
  34. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +3 -0
  35. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +5 -0
  36. data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +15 -0
  37. data/lib/tap/generator/generators/task/task_generator.rb +27 -0
  38. data/lib/tap/generator/generators/task/templates/task.erb +14 -0
  39. data/lib/tap/generator/generators/task/templates/test.erb +21 -0
  40. data/lib/tap/generator/manifest.rb +14 -0
  41. data/lib/tap/patches/rake/rake_test_loader.rb +8 -0
  42. data/lib/tap/patches/rake/testtask.rb +55 -0
  43. data/lib/tap/patches/ruby19/backtrace_filter.rb +51 -0
  44. data/lib/tap/patches/ruby19/parsedate.rb +16 -0
  45. data/lib/tap/root.rb +581 -0
  46. data/lib/tap/support/aggregator.rb +55 -0
  47. data/lib/tap/support/assignments.rb +172 -0
  48. data/lib/tap/support/audit.rb +418 -0
  49. data/lib/tap/support/batchable.rb +47 -0
  50. data/lib/tap/support/batchable_class.rb +107 -0
  51. data/lib/tap/support/class_configuration.rb +194 -0
  52. data/lib/tap/support/command_line.rb +98 -0
  53. data/lib/tap/support/comment.rb +270 -0
  54. data/lib/tap/support/configurable.rb +114 -0
  55. data/lib/tap/support/configurable_class.rb +296 -0
  56. data/lib/tap/support/configuration.rb +122 -0
  57. data/lib/tap/support/constant.rb +70 -0
  58. data/lib/tap/support/constant_utils.rb +127 -0
  59. data/lib/tap/support/declarations.rb +111 -0
  60. data/lib/tap/support/executable.rb +111 -0
  61. data/lib/tap/support/executable_queue.rb +82 -0
  62. data/lib/tap/support/framework.rb +71 -0
  63. data/lib/tap/support/framework_class.rb +199 -0
  64. data/lib/tap/support/instance_configuration.rb +147 -0
  65. data/lib/tap/support/lazydoc.rb +428 -0
  66. data/lib/tap/support/manifest.rb +89 -0
  67. data/lib/tap/support/run_error.rb +39 -0
  68. data/lib/tap/support/shell_utils.rb +71 -0
  69. data/lib/tap/support/summary.rb +30 -0
  70. data/lib/tap/support/tdoc.rb +404 -0
  71. data/lib/tap/support/tdoc/tdoc_html_generator.rb +38 -0
  72. data/lib/tap/support/tdoc/tdoc_html_template.rb +42 -0
  73. data/lib/tap/support/templater.rb +180 -0
  74. data/lib/tap/support/validation.rb +410 -0
  75. data/lib/tap/support/versions.rb +97 -0
  76. data/lib/tap/task.rb +259 -0
  77. data/lib/tap/tasks/dump.rb +56 -0
  78. data/lib/tap/tasks/rake.rb +93 -0
  79. data/lib/tap/test.rb +37 -0
  80. data/lib/tap/test/env_vars.rb +29 -0
  81. data/lib/tap/test/file_methods.rb +377 -0
  82. data/lib/tap/test/script_methods.rb +144 -0
  83. data/lib/tap/test/subset_methods.rb +420 -0
  84. data/lib/tap/test/tap_methods.rb +237 -0
  85. data/lib/tap/workflow.rb +187 -0
  86. metadata +145 -0
@@ -0,0 +1,187 @@
1
+ module Tap
2
+
3
+ # Workflow is a specialized type of Task allowing the encapsulation and reuse of
4
+ # workflow logic. Workflows are still under construction.
5
+ #
6
+ # === Workflow Definition
7
+ #
8
+ # During initialization, Workflow executes the workflow method (by default the
9
+ # block provided to Workflow.new) to define the workflow logic. This method
10
+ # defines one or more entry_points and zero or more exit points, as well as
11
+ # the internal logic for the workflow.
12
+ #
13
+ # Workflow.new do |w|
14
+ # factor = w.config[:factor] || 1
15
+ #
16
+ # t1 = Task.new {|task, input| input += 1 }
17
+ # t2 = Task.new {|task, input| input += 10 }
18
+ # t3 = Task.new {|task, input| input *= factor }
19
+ #
20
+ # w.app.sequence(t1, t2, t3)
21
+ # w.entry_point = t1
22
+ # w.exit_point = t3
23
+ # end
24
+ #
25
+ # Or equivalently:
26
+ #
27
+ # class SimpleSequence < Workflow
28
+ # config :factor, 1
29
+ #
30
+ # def workflow
31
+ # t1 = Task.new {|task, input| input += 5 }
32
+ # t2 = Task.new {|task, input| input += 3 }
33
+ # t3 = Task.new {|task, input| input *= factor }
34
+ #
35
+ # app.sequence(t1, t2, t3)
36
+ # self.entry_point = t1
37
+ # self.exit_point = t3
38
+ # end
39
+ # end
40
+ #
41
+ # To facilitate the specification of entry and exit points, workflow
42
+ # can accomodate either single-task assignments or a collection. By
43
+ # default both are hashes, but they can be reassigned:
44
+ #
45
+ # Workflow.new do |w|
46
+ # w.entry_point.class # => Hash
47
+ # w.exit_point.class # => Hash
48
+ # w.entry_point[:main] = Task.new
49
+ # end
50
+ #
51
+ # Workflow.new {|w| w.entry_point = Task.new }
52
+ # Workflow.new {|w| w.entry_point = [Task.new, Task.new] }
53
+ #
54
+ # Access to the group of entry/exit points is standardized to an
55
+ # array via the entry_points and exit_points methods.
56
+ #
57
+ # === Workflow Behavior
58
+ #
59
+ # The entry points act as an enque batch; when the workflow is enqued, the
60
+ # entry points are enqued. The exit points act as an on_complete batch; their
61
+ # on_complete blocks are set for workflow.on_complete.
62
+ #
63
+ # w = SimpleSequence.new
64
+ # w.enq(0)
65
+ # app.run
66
+ # app.results(w.exit_points) # => [8]
67
+ #
68
+ # The batching of entry and exit points is distinct from workflow.batch itself.
69
+ # Workflows can be batched like Tasks, such that all entry points from all
70
+ # workflows in a batch are enqued at once.
71
+ #
72
+ # w1 = SimpleSequence.new nil, :factor => 1
73
+ # w2 = w1.initialize_batch_obj nil, :factor => -1
74
+ #
75
+ # w1.enq(0)
76
+ # app.run
77
+ # app.results(w1.exit_points, w2.exit_points)) # => [8, -8]
78
+ #
79
+ class Workflow
80
+ include Support::Framework
81
+
82
+ # The entry point for self.
83
+ attr_accessor :entry_point
84
+
85
+ # The exit point for self.
86
+ attr_accessor :exit_point
87
+
88
+ # The task block provided during initialization.
89
+ attr_reader :task_block
90
+
91
+ # Creates a new Task with the specified attributes.
92
+ def initialize(config={}, name=nil, app=App.instance, &task_block)
93
+ super(config, name, app)
94
+ @task_block = (task_block == nil ? default_task_block : task_block)
95
+ initialize_workflow
96
+ end
97
+
98
+ # Initializes a new batch object, running workflow to set the
99
+ # instance-specific entry/exit points. Raises an error if
100
+ # no entry points are defined.
101
+ def initialize_copy(orig)
102
+ super
103
+ initialize_workflow
104
+ end
105
+
106
+ # Returns an array of entry points, determined from entry_point.
107
+ def entry_points
108
+ case entry_point
109
+ when Hash then entry_point.values
110
+ when Support::Executable then [entry_point]
111
+ when Array then entry_point
112
+ else
113
+ raise "unable to determine entry points from entry_point (should be Hash, Array, or Executable): #{entry_point}"
114
+ end
115
+ end
116
+
117
+ # Returns an array of exit points, determined from exit_point.
118
+ def exit_points
119
+ case exit_point
120
+ when Hash then exit_point.values
121
+ when Support::Executable then [exit_point]
122
+ when Array then exit_point
123
+ else
124
+ raise "unable to determine exit points from exit_point (should be Hash, Array, or Executable): #{exit_point}"
125
+ end
126
+ end
127
+
128
+ # Enqueues all entry points for self and self.batch to app
129
+ # with the inputs. The number of inputs provided should match
130
+ # the number of inputs required by all the entry points;
131
+ # if the entry points have different input requirements, they
132
+ # have to be enqued separately.
133
+ def enq(*inputs)
134
+ entry_points.each do |task|
135
+ app.enq(task, *inputs)
136
+ end
137
+ end
138
+
139
+ batch_function :enq
140
+
141
+ # Sets the on_complete_block for all exit points for self and
142
+ # self.batch. Use unbatched_on_complete to set the on_complete_block
143
+ # for just self.exit_points.
144
+ def on_complete(override=false, &block)
145
+ exit_points.each do |task|
146
+ task.on_complete(override, &block)
147
+ end
148
+ self
149
+ end
150
+
151
+ batch_function(:on_complete) {}
152
+
153
+ # The workflow definition method. By default workflow
154
+ # simply calls the task_block. In subclasses, workflow
155
+ # should be overridden to provide the workflow definition.
156
+ def workflow
157
+ raise WorkflowError.new("No workflow definition provided.") unless task_block
158
+ task_block.call(self)
159
+ end
160
+
161
+ class WorkflowError < Exception # :nodoc:
162
+ end
163
+
164
+ # Returns the name of the workflow joined to the input. This
165
+ # can be convenient when naming internal tasks, as they can
166
+ # be grouped based on the name of the workflow. Returns
167
+ # the name of the workflow if input == nil.
168
+ def name(input=nil)
169
+ input == nil ? @name : File.join(@name, input)
170
+ end
171
+
172
+ protected
173
+
174
+ def initialize_workflow
175
+ @entry_point = {}
176
+ @exit_point = {}
177
+
178
+ workflow
179
+ raise WorkflowError.new("No entry points defined") if entry_points.empty?
180
+ end
181
+
182
+ # Hook to set a default task block. By default, nil.
183
+ def default_task_block
184
+ nil
185
+ end
186
+ end
187
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bahuvrihi-tap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
5
+ platform: ruby
6
+ authors:
7
+ - Simon Chiang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-08 00:00:00 -07:00
13
+ default_executable: tap
14
+ dependencies: []
15
+
16
+ description:
17
+ email: simon.a.chiang@gmail.com
18
+ executables:
19
+ - tap
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - MIT-LICENSE
25
+ - History
26
+ - doc/Tutorial
27
+ - doc/Class Reference
28
+ - doc/Command Reference
29
+ files:
30
+ - README
31
+ - MIT-LICENSE
32
+ - History
33
+ - cmd/console.rb
34
+ - cmd/destroy.rb
35
+ - cmd/generate.rb
36
+ - cmd/run.rb
37
+ - doc/Tutorial
38
+ - doc/Class Reference
39
+ - doc/Command Reference
40
+ - bin/tap
41
+ - lib/tap/app.rb
42
+ - lib/tap/constants.rb
43
+ - lib/tap/env.rb
44
+ - lib/tap/file_task.rb
45
+ - lib/tap/generator/base.rb
46
+ - lib/tap/generator/destroy.rb
47
+ - lib/tap/generator/generate.rb
48
+ - lib/tap/generator/generators/command/command_generator.rb
49
+ - lib/tap/generator/generators/command/templates/command.erb
50
+ - lib/tap/generator/generators/config/config_generator.rb
51
+ - lib/tap/generator/generators/config/templates/doc.erb
52
+ - lib/tap/generator/generators/config/templates/nodoc.erb
53
+ - lib/tap/generator/generators/file_task/file_task_generator.rb
54
+ - lib/tap/generator/generators/file_task/templates/file.txt
55
+ - lib/tap/generator/generators/file_task/templates/result.yml
56
+ - lib/tap/generator/generators/file_task/templates/task.erb
57
+ - lib/tap/generator/generators/file_task/templates/test.erb
58
+ - lib/tap/generator/generators/root/root_generator.rb
59
+ - lib/tap/generator/generators/root/templates/Rakefile
60
+ - lib/tap/generator/generators/root/templates/tapfile
61
+ - lib/tap/generator/generators/root/templates/gemspec
62
+ - lib/tap/generator/generators/root/templates/test/tap_test_helper.rb
63
+ - lib/tap/generator/generators/root/templates/test/tap_test_suite.rb
64
+ - lib/tap/generator/generators/root/templates/test/tapfile_test.rb
65
+ - lib/tap/generator/generators/task/task_generator.rb
66
+ - lib/tap/generator/generators/task/templates/task.erb
67
+ - lib/tap/generator/generators/task/templates/test.erb
68
+ - lib/tap/generator/manifest.rb
69
+ - lib/tap/patches/rake/rake_test_loader.rb
70
+ - lib/tap/patches/rake/testtask.rb
71
+ - lib/tap/patches/ruby19/backtrace_filter.rb
72
+ - lib/tap/patches/ruby19/parsedate.rb
73
+ - lib/tap/root.rb
74
+ - lib/tap/support/aggregator.rb
75
+ - lib/tap/support/assignments.rb
76
+ - lib/tap/support/audit.rb
77
+ - lib/tap/support/batchable.rb
78
+ - lib/tap/support/batchable_class.rb
79
+ - lib/tap/support/class_configuration.rb
80
+ - lib/tap/support/command_line.rb
81
+ - lib/tap/support/comment.rb
82
+ - lib/tap/support/configurable.rb
83
+ - lib/tap/support/configurable_class.rb
84
+ - lib/tap/support/configuration.rb
85
+ - lib/tap/support/constant.rb
86
+ - lib/tap/support/constant_utils.rb
87
+ - lib/tap/support/declarations.rb
88
+ - lib/tap/support/executable.rb
89
+ - lib/tap/support/executable_queue.rb
90
+ - lib/tap/support/framework.rb
91
+ - lib/tap/support/framework_class.rb
92
+ - lib/tap/support/instance_configuration.rb
93
+ - lib/tap/support/lazydoc.rb
94
+ - lib/tap/support/manifest.rb
95
+ - lib/tap/support/run_error.rb
96
+ - lib/tap/support/shell_utils.rb
97
+ - lib/tap/support/tdoc.rb
98
+ - lib/tap/support/tdoc/tdoc_html_generator.rb
99
+ - lib/tap/support/tdoc/tdoc_html_template.rb
100
+ - lib/tap/support/summary.rb
101
+ - lib/tap/support/templater.rb
102
+ - lib/tap/support/validation.rb
103
+ - lib/tap/support/versions.rb
104
+ - lib/tap/task.rb
105
+ - lib/tap/tasks/dump.rb
106
+ - lib/tap/tasks/rake.rb
107
+ - lib/tap/test/env_vars.rb
108
+ - lib/tap/test/file_methods.rb
109
+ - lib/tap/test/script_methods.rb
110
+ - lib/tap/test/subset_methods.rb
111
+ - lib/tap/test/tap_methods.rb
112
+ - lib/tap/test.rb
113
+ - lib/tap/workflow.rb
114
+ - lib/tap.rb
115
+ has_rdoc: true
116
+ homepage: http://tap.rubyforge.org
117
+ post_install_message:
118
+ rdoc_options:
119
+ - --title
120
+ - Tap - Task Application
121
+ - --main
122
+ - README
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: "0"
130
+ version:
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "0"
136
+ version:
137
+ requirements: []
138
+
139
+ rubyforge_project: tap
140
+ rubygems_version: 1.2.0
141
+ signing_key:
142
+ specification_version: 2
143
+ summary: A framework for creating configurable, distributable tasks and workflows.
144
+ test_files: []
145
+