tap 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/History +28 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README +71 -43
  4. data/Rakefile +81 -64
  5. data/Tutorial +235 -0
  6. data/bin/tap +80 -44
  7. data/lib/tap.rb +41 -12
  8. data/lib/tap/app.rb +243 -246
  9. data/lib/tap/file_task.rb +357 -118
  10. data/lib/tap/generator.rb +88 -29
  11. data/lib/tap/generator/generators/config/config_generator.rb +4 -2
  12. data/lib/tap/generator/generators/config/templates/config.erb +1 -2
  13. data/lib/tap/generator/generators/file_task/file_task_generator.rb +3 -18
  14. data/lib/tap/generator/generators/file_task/templates/task.erb +22 -15
  15. data/lib/tap/generator/generators/file_task/templates/test.erb +13 -2
  16. data/{test/test/inference_methods/test_assert_files_exist/input/input_1.txt → lib/tap/generator/generators/generator/USAGE} +0 -0
  17. data/lib/tap/generator/generators/generator/generator_generator.rb +21 -0
  18. data/lib/tap/generator/generators/generator/templates/generator.erb +23 -0
  19. data/lib/tap/generator/generators/generator/templates/usage.erb +1 -0
  20. data/{test/test/inference_methods/test_assert_files_exist/input/input_2.txt → lib/tap/generator/generators/package/USAGE} +0 -0
  21. data/lib/tap/generator/generators/package/package_generator.rb +38 -0
  22. data/lib/tap/generator/generators/package/templates/package.erb +186 -0
  23. data/lib/tap/generator/generators/root/root_generator.rb +14 -9
  24. data/lib/tap/generator/generators/root/templates/Rakefile +20 -14
  25. data/{test/test/inference_methods/test_infer_glob/expected/file.yml → lib/tap/generator/generators/root/templates/ReadMe.txt} +0 -0
  26. data/lib/tap/generator/generators/root/templates/tap.yml +82 -0
  27. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -1
  28. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +2 -1
  29. data/{test/test/inference_methods/test_infer_glob/expected/file_1.txt → lib/tap/generator/generators/script/USAGE} +0 -0
  30. data/lib/tap/generator/generators/script/script_generator.rb +17 -0
  31. data/lib/tap/generator/generators/script/templates/script.erb +42 -0
  32. data/lib/tap/generator/generators/task/task_generator.rb +1 -1
  33. data/lib/tap/generator/generators/task/templates/task.erb +24 -16
  34. data/lib/tap/generator/generators/task/templates/test.erb +13 -17
  35. data/lib/tap/generator/generators/workflow/templates/task.erb +10 -10
  36. data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
  37. data/lib/tap/generator/generators/workflow/workflow_generator.rb +3 -18
  38. data/lib/tap/root.rb +108 -146
  39. data/lib/tap/script.rb +362 -0
  40. data/lib/tap/script/console.rb +28 -0
  41. data/lib/tap/script/destroy.rb +13 -1
  42. data/lib/tap/script/generate.rb +13 -1
  43. data/lib/tap/script/run.rb +100 -57
  44. data/lib/tap/support/batch_queue.rb +0 -3
  45. data/lib/tap/support/logger.rb +6 -3
  46. data/lib/tap/support/rake.rb +54 -0
  47. data/lib/tap/support/task_configuration.rb +169 -0
  48. data/lib/tap/support/tdoc.rb +198 -0
  49. data/lib/tap/support/tdoc/config_attr.rb +338 -0
  50. data/lib/tap/support/tdoc/tdoc_html_generator.rb +38 -0
  51. data/lib/tap/support/tdoc/tdoc_html_template.rb +42 -0
  52. data/lib/tap/support/versions.rb +33 -1
  53. data/lib/tap/task.rb +339 -227
  54. data/lib/tap/test.rb +86 -128
  55. data/lib/tap/test/env_vars.rb +16 -5
  56. data/lib/tap/test/file_methods.rb +373 -0
  57. data/lib/tap/test/subset_methods.rb +299 -180
  58. data/lib/tap/version.rb +2 -1
  59. data/lib/tap/workflow.rb +2 -0
  60. data/test/app/lib/app_test_task.rb +1 -0
  61. data/test/app_test.rb +327 -83
  62. data/test/check/binding_eval.rb +23 -0
  63. data/test/check/define_method_check.rb +22 -0
  64. data/test/check/dependencies_check.rb +175 -0
  65. data/test/check/inheritance_check.rb +22 -0
  66. data/test/file_task_test.rb +524 -291
  67. data/test/{test/inference_methods/test_infer_glob/expected/file_2.txt → root/glob/one.txt} +0 -0
  68. data/test/root/glob/two.txt +0 -0
  69. data/test/root_test.rb +330 -262
  70. data/test/script_test.rb +194 -0
  71. data/test/support/audit_test.rb +5 -2
  72. data/test/support/combinator_test.rb +10 -10
  73. data/test/support/rake_test.rb +35 -0
  74. data/test/support/task_configuration_test.rb +272 -0
  75. data/test/support/tdoc_test.rb +363 -0
  76. data/test/support/templater_test.rb +2 -2
  77. data/test/support/versions_test.rb +32 -0
  78. data/test/tap_test_helper.rb +39 -0
  79. data/test/task_base_test.rb +115 -0
  80. data/test/task_class_test.rb +56 -4
  81. data/test/task_execute_test.rb +29 -0
  82. data/test/task_test.rb +89 -70
  83. data/test/test/env_vars_test.rb +48 -0
  84. data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/file.txt +0 -0
  85. data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/folder/file.txt +0 -0
  86. data/test/test/{inference_methods → file_methods}/test_assert_expected/input/file.txt +0 -0
  87. data/test/test/{inference_methods → file_methods}/test_assert_expected/input/folder/file.txt +0 -0
  88. data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
  89. data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
  90. data/test/test/file_methods/test_assert_output_files_equal/expected/one.txt +1 -0
  91. data/test/test/file_methods/test_assert_output_files_equal/expected/two.txt +1 -0
  92. data/test/test/file_methods/test_assert_output_files_equal/input/one.txt +1 -0
  93. data/test/test/file_methods/test_assert_output_files_equal/input/two.txt +1 -0
  94. data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_1.txt +0 -0
  95. data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_2.txt +0 -0
  96. data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_1.txt +0 -0
  97. data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_2.txt +0 -0
  98. data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
  99. data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
  100. data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
  101. data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
  102. data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
  103. data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
  104. data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_1.yml +0 -0
  105. data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_2.yml +0 -0
  106. data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_1.yml +0 -0
  107. data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_2.yml +0 -0
  108. data/test/test/file_methods_test.rb +204 -0
  109. data/test/test/subset_methods_test.rb +93 -33
  110. data/test/test/test_assert_expected_result_files/expected/task/name/a.txt +1 -0
  111. data/test/test/test_assert_expected_result_files/expected/task/name/b.txt +1 -0
  112. data/test/test/test_assert_expected_result_files/input/a.txt +1 -0
  113. data/test/test/test_assert_expected_result_files/input/b.txt +1 -0
  114. data/test/test/test_file_task_test/expected/one.txt +1 -0
  115. data/test/test/test_file_task_test/expected/two.txt +1 -0
  116. data/test/test/test_file_task_test/input/one.txt +1 -0
  117. data/test/test/test_file_task_test/input/two.txt +1 -0
  118. data/test/test_test.rb +143 -3
  119. data/test/workflow_test.rb +2 -0
  120. data/vendor/rails_generator.rb +56 -0
  121. data/vendor/rails_generator/base.rb +263 -0
  122. data/vendor/rails_generator/commands.rb +581 -0
  123. data/vendor/rails_generator/generated_attribute.rb +42 -0
  124. data/vendor/rails_generator/lookup.rb +209 -0
  125. data/vendor/rails_generator/manifest.rb +53 -0
  126. data/vendor/rails_generator/options.rb +143 -0
  127. data/vendor/rails_generator/scripts.rb +83 -0
  128. data/vendor/rails_generator/scripts/destroy.rb +7 -0
  129. data/vendor/rails_generator/scripts/generate.rb +7 -0
  130. data/vendor/rails_generator/scripts/update.rb +12 -0
  131. data/vendor/rails_generator/simple_logger.rb +46 -0
  132. data/vendor/rails_generator/spec.rb +44 -0
  133. metadata +180 -196
  134. data/lib/tap/generator/generators/root/templates/app.yml +0 -19
  135. data/lib/tap/generator/generators/root/templates/config/process_tap_request.yml +0 -4
  136. data/lib/tap/generator/generators/root/templates/lib/process_tap_request.rb +0 -26
  137. data/lib/tap/generator/generators/root/templates/public/images/nav.jpg +0 -0
  138. data/lib/tap/generator/generators/root/templates/public/stylesheets/color.css +0 -57
  139. data/lib/tap/generator/generators/root/templates/public/stylesheets/layout.css +0 -108
  140. data/lib/tap/generator/generators/root/templates/public/stylesheets/normalize.css +0 -40
  141. data/lib/tap/generator/generators/root/templates/public/stylesheets/typography.css +0 -21
  142. data/lib/tap/generator/generators/root/templates/server/config/environment.rb +0 -60
  143. data/lib/tap/generator/generators/root/templates/server/lib/tasks/clear_database_prerequisites.rake +0 -5
  144. data/lib/tap/generator/generators/root/templates/server/test/test_helper.rb +0 -53
  145. data/lib/tap/script/server.rb +0 -12
  146. data/lib/tap/support/rap.rb +0 -38
  147. data/lib/tap/test/inference_methods.rb +0 -298
  148. data/test/task/config/task_with_config.yml +0 -1
  149. 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:: UCHSC School of Medicine Deans Academic Enrichment Fund
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
- Task Application: A framework for configurable, file based, web ready workflow applications.
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 fundamentally is a basic workflow engine wherein you can define tasks and rules to pass
8
- outputs from one task into another. Tap uses a standardized folder layout to assist in
9
- configuring tasks and managing files.
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
- Tap can be run from the console or from an integrated web server built on the camping[link to camping]
12
- framework. The Tap Server makes it easy to build tools and share them within an organization,
13
- or with a wider audience as you please.
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:: UCHSC School of Medicine Deans Academic Enrichment Fund
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
- Begin by creating a Tap folder:
56
+ <b>See the tutorial for information on using Tap programatically.</b>
34
57
 
35
- % tap --generate root path/to/folder
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 --generate task say_hello
60
+ % tap generate root /path/to/root
61
+ % cd /path/to/root
42
62
 
43
- The task generator makes a stub configuration file, task, and test. Open up each file to
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
- You can start an IRB session to interact with your tap tasks...
65
+ % tap generate task sample/task
50
66
 
51
- % tap --console
52
- > Tap::App.run(:say_hello, "from me")
53
- # => I[hh::mm::ss] message hello from me!
67
+ Test the task (in fact invokes the rake test task):
68
+
69
+ % tap run test
54
70
 
55
- Or start the server...
71
+ Get help for the task:
56
72
 
57
- % tap --server
73
+ % tap run -- sample/task --help
74
+
75
+ Run the task, setting the 'key' configuration and passing some inputs:
58
76
 
59
- Now you can go to {http://localhost:3000/tap}[http://localhost:3000/tap] to see your
60
- Tap Server in action.
61
-
62
- == Auditing
63
- == Notes
64
-
65
- Tap takes a simplified approach to workflows where the idea is to setup
66
- tasks, their configs, conditions, and on_complete behavior before running,
67
- and then to let the application act out this predefined logic. Changing
68
- task setup during execution can naturally cause unexpected behavior.
69
- Various safeguards should let you get away with this inadvisable practice,
70
- but on the other hand you may just thread lock the whole caboodle.
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 = "Framework for configurable, file-based applications."
41
- s.files = Dir.glob("{bin,test,lib}/**/*") + ["MIT-LICENSE", "README", "Rakefile"]
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("rails", ">= 1.2.3") # only for generators?
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
- # Hoe tasks
62
- #
63
-
64
- desc 'Install the package as a gem'
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 "Publish RDoc to RubyForge"
71
- task :publish_docs => [:clean, :docs] do
72
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
73
- host = "#{config["username"]}@rubyforge.org"
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
- remote_dir = "/var/www/gforge-projects/#{rubyforge_name}/#{remote_rdoc_dir}"
76
- local_dir = 'doc'
57
+ #
58
+ # Documentation tasks
59
+ #
77
60
 
78
- sh %{rsync #{rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
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 'Package and upload the release to rubyforge.'
82
- task :release => [:package] do |t|
83
- require 'rubyforge'
73
+ desc 'Generate website.'
74
+ task :website => [:rdoc] do |t|
75
+ require 'tap/root'
76
+ require 'redcloth'
77
+ require 'erb'
84
78
 
85
- #task :release => [:clean, :package] do |t|
86
- v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
87
- abort "Versions don't match #{v} vs #{spec.version}" if v != spec.version.to_s
88
- pkg = "pkg/#{spec.name}-#{spec.version}"
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
- rf = RubyForge.new
96
- puts "Logging in"
97
- rf.login
110
+ #
111
+ # Hoe tasks
112
+ #
98
113
 
99
- c = rf.userconfig
100
- c["release_notes"] = description if description
101
- c["release_changes"] = changes if changes
102
- c["preformatted"] = true
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
- #files = [(@need_tar ? "#{pkg}.tgz" : nil),
105
- # (@need_zip ? "#{pkg}.zip" : nil),
106
- # "#{pkg}.gem"].compact
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
- puts "Releasing #{name} v. #{version}"
111
- rf.add_release rubyforge_name, name, version, *files
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