tap 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +28 -0
- data/MIT-LICENSE +1 -1
- data/README +71 -43
- data/Rakefile +81 -64
- data/Tutorial +235 -0
- data/bin/tap +80 -44
- data/lib/tap.rb +41 -12
- data/lib/tap/app.rb +243 -246
- data/lib/tap/file_task.rb +357 -118
- data/lib/tap/generator.rb +88 -29
- data/lib/tap/generator/generators/config/config_generator.rb +4 -2
- data/lib/tap/generator/generators/config/templates/config.erb +1 -2
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +3 -18
- data/lib/tap/generator/generators/file_task/templates/task.erb +22 -15
- data/lib/tap/generator/generators/file_task/templates/test.erb +13 -2
- data/{test/test/inference_methods/test_assert_files_exist/input/input_1.txt → lib/tap/generator/generators/generator/USAGE} +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +21 -0
- data/lib/tap/generator/generators/generator/templates/generator.erb +23 -0
- data/lib/tap/generator/generators/generator/templates/usage.erb +1 -0
- data/{test/test/inference_methods/test_assert_files_exist/input/input_2.txt → lib/tap/generator/generators/package/USAGE} +0 -0
- data/lib/tap/generator/generators/package/package_generator.rb +38 -0
- data/lib/tap/generator/generators/package/templates/package.erb +186 -0
- data/lib/tap/generator/generators/root/root_generator.rb +14 -9
- data/lib/tap/generator/generators/root/templates/Rakefile +20 -14
- data/{test/test/inference_methods/test_infer_glob/expected/file.yml → lib/tap/generator/generators/root/templates/ReadMe.txt} +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +82 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -1
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +2 -1
- data/{test/test/inference_methods/test_infer_glob/expected/file_1.txt → lib/tap/generator/generators/script/USAGE} +0 -0
- data/lib/tap/generator/generators/script/script_generator.rb +17 -0
- data/lib/tap/generator/generators/script/templates/script.erb +42 -0
- data/lib/tap/generator/generators/task/task_generator.rb +1 -1
- data/lib/tap/generator/generators/task/templates/task.erb +24 -16
- data/lib/tap/generator/generators/task/templates/test.erb +13 -17
- data/lib/tap/generator/generators/workflow/templates/task.erb +10 -10
- data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +3 -18
- data/lib/tap/root.rb +108 -146
- data/lib/tap/script.rb +362 -0
- data/lib/tap/script/console.rb +28 -0
- data/lib/tap/script/destroy.rb +13 -1
- data/lib/tap/script/generate.rb +13 -1
- data/lib/tap/script/run.rb +100 -57
- data/lib/tap/support/batch_queue.rb +0 -3
- data/lib/tap/support/logger.rb +6 -3
- data/lib/tap/support/rake.rb +54 -0
- data/lib/tap/support/task_configuration.rb +169 -0
- data/lib/tap/support/tdoc.rb +198 -0
- data/lib/tap/support/tdoc/config_attr.rb +338 -0
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +38 -0
- data/lib/tap/support/tdoc/tdoc_html_template.rb +42 -0
- data/lib/tap/support/versions.rb +33 -1
- data/lib/tap/task.rb +339 -227
- data/lib/tap/test.rb +86 -128
- data/lib/tap/test/env_vars.rb +16 -5
- data/lib/tap/test/file_methods.rb +373 -0
- data/lib/tap/test/subset_methods.rb +299 -180
- data/lib/tap/version.rb +2 -1
- data/lib/tap/workflow.rb +2 -0
- data/test/app/lib/app_test_task.rb +1 -0
- data/test/app_test.rb +327 -83
- data/test/check/binding_eval.rb +23 -0
- data/test/check/define_method_check.rb +22 -0
- data/test/check/dependencies_check.rb +175 -0
- data/test/check/inheritance_check.rb +22 -0
- data/test/file_task_test.rb +524 -291
- data/test/{test/inference_methods/test_infer_glob/expected/file_2.txt → root/glob/one.txt} +0 -0
- data/test/root/glob/two.txt +0 -0
- data/test/root_test.rb +330 -262
- data/test/script_test.rb +194 -0
- data/test/support/audit_test.rb +5 -2
- data/test/support/combinator_test.rb +10 -10
- data/test/support/rake_test.rb +35 -0
- data/test/support/task_configuration_test.rb +272 -0
- data/test/support/tdoc_test.rb +363 -0
- data/test/support/templater_test.rb +2 -2
- data/test/support/versions_test.rb +32 -0
- data/test/tap_test_helper.rb +39 -0
- data/test/task_base_test.rb +115 -0
- data/test/task_class_test.rb +56 -4
- data/test/task_execute_test.rb +29 -0
- data/test/task_test.rb +89 -70
- data/test/test/env_vars_test.rb +48 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/folder/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/input/file.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_assert_expected/input/folder/file.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
- data/test/test/file_methods/test_assert_output_files_equal/expected/one.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/expected/two.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_output_files_equal/input/two.txt +1 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_1.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_2.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_1.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_2.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_1.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_2.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_1.yml +0 -0
- data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_2.yml +0 -0
- data/test/test/file_methods_test.rb +204 -0
- data/test/test/subset_methods_test.rb +93 -33
- data/test/test/test_assert_expected_result_files/expected/task/name/a.txt +1 -0
- data/test/test/test_assert_expected_result_files/expected/task/name/b.txt +1 -0
- data/test/test/test_assert_expected_result_files/input/a.txt +1 -0
- data/test/test/test_assert_expected_result_files/input/b.txt +1 -0
- data/test/test/test_file_task_test/expected/one.txt +1 -0
- data/test/test/test_file_task_test/expected/two.txt +1 -0
- data/test/test/test_file_task_test/input/one.txt +1 -0
- data/test/test/test_file_task_test/input/two.txt +1 -0
- data/test/test_test.rb +143 -3
- data/test/workflow_test.rb +2 -0
- data/vendor/rails_generator.rb +56 -0
- data/vendor/rails_generator/base.rb +263 -0
- data/vendor/rails_generator/commands.rb +581 -0
- data/vendor/rails_generator/generated_attribute.rb +42 -0
- data/vendor/rails_generator/lookup.rb +209 -0
- data/vendor/rails_generator/manifest.rb +53 -0
- data/vendor/rails_generator/options.rb +143 -0
- data/vendor/rails_generator/scripts.rb +83 -0
- data/vendor/rails_generator/scripts/destroy.rb +7 -0
- data/vendor/rails_generator/scripts/generate.rb +7 -0
- data/vendor/rails_generator/scripts/update.rb +12 -0
- data/vendor/rails_generator/simple_logger.rb +46 -0
- data/vendor/rails_generator/spec.rb +44 -0
- metadata +180 -196
- data/lib/tap/generator/generators/root/templates/app.yml +0 -19
- data/lib/tap/generator/generators/root/templates/config/process_tap_request.yml +0 -4
- data/lib/tap/generator/generators/root/templates/lib/process_tap_request.rb +0 -26
- data/lib/tap/generator/generators/root/templates/public/images/nav.jpg +0 -0
- data/lib/tap/generator/generators/root/templates/public/stylesheets/color.css +0 -57
- data/lib/tap/generator/generators/root/templates/public/stylesheets/layout.css +0 -108
- data/lib/tap/generator/generators/root/templates/public/stylesheets/normalize.css +0 -40
- data/lib/tap/generator/generators/root/templates/public/stylesheets/typography.css +0 -21
- data/lib/tap/generator/generators/root/templates/server/config/environment.rb +0 -60
- data/lib/tap/generator/generators/root/templates/server/lib/tasks/clear_database_prerequisites.rake +0 -5
- data/lib/tap/generator/generators/root/templates/server/test/test_helper.rb +0 -53
- data/lib/tap/script/server.rb +0 -12
- data/lib/tap/support/rap.rb +0 -38
- data/lib/tap/test/inference_methods.rb +0 -298
- data/test/task/config/task_with_config.yml +0 -1
- data/test/test/inference_methods_test.rb +0 -311
data/History
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== 0.7.9 / 2007-09-14
|
2
|
+
|
3
|
+
* Initial testing release with partial documentation
|
4
|
+
|
5
|
+
== 0.8.0 / 2007-12-08 revision 138
|
6
|
+
|
7
|
+
Major update to Tap. Many changes in this release ARE NOT BACKWARD COMPATIBLE.
|
8
|
+
Documentation is still patchy, but improving.
|
9
|
+
|
10
|
+
* Expanded/reworked application configuration, allowing specification of gems
|
11
|
+
to be loaded as task libraries.
|
12
|
+
* Default app config file is now tap.yml (from app.yml)
|
13
|
+
* Updated and improved generators
|
14
|
+
* Included rails_generators in distribution, removing rails dependency
|
15
|
+
* Reworked many classes to clean up interface
|
16
|
+
* Reworked testing methods
|
17
|
+
* Improved configuration for tasks
|
18
|
+
* Optimized loading
|
19
|
+
* Reworked threading model
|
20
|
+
* Addition of TDoc documentation
|
21
|
+
* Reworked tap command and subcommands
|
22
|
+
* Added packaging into executables
|
23
|
+
* Updated to ActiveSupport 2.0.1
|
24
|
+
* documentation, documentation, documentation
|
25
|
+
* many other things as well...
|
26
|
+
|
27
|
+
|
28
|
+
|
data/MIT-LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Copyright (c) 2006-2007, Regents of the University of Colorado.
|
2
2
|
Developer:: Simon Chiang, Biomolecular Structure Program
|
3
|
-
Support::
|
3
|
+
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
6
6
|
software and associated documentation files (the "Software"), to deal in the Software
|
data/README
CHANGED
@@ -1,22 +1,48 @@
|
|
1
|
-
= Tap
|
1
|
+
= Tap (Task Application)
|
2
2
|
|
3
|
-
|
3
|
+
A framework for creating configurable, distributable, and easy-to-use tasks and workflow applications.
|
4
|
+
|
5
|
+
See the {website}[http://tap.rubyforge.org] for more information and tutorials.
|
4
6
|
|
5
7
|
== Description
|
6
8
|
|
7
|
-
Tap
|
8
|
-
|
9
|
-
|
9
|
+
Tap provides a framework facilitaing the definition, configuration, and joining of tasks into workflows.
|
10
|
+
Tap provides a lot of framework niceties like generators and libraries geared towards testing tasks,
|
11
|
+
generating documentation, as well as task execution and distribution. Tasks are immediately available
|
12
|
+
from the comand line through though the 'tap' command.
|
13
|
+
|
14
|
+
Running a task named 'sample/task' is simply:
|
15
|
+
|
16
|
+
% tap run sample/task
|
17
|
+
|
18
|
+
Packaging tasks into an executables can be accomplished using {rubyscript2exe}[http://rubyforge.org/projects/rubyscript2exe/].
|
19
|
+
First you generate a packaging script, then use rubyscript2exe to make the executable.
|
20
|
+
|
21
|
+
% tap generate package sample "run sample/task"
|
22
|
+
% rubyscript2exe pkg/sample.rb
|
23
|
+
|
24
|
+
The result is a fully contained, documented executable that runs on other computers
|
25
|
+
of the same platform, without Tap or even Ruby[http://www.ruby-lang.org/en/] being installed.
|
26
|
+
|
27
|
+
Additional Notes:
|
28
|
+
|
29
|
+
- Tap can incorporate and run Rake[http://rake.rubyforge.org/] tasks as well as Tap tasks.
|
30
|
+
- Tap task libraries are designed for distribution as gems.
|
31
|
+
- Tap is tested on both MRI (the standard Ruby interpreter) and JRuby[http://jruby.codehaus.org/].
|
10
32
|
|
11
|
-
|
12
|
-
|
13
|
-
|
33
|
+
=== Bugs/Known Issues
|
34
|
+
|
35
|
+
- The threading model for executing multithreaded tasks does not currently make shared resources
|
36
|
+
like Tap::App completely thread-safe and should be considered *experimental*. If you're concerned,
|
37
|
+
don't multithread your tasks.
|
38
|
+
- Some inconsequential tests on JRuby fail due to bugs in JRuby itself.
|
39
|
+
- TDoc documentation is still under development. You may find small typographic bugs.
|
14
40
|
|
15
41
|
== Info
|
16
42
|
|
17
43
|
Copyright (c) 2006-2007, Regents of the University of Colorado.
|
18
|
-
Developer:: Simon Chiang, Biomolecular Structure Program
|
19
|
-
Support::
|
44
|
+
Developer:: {Simon Chiang}[http://bahuvrihi.wordpress.com], {Biomolecular Structure Program}[http://biomol.uchsc.edu/], {Hansen Lab}[http://hsc-proteomics.uchsc.edu/hansenlab/]
|
45
|
+
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
20
46
|
Licence:: MIT-Style
|
21
47
|
|
22
48
|
== Installation
|
@@ -24,48 +50,50 @@ Licence:: MIT-Style
|
|
24
50
|
Tap is available as a gem on RubyForge[http://rubyforge.org/projects/tap]. Use:
|
25
51
|
|
26
52
|
% gem install tap
|
27
|
-
|
28
|
-
In addition, Tap may be installed through a {Firefox Add-On}[http://prosperity.uchsc.edu/tap/addon].
|
29
|
-
The Tap add-on provides shortcuts for starting and running Tap in a console or as a server.
|
30
53
|
|
31
54
|
== Usage
|
32
55
|
|
33
|
-
|
56
|
+
<b>See the tutorial for information on using Tap programatically.</b>
|
34
57
|
|
35
|
-
|
36
|
-
|
37
|
-
This command generates the standard file structure for Tap, including folders for
|
38
|
-
configurations, data, task libraries, documentation, and testing. Navigate into your
|
39
|
-
folder and generate a task:
|
58
|
+
Begin by creating a tap root directory structure:
|
40
59
|
|
41
|
-
% tap
|
60
|
+
% tap generate root /path/to/root
|
61
|
+
% cd /path/to/root
|
42
62
|
|
43
|
-
|
44
|
-
see the basics of task creation. Everthing is set up for the test run, so give it a go:
|
45
|
-
|
46
|
-
% tap say_hello "from me"
|
47
|
-
# => I[hh::mm::ss] message hello from me!
|
63
|
+
Make a task:
|
48
64
|
|
49
|
-
|
65
|
+
% tap generate task sample/task
|
50
66
|
|
51
|
-
|
52
|
-
|
53
|
-
|
67
|
+
Test the task (in fact invokes the rake test task):
|
68
|
+
|
69
|
+
% tap run test
|
54
70
|
|
55
|
-
|
71
|
+
Get help for the task:
|
56
72
|
|
57
|
-
% tap --
|
73
|
+
% tap run -- sample/task --help
|
74
|
+
|
75
|
+
Run the task, setting the 'key' configuration and passing some inputs:
|
58
76
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
% tap run -- sample/task --label=processing one two
|
78
|
+
|
79
|
+
Package the task into an executable (rubyscript2exe must be installed
|
80
|
+
and may not work on platforms where rubyscript2exe is squirrelly, ie
|
81
|
+
OS X)
|
82
|
+
|
83
|
+
% tap generate package sample "run sample/task"
|
84
|
+
% rubyscript2exe pkg/sample.rb
|
85
|
+
|
86
|
+
== Credits
|
87
|
+
|
88
|
+
A great deal of inspiration came from other excellent open-source projects including
|
89
|
+
Rake[http://rake.rubyforge.org] and {Ruby on Rails}[http://www.rubyonrails.org].
|
90
|
+
I also want to give credit to RubyGems[http://www.rubygems.org] and
|
91
|
+
RubyForge[http://rubyforge.org] because they are crucial parts of what make Ruby a
|
92
|
+
great language to work with.
|
93
|
+
|
94
|
+
Thanks to my advisor {Dr. Kirk Hansen}[http://hsc-proteomics.uchsc.edu/hansenlab/]
|
95
|
+
for his patience in letting me work on this project, and for putting together an awesome
|
96
|
+
lab.
|
97
|
+
|
98
|
+
Most of all I would like to thank my family for their never-ending support.
|
71
99
|
|
data/Rakefile
CHANGED
@@ -3,31 +3,15 @@ require 'rake/testtask'
|
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
|
6
|
+
$:.unshift "./lib"
|
7
|
+
require 'tap/version.rb'
|
8
|
+
|
6
9
|
desc 'Default: Run tests.'
|
7
10
|
task :default => :test
|
8
11
|
|
9
|
-
desc 'Run tests.'
|
10
|
-
Rake::TestTask.new(:test) do |t|
|
11
|
-
t.libs << 'lib'
|
12
|
-
t.pattern = File.join('test', ENV['subset'] || '', ENV['pattern'] || '**/*_test.rb')
|
13
|
-
t.verbose = true
|
14
|
-
t.warning = true
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Generate documentation.'
|
18
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
19
|
-
rdoc.rdoc_dir = 'rdoc'
|
20
|
-
rdoc.title = 'tap'
|
21
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
22
|
-
rdoc.rdoc_files.include('README', 'MIT-LICENSE')
|
23
|
-
rdoc.rdoc_files.include('lib/tap/**/*.rb')
|
24
|
-
end
|
25
|
-
|
26
12
|
#
|
27
13
|
# Gem specification
|
28
14
|
#
|
29
|
-
require './lib/tap/version.rb'
|
30
|
-
|
31
15
|
Gem::manage_gems
|
32
16
|
|
33
17
|
spec = Gem::Specification.new do |s|
|
@@ -37,8 +21,8 @@ spec = Gem::Specification.new do |s|
|
|
37
21
|
s.email = "simon.chiang@uchsc.edu"
|
38
22
|
s.homepage = "http://rubyforge.org/projects/tap/"
|
39
23
|
s.platform = Gem::Platform::RUBY
|
40
|
-
s.summary = "
|
41
|
-
s.files =
|
24
|
+
s.summary = "A framework for configurable, distributable, and easy-to-use tasks and workflow applications."
|
25
|
+
s.files = File.read("Manifest.txt").split("\n").select {|f| f !~ /^\s*#/ && File.file?(f) }
|
42
26
|
s.require_path = "lib"
|
43
27
|
s.autorequire = "tap"
|
44
28
|
s.test_file = "test/tap_test_suite.rb"
|
@@ -48,67 +32,100 @@ spec = Gem::Specification.new do |s|
|
|
48
32
|
|
49
33
|
s.has_rdoc = true
|
50
34
|
s.rdoc_options << '--title' << 'Tap - Task Application' << '--main' << 'README'
|
51
|
-
s.extra_rdoc_files = ["README", "MIT-LICENSE"]
|
52
|
-
s.add_dependency("
|
53
|
-
s.add_dependency("activesupport", ">=1.4.2")
|
35
|
+
s.extra_rdoc_files = ["README", "MIT-LICENSE", "History", "Tutorial"]
|
36
|
+
s.add_dependency("activesupport", ">=2.0.1")
|
54
37
|
end
|
55
38
|
|
56
39
|
Rake::GemPackageTask.new(spec) do |pkg|
|
57
40
|
pkg.need_tar = true
|
58
41
|
end
|
59
42
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
task :install_gem => [:package] do
|
66
|
-
#task :install_gem => [:clean, :package] do
|
67
|
-
sh "#{'sudo ' unless WINDOZE}gem install pkg/*.gem"
|
43
|
+
desc 'Prints the gem manifest.'
|
44
|
+
task :print_manifest do
|
45
|
+
spec.files.each do |file|
|
46
|
+
puts file
|
47
|
+
end
|
68
48
|
end
|
69
49
|
|
70
|
-
desc
|
71
|
-
|
72
|
-
|
73
|
-
|
50
|
+
desc 'Run tests.'
|
51
|
+
Rake::TestTask.new(:test) do |t|
|
52
|
+
t.pattern = File.join('test', ENV['subset'] || '', ENV['pattern'] || '**/*_test.rb')
|
53
|
+
t.verbose = true
|
54
|
+
t.warning = true
|
55
|
+
end
|
74
56
|
|
75
|
-
|
76
|
-
|
57
|
+
#
|
58
|
+
# Documentation tasks
|
59
|
+
#
|
77
60
|
|
78
|
-
|
61
|
+
desc 'Generate documentation.'
|
62
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
63
|
+
require 'tap/support/tdoc'
|
64
|
+
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = 'tap'
|
67
|
+
rdoc.template = 'tap/support/tdoc/tdoc_html_template'
|
68
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--fmt' << 'tdoc'
|
69
|
+
rdoc.rdoc_files.include('README', 'MIT-LICENSE', "History", "Tutorial")
|
70
|
+
rdoc.rdoc_files.include('lib/tap/**/*.rb')
|
79
71
|
end
|
80
72
|
|
81
|
-
desc '
|
82
|
-
task :
|
83
|
-
require '
|
73
|
+
desc 'Generate website.'
|
74
|
+
task :website => [:rdoc] do |t|
|
75
|
+
require 'tap/root'
|
76
|
+
require 'redcloth'
|
77
|
+
require 'erb'
|
84
78
|
|
85
|
-
#
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if $DEBUG then
|
91
|
-
puts "release_id = rf.add_release #{rubyforge_name.inspect}, #{name.inspect}, #{version.inspect}, \"#{pkg}.tgz\""
|
92
|
-
puts "rf.add_file #{rubyforge_name.inspect}, #{name.inspect}, release_id, \"#{pkg}.gem\""
|
79
|
+
# setup some variables
|
80
|
+
page_template = File.read('website/page.erb')
|
81
|
+
output_dir = "pkg/website-#{Tap::VERSION}"
|
82
|
+
pages = FileList.new('website/pages/**/*.txt') do |list|
|
83
|
+
list.exclude /_sub\.txt$/
|
93
84
|
end
|
85
|
+
|
86
|
+
# remove existing dir, move in or create pages
|
87
|
+
rm_r output_dir if File.exists?(output_dir)
|
88
|
+
mkdir_p output_dir
|
89
|
+
cp "website/index.html", File.join(output_dir, "index.html")
|
90
|
+
cp_r "website/images", File.join(output_dir, "images")
|
91
|
+
cp_r "website/stylesheets", File.join(output_dir, "stylesheets")
|
92
|
+
cp_r "rdoc", File.join(output_dir, "rdoc")
|
93
|
+
|
94
|
+
pages.each do |source|
|
95
|
+
base = Tap::Root.relative_filepath("./website/pages", source).chomp(".txt")
|
96
|
+
sub_source = source.chomp(".txt") + "_sub.txt"
|
97
|
+
|
98
|
+
@title = base.capitalize
|
99
|
+
@content_main = RedCloth.new(File.read(source)).to_html
|
100
|
+
@content_sub = File.exists?(sub_source) ? RedCloth.new(File.read(sub_source)).to_html : ""
|
101
|
+
|
102
|
+
target = File.join(output_dir, base + ".html")
|
103
|
+
File.open(target, "w") do |file|
|
104
|
+
file << ERB.new(page_template).result
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
94
109
|
|
95
|
-
|
96
|
-
|
97
|
-
|
110
|
+
#
|
111
|
+
# Hoe tasks
|
112
|
+
#
|
98
113
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
114
|
+
desc 'Install the package as a gem'
|
115
|
+
task :install_gem => [:package] do
|
116
|
+
sh "#{'sudo ' unless WINDOZE}gem install pkg/*.gem"
|
117
|
+
end
|
103
118
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
files = "#{pkg}.gem"
|
119
|
+
desc "Publish Website to RubyForge"
|
120
|
+
task :publish_website => [:website] do
|
121
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
122
|
+
host = "#{config["username"]}@rubyforge.org"
|
109
123
|
|
110
|
-
|
111
|
-
|
124
|
+
rsync_args = "-v -c -r"
|
125
|
+
remote_dir = "/var/www/gforge-projects/tap"
|
126
|
+
local_dir = "pkg/website-#{Tap::VERSION}"
|
127
|
+
|
128
|
+
sh %{rsync #{rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
|
112
129
|
end
|
113
130
|
|
114
131
|
desc 'Show information about the gem.'
|
data/Tutorial
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
= Tutorial
|
2
|
+
|
3
|
+
<b>Under Construction!</b>
|
4
|
+
|
5
|
+
== Overview
|
6
|
+
|
7
|
+
=== Tasks
|
8
|
+
|
9
|
+
# insert task image
|
10
|
+
|
11
|
+
Tap tasks are designed to be modular: they can be configured, they take inputs, and they
|
12
|
+
produce results. On a programatic level this system is convenient for joining tasks into
|
13
|
+
workflows using condition and decision blocks. On an application level, the task structure
|
14
|
+
makes it easy to incorporate tasks into configurable, user-ready scripts.
|
15
|
+
|
16
|
+
A task is structured like this:
|
17
|
+
|
18
|
+
module Sample
|
19
|
+
# == Documentation
|
20
|
+
# This documentation is available in RDoc, as well as from the
|
21
|
+
# command line, if you were to run it through tap, like this:
|
22
|
+
# % tap run -- sample/task --help
|
23
|
+
#
|
24
|
+
# === Usage
|
25
|
+
# By default, usage info comes up as well...
|
26
|
+
#
|
27
|
+
class Task < Tap::Task
|
28
|
+
|
29
|
+
# Configurations are defined like this. In this format,
|
30
|
+
# this comment is used in generating customized RDoc
|
31
|
+
# documenting the configurations and any accessors created
|
32
|
+
# for them. The default 'config' creates a config reader
|
33
|
+
# and writer.
|
34
|
+
config :config_name, "default value" #-- a command line comment
|
35
|
+
|
36
|
+
# Process receives each input from the command line
|
37
|
+
# and can do arbitrary work to make an output.
|
38
|
+
def process(input)
|
39
|
+
# ... log a message and return the input plus one ...
|
40
|
+
log "#{self.name} recieved #{input}"
|
41
|
+
input + 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Once instantiated, tasks can be joined into a workflow by the Tap application, which is
|
47
|
+
made to work with a standard directory structure. The basics looks like this:
|
48
|
+
|
49
|
+
tap
|
50
|
+
|- Rakefile
|
51
|
+
|- ReadMe.txt
|
52
|
+
|- config
|
53
|
+
| `- sample
|
54
|
+
| `- task.yml # a default config file for Sample::Task
|
55
|
+
|- lib
|
56
|
+
| `- sample
|
57
|
+
| `- task.rb # a class file like above
|
58
|
+
|- tap.yml # a configuration file for Tap::App
|
59
|
+
`- test
|
60
|
+
|- sample
|
61
|
+
| `- task_test.rb # a test file for Sample::Task
|
62
|
+
|- tap_test_helper.rb
|
63
|
+
`- tap_test_suite.rb
|
64
|
+
|
65
|
+
All task instances have a name, which by default serves as the relative filepath from an
|
66
|
+
application directory to assoicated files. So for instance when the application instantiates
|
67
|
+
a task by the name 'sample/task' it sets the task configs from 'config/sample/task.yml'.
|
68
|
+
Any number of configurations can exist for a single task class. In addition, Tap knows
|
69
|
+
how to load unknown task classes by name or via mapping...
|
70
|
+
|
71
|
+
app = Tap:App.instance
|
72
|
+
app.root = '/path/to/tap'
|
73
|
+
|
74
|
+
# set up a mapping between a name and a task class
|
75
|
+
app.map("two" => Sample::Task)
|
76
|
+
|
77
|
+
# the task method looks up and instantiates the proper
|
78
|
+
# task, with the input name and configuration (if the
|
79
|
+
# config file exists)
|
80
|
+
|
81
|
+
t1 = app.task("sample/task") # configured from 'config/sample/task.yml'
|
82
|
+
t2 = app.task("task_two") # configured from 'config/task_two.yml'
|
83
|
+
|
84
|
+
# the idea is the same if you manually make a task...
|
85
|
+
# t3 is configured from 'config/task_three.yml'
|
86
|
+
|
87
|
+
t3 = Tap::Task.new("task_three") do |task, input|
|
88
|
+
log "#{task.name} recieved #{input}"
|
89
|
+
input + 1
|
90
|
+
end
|
91
|
+
|
92
|
+
t1.class # => Sample::Task
|
93
|
+
t2.class # => Sample::Task
|
94
|
+
t3.class # => Tap::Task
|
95
|
+
|
96
|
+
=== Workflows
|
97
|
+
|
98
|
+
# insert workflow image
|
99
|
+
|
100
|
+
Once tasks are instantiated, they can be joined into workflows, and run with inputs.
|
101
|
+
Tasks are joined using a condition block and a decision (on_complete) block that runs
|
102
|
+
when the task finishes. Arbitrary workflow logic can be used to join tasks in this
|
103
|
+
way, but by default Tap supports sequencing, forking, and merging.
|
104
|
+
|
105
|
+
--
|
106
|
+
...and multithread execution of tasks.
|
107
|
+
Add this when multithreading works properly.
|
108
|
+
++
|
109
|
+
|
110
|
+
# using the same tasks as above...
|
111
|
+
|
112
|
+
app.sequence(t1, t2, t3)
|
113
|
+
app.run(t1, 0)
|
114
|
+
|
115
|
+
# the log output is like this:
|
116
|
+
#
|
117
|
+
# I[10:38:06] sample/task recieved 0
|
118
|
+
# I[10:38:06] task_two recieved 1
|
119
|
+
# I[10:38:06] task_three recieved 2
|
120
|
+
# I[10:38:06] sample/task recieved 3
|
121
|
+
|
122
|
+
Workflows can be constructed as tasks themselves, and joined with other tasks and
|
123
|
+
workflows in the same fashion.
|
124
|
+
|
125
|
+
== Running Tap from the Command Line
|
126
|
+
|
127
|
+
The tap command is a gateway for the execution of other subcommands. To
|
128
|
+
get general help for tap, type:
|
129
|
+
|
130
|
+
% tap --help
|
131
|
+
|
132
|
+
The tap command does only a few things. It's main responsibility is configuring
|
133
|
+
Tap::App.instance with 'tap.yml' from the present working directory, if it exists,
|
134
|
+
running any before/after scripts specified therein, and passing control to the
|
135
|
+
specifed subcommand. Subcommand help can be obtained using:
|
136
|
+
|
137
|
+
% tap [subcommand] --help
|
138
|
+
|
139
|
+
=== run
|
140
|
+
|
141
|
+
The run subcommand configures, enqueues, and executes tasks. Run has a rich
|
142
|
+
syntax allowing the full specification of any number of tasks which simplifies
|
143
|
+
under most circumstances. Several examples illustrate the key points:
|
144
|
+
|
145
|
+
% tap run sample/task
|
146
|
+
% tap run -- sample/task
|
147
|
+
|
148
|
+
Both of these commands are equivalent but the second statement is a more
|
149
|
+
formally correct syntax. The option break '--' signifies the start of a task (or
|
150
|
+
equivalently a break in processing statements) and is essential to pass options
|
151
|
+
to the task:
|
152
|
+
|
153
|
+
% tap run --debug -- sample/task --key=value
|
154
|
+
|
155
|
+
Here run recieves the '--debug' option and sample/task recieves the
|
156
|
+
'--key=value' option'. Inputs work the same way. By default task options
|
157
|
+
are used to set configurations, and inputs enqued to the task. For example:
|
158
|
+
|
159
|
+
% tap run -- sample/task --key=value one -- another/task two three
|
160
|
+
|
161
|
+
Specifies the following:
|
162
|
+
|
163
|
+
t1 = app.task('sample/task', :key => 'value')
|
164
|
+
app.queue.enq(t1, 'one')
|
165
|
+
|
166
|
+
t2 = app.task('another/task')
|
167
|
+
app.queue.enq(t2, 'two', 'three')
|
168
|
+
|
169
|
+
Any number of tasks, configurations, and inputs may be specified in this
|
170
|
+
way. As a special note, rake tasks can be specifed as well. If the app cannot
|
171
|
+
find a tap task by the specified name, rake is loaded (using the same loading
|
172
|
+
rules as the rake command) and run tries to find a corresponding rake task.
|
173
|
+
ENV options can be specified in the rake statement.
|
174
|
+
|
175
|
+
% tap run -- sample/task --key=value one -- rake_task KEY=value
|
176
|
+
|
177
|
+
Non-string inputs can be provided as well. If the input begins with "---\n"
|
178
|
+
then it will be loaded as YAML into an object before being passed to a task.
|
179
|
+
The syntax can be a lot to type, but is very handy to have around especially
|
180
|
+
when tap is lauched automatically or from some other program. The following
|
181
|
+
enques 'sample/task' with a hash input, {'number' => 1}.
|
182
|
+
|
183
|
+
% tap -- sample/task "---
|
184
|
+
> number: 1"
|
185
|
+
|
186
|
+
On Windows, you need to pull some tricks to get newlines into your argument.
|
187
|
+
Cleverly use a caret to ignore the next line feed:
|
188
|
+
|
189
|
+
% tap -- sample/task '---^
|
190
|
+
More?
|
191
|
+
More? key: value'
|
192
|
+
|
193
|
+
Notice that hitting enter every other line is what actually puts the "\n" into the
|
194
|
+
parameter. Keep using carets to enter more lines. The syntax on Windows isn't
|
195
|
+
exactly pretty, but it works.
|
196
|
+
|
197
|
+
=== generate/destroy
|
198
|
+
|
199
|
+
Generate and destory are subcommands launching generators. They use the
|
200
|
+
same back-end code as Rails generators, and are used identically. By default
|
201
|
+
Tap provides generators for:
|
202
|
+
|
203
|
+
- root (creating the basic Tap directory structure)
|
204
|
+
- task
|
205
|
+
- file_task
|
206
|
+
- workflow
|
207
|
+
- config
|
208
|
+
- script
|
209
|
+
- package
|
210
|
+
|
211
|
+
--
|
212
|
+
Consult the help for each of these generators:
|
213
|
+
|
214
|
+
% tap [generate/destroy] [generator] --help
|
215
|
+
|
216
|
+
++
|
217
|
+
|
218
|
+
=== console
|
219
|
+
|
220
|
+
Console opens an irb session with Tap loaded. Here you can directly interact
|
221
|
+
with your code. Console defines a variable 'app' referencing Tap::App.instance,
|
222
|
+
for easy access.
|
223
|
+
|
224
|
+
% tap console
|
225
|
+
irb(main):001:0> app.log(:hello)
|
226
|
+
I[17:18:53] hello
|
227
|
+
=> true
|
228
|
+
irb(main):002:0>
|
229
|
+
|
230
|
+
For actively testing your code, remember that many of your files will be loaded
|
231
|
+
using Dependencies (from ActiveSupport). You can modify your code, clear the
|
232
|
+
dependencies, and observe the changes within a single session. The irb
|
233
|
+
command is:
|
234
|
+
|
235
|
+
irb(main):001:0>Dependencies.clear
|