drake 0.8.7.0.2.4 → 0.9.0.0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGES +77 -9
  3. data/{CHANGES.drake → CHANGES-drake} +6 -2
  4. data/MIT-LICENSE +2 -0
  5. data/{README → README.rdoc} +30 -18
  6. data/Rakefile +144 -130
  7. data/Rakefile-drake +67 -0
  8. data/TODO +1 -1
  9. data/bin/drake +2 -0
  10. data/doc/command_line_usage.rdoc +25 -11
  11. data/doc/glossary.rdoc +2 -2
  12. data/doc/jamis.rb +2 -2
  13. data/doc/parallel.rdoc +37 -29
  14. data/doc/proto_rake.rdoc +22 -22
  15. data/doc/rake.1.gz +0 -0
  16. data/doc/rakefile.rdoc +56 -33
  17. data/doc/rational.rdoc +6 -6
  18. data/doc/release_notes/rake-0.4.15.rdoc +1 -1
  19. data/doc/release_notes/rake-0.5.0.rdoc +1 -1
  20. data/doc/release_notes/rake-0.7.0.rdoc +1 -1
  21. data/doc/release_notes/rake-0.7.2.rdoc +3 -3
  22. data/doc/release_notes/rake-0.7.3.rdoc +2 -2
  23. data/doc/release_notes/rake-0.8.0.rdoc +1 -1
  24. data/doc/release_notes/rake-0.8.2.rdoc +3 -3
  25. data/doc/release_notes/rake-0.8.3.rdoc +2 -2
  26. data/doc/release_notes/rake-0.8.4.rdoc +1 -1
  27. data/doc/release_notes/rake-0.8.5.rdoc +1 -1
  28. data/doc/release_notes/rake-0.8.6.rdoc +1 -1
  29. data/doc/release_notes/rake-0.8.7.rdoc +1 -1
  30. data/doc/release_notes/rake-0.9.0.rdoc +112 -0
  31. data/install.rb +14 -12
  32. data/lib/rake.rb +31 -2527
  33. data/lib/rake/alt_system.rb +7 -6
  34. data/lib/rake/application.rb +626 -0
  35. data/lib/rake/classic_namespace.rb +1 -0
  36. data/lib/rake/clean.rb +2 -4
  37. data/lib/rake/cloneable.rb +25 -0
  38. data/lib/rake/contrib/compositepublisher.rb +2 -5
  39. data/lib/rake/contrib/ftptools.rb +5 -8
  40. data/lib/rake/contrib/publisher.rb +2 -8
  41. data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
  42. data/lib/rake/contrib/sshpublisher.rb +4 -6
  43. data/lib/rake/contrib/sys.rb +7 -25
  44. data/lib/rake/default_loader.rb +10 -0
  45. data/lib/rake/dsl.rb +2 -0
  46. data/lib/rake/dsl_definition.rb +143 -0
  47. data/lib/rake/early_time.rb +18 -0
  48. data/lib/rake/ext/core.rb +27 -0
  49. data/lib/rake/ext/module.rb +39 -0
  50. data/lib/rake/ext/string.rb +167 -0
  51. data/lib/rake/ext/time.rb +14 -0
  52. data/lib/rake/file_creation_task.rb +24 -0
  53. data/lib/rake/file_list.rb +403 -0
  54. data/lib/rake/file_task.rb +47 -0
  55. data/lib/rake/file_utils.rb +112 -0
  56. data/lib/rake/file_utils_ext.rb +142 -0
  57. data/lib/rake/gempackagetask.rb +6 -90
  58. data/lib/rake/invocation_chain.rb +51 -0
  59. data/lib/rake/invocation_exception_mixin.rb +16 -0
  60. data/lib/rake/loaders/makefile.rb +13 -15
  61. data/lib/rake/multi_task.rb +16 -0
  62. data/lib/rake/name_space.rb +25 -0
  63. data/lib/rake/packagetask.rb +13 -12
  64. data/lib/rake/parallel.rb +17 -28
  65. data/lib/rake/pathmap.rb +1 -0
  66. data/lib/rake/pseudo_status.rb +24 -0
  67. data/lib/rake/rake_module.rb +29 -0
  68. data/lib/rake/rake_test_loader.rb +10 -2
  69. data/lib/rake/rdoctask.rb +211 -190
  70. data/lib/rake/ruby182_test_unit_fix.rb +9 -7
  71. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  72. data/lib/rake/runtest.rb +4 -6
  73. data/lib/rake/task.rb +351 -0
  74. data/lib/rake/task_argument_error.rb +7 -0
  75. data/lib/rake/task_arguments.rb +74 -0
  76. data/lib/rake/task_manager.rb +307 -0
  77. data/lib/rake/tasklib.rb +1 -2
  78. data/lib/rake/testtask.rb +57 -27
  79. data/lib/rake/version.rb +13 -0
  80. data/lib/rake/win32.rb +4 -4
  81. data/test/contrib/test_sys.rb +8 -31
  82. data/test/data/access/Rakefile +33 -0
  83. data/test/data/comments/Rakefile +18 -0
  84. data/test/data/default/Rakefile +1 -1
  85. data/test/data/deprecated_import/Rakefile +1 -0
  86. data/test/data/dryrun/Rakefile +1 -1
  87. data/test/data/file_creation_task/Rakefile +1 -1
  88. data/test/data/namespace/Rakefile +9 -0
  89. data/test/data/rakelib/test1.rb +1 -0
  90. data/test/data/verbose/Rakefile +34 -0
  91. data/test/{filecreation.rb → file_creation.rb} +11 -7
  92. data/test/functional/functional_test.rb +25 -0
  93. data/test/{session_functional.rb → functional/session_based_tests.rb} +141 -23
  94. data/test/in_environment.rb +7 -5
  95. data/test/{test_application.rb → lib/application_test.rb} +331 -143
  96. data/test/{test_clean.rb → lib/clean_test.rb} +1 -0
  97. data/test/{test_definitions.rb → lib/definitions_test.rb} +4 -4
  98. data/test/lib/dsl_test.rb +52 -0
  99. data/test/{test_earlytime.rb → lib/earlytime_test.rb} +1 -2
  100. data/test/{test_extension.rb → lib/extension_test.rb} +2 -2
  101. data/test/{test_file_creation_task.rb → lib/file_creation_task_test.rb} +1 -1
  102. data/test/{test_file_task.rb → lib/file_task_test.rb} +9 -5
  103. data/test/{test_filelist.rb → lib/filelist_test.rb} +38 -24
  104. data/test/{test_fileutils.rb → lib/fileutils_test.rb} +27 -22
  105. data/test/{test_ftp.rb → lib/ftp_test.rb} +0 -0
  106. data/test/{test_invocation_chain.rb → lib/invocation_chain_test.rb} +0 -0
  107. data/test/{test_makefile_loader.rb → lib/makefile_loader_test.rb} +0 -0
  108. data/test/{test_multitask.rb → lib/multitask_test.rb} +3 -2
  109. data/test/{test_namespace.rb → lib/namespace_test.rb} +0 -0
  110. data/test/lib/package_task_test.rb +82 -0
  111. data/test/{test_parallel.rb → lib/parallel_test.rb} +5 -5
  112. data/test/{test_pathmap.rb → lib/pathmap_test.rb} +3 -2
  113. data/test/{test_pseudo_status.rb → lib/pseudo_status_test.rb} +0 -0
  114. data/test/{test_rake.rb → lib/rake_test.rb} +1 -1
  115. data/test/{test_rdoc_task.rb → lib/rdoc_task_test.rb} +19 -23
  116. data/test/{test_require.rb → lib/require_test.rb} +8 -2
  117. data/test/{test_rules.rb → lib/rules_test.rb} +4 -5
  118. data/test/{test_task_arguments.rb → lib/task_arguments_test.rb} +5 -5
  119. data/test/{test_task_manager.rb → lib/task_manager_test.rb} +15 -5
  120. data/test/{test_tasks.rb → lib/task_test.rb} +91 -28
  121. data/test/{test_tasklib.rb → lib/tasklib_test.rb} +0 -0
  122. data/test/{test_test_task.rb → lib/test_task_test.rb} +3 -3
  123. data/test/lib/testtask_test.rb +49 -0
  124. data/test/{test_top_level_functions.rb → lib/top_level_functions_test.rb} +5 -3
  125. data/test/{test_win32.rb → lib/win32_test.rb} +19 -0
  126. data/test/rake_test_setup.rb +6 -10
  127. data/test/ruby_version_test.rb +3 -0
  128. data/test/test_helper.rb +19 -0
  129. metadata +108 -66
  130. data/Rakefile.drake +0 -73
  131. data/test/functional.rb +0 -15
  132. data/test/test_package_task.rb +0 -118
data/Rakefile-drake ADDED
@@ -0,0 +1,67 @@
1
+
2
+ def git(*args)
3
+ sh "git", *args
4
+ end
5
+
6
+ task :drake_pull_mainline do
7
+ git "pull",
8
+ "--no-commit",
9
+ "git://github.com/jimweirich/rake.git",
10
+ "refs/heads/master:refs/heads/origin"
11
+ end
12
+
13
+ task :drake_check_directory do
14
+ unless `git status` =~ %r!nothing to commit \(working directory clean\)!
15
+ raise "Directory not clean"
16
+ end
17
+ end
18
+
19
+ task :drake_prerelease => [:clobber, :gemspec, :drake_check_directory] do
20
+ unless `git pull` =~ %r!Already up-to-date!
21
+ raise "New stuff from remote repository"
22
+ end
23
+ %w[github.com].each { |server|
24
+ cmd = "ping " + (
25
+ if Config::CONFIG["host"] =~ %r!darwin!
26
+ "-c2 #{server}"
27
+ else
28
+ "#{server} 2 2"
29
+ end
30
+ )
31
+ unless `#{cmd}` =~ %r!0% packet loss!
32
+ raise "No ping for #{server}"
33
+ end
34
+ }
35
+ end
36
+
37
+ task :drake_publish => :rdoc do
38
+ Dir.chdir("html") {
39
+ sh "scp", "-r", ".", "quix@rubyforge.org:/var/www/gforge-projects/drake"
40
+ }
41
+ git "branch", "-D", "gh-pages"
42
+ git "checkout", "--orphan", "gh-pages"
43
+ FileUtils.rm ".git/index"
44
+ git "clean", "-fdx", "-e", "html"
45
+ Dir["html/*"].each { |path|
46
+ FileUtils.mv path, "."
47
+ }
48
+ FileUtils.rmdir "html"
49
+ git "add", "."
50
+ git "commit", "-m", "generated by rdoc"
51
+ git "push", "-f", "origin", "gh-pages"
52
+ end
53
+
54
+ task :drake_finish_release do
55
+ git "tag", "drake-#{SPEC.version}"
56
+ git "push", "--tags", "origin", "master"
57
+ sh "gem", "push", gem
58
+ end
59
+
60
+ task :drake_release =>
61
+ [
62
+ :drake_prerelease,
63
+ :gem,
64
+ "test:all",
65
+ :drake_finish_release,
66
+ ]
67
+
data/TODO CHANGED
@@ -6,7 +6,7 @@ the rake-devel@rubyforge.org mailing list.
6
6
  === To Do
7
7
  * Need a nice API for accessing tasks in namespaces, namespaces in an app, etc.
8
8
  * Provide a way to disable -w warning mode.
9
- * Define a set of default rules that work in the absense of any Rakefile
9
+ * Define a set of default rules that work in the absence of any Rakefile
10
10
  * What about cyclic dependencies?
11
11
  * Java support utilities
12
12
  * Installation support utilities
data/bin/drake CHANGED
@@ -3,6 +3,8 @@
3
3
  #--
4
4
  # Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
5
5
  #
6
+ # Copyright (c) 2008-2011 James M. Lawrence
7
+ #
6
8
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
9
  # of this software and associated documentation files (the "Software"), to
8
10
  # deal in the Software without restriction, including without limitation the
@@ -9,7 +9,7 @@ Options are:
9
9
  [<tt><em>name</em>=<em>value</em></tt>]
10
10
  Set the environment variable <em>name</em> to <em>value</em>
11
11
  during the execution of the <b>rake</b> command. You can access
12
- the value by using ENV['<em>name</em>'].
12
+ the value by using ENV['<em>name</em>'].
13
13
 
14
14
  [<tt>--classic-namespace</tt> (-n)]
15
15
  Import the Task, FileTask, and FileCreateTask into the top-level
@@ -42,6 +42,8 @@ Options are:
42
42
 
43
43
  [<tt>--threads</tt> _number_ (-j)]
44
44
  Run up to N independent tasks simultaneously in separate threads.
45
+ If _number_ is not given, run as many tasks in parallel as the
46
+ dependencies allow.
45
47
 
46
48
  [<tt>--nosearch</tt> (-N)]
47
49
  Do not search for a Rakefile in parent directories.
@@ -63,11 +65,11 @@ Options are:
63
65
  [<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
64
66
  Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
65
67
 
66
- [<tt>--randomize</tt>[=_seed_]]
67
- Randomize the order of sibling prerequisites for each task. When
68
- _seed_ is given, <tt>srand(seed.hash)</tt> will be called so that
69
- the same permutations will be produced for subsequent runs with
70
- the same _seed_.
68
+ [<tt>--randomize</tt> _seed_]
69
+ Randomize the order of sibling prerequisites for each task. Runs
70
+ with the same _seed_ will produce the same sibling permutations.
71
+ If no _seed_ is given then one will be generated. _seed_ is
72
+ reported when Rake exits.
71
73
 
72
74
  [<tt>--require</tt> _name_ (-r)]
73
75
  Require _name_ before executing the Rakefile.
@@ -89,23 +91,35 @@ Options are:
89
91
  Use the project level Rakefile, ignoring the system-wide (global)
90
92
  rakefiles.
91
93
 
92
- [<tt>--tasks</tt> (-T)]
94
+ [<tt>--tasks</tt> <em>pattern</em> (-T)]
93
95
  Display a list of the major tasks and their comments. Comments
94
- are defined using the "desc" command.
96
+ are defined using the "desc" command. If a pattern is given, then
97
+ only tasks matching the pattern are displayed.
98
+
99
+ [<tt>--no-top-level-dsl</tt> (-X)]
100
+ Do not put the Rake DSL commands into the top level scope.
101
+
102
+ [<tt>--top-level-dsl</tt>]
103
+ Put the Rake DSL commands into the top level scope (default).
104
+
105
+ NOTE: Although currently Rake defaults to its DSL in the top level
106
+ scope, the plan is to deprecate this in the future and default ot
107
+ having the DSL commands *not* appear in the top level scope.
95
108
 
96
109
  [<tt>--trace</tt> (-t)]
97
110
  Turn on invoke/execute tracing. Also enable full backtrace on
98
111
  errors.
99
112
 
100
- [<tt>--usage</tt> (-h)]
101
- Display a usage message and exit.
102
-
103
113
  [<tt>--verbose</tt> (-v)]
104
114
  Echo the Sys commands to standard output.
105
115
 
106
116
  [<tt>--version</tt> (-V)]
107
117
  Display the program version and exit.
108
118
 
119
+ [<tt>--where</tt> <em>pattern</em> (-W)]
120
+ Display tasks that match <em>pattern</em> and the file and line
121
+ number where the task is defined.
122
+
109
123
  In addition, any command line option of the form
110
124
  <em>VAR</em>=<em>VALUE</em> will be added to the environment hash
111
125
  <tt>ENV</tt> and may be tested in the Rakefile.
data/doc/glossary.rdoc CHANGED
@@ -37,9 +37,9 @@
37
37
  not needed. This may change in the future.
38
38
 
39
39
  [<b>prerequisites</b>]
40
- Every task has a set (possiblity empty) of prerequisites. A
40
+ Every task has a set (possibly empty) of prerequisites. A
41
41
  prerequisite P to Task T is itself a task that must be invoked
42
- before Task T.
42
+ before Task T.
43
43
 
44
44
  [<b>rule</b>]
45
45
  A rule is a recipe for synthesizing a task when no task is
data/doc/jamis.rb CHANGED
@@ -183,7 +183,7 @@ h3, h4, h5, h6 {
183
183
  CSS
184
184
 
185
185
  XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
186
- <!DOCTYPE html
186
+ <!DOCTYPE html
187
187
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
188
188
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
189
189
  }
@@ -510,7 +510,7 @@ FILE_INDEX = XHTML_PREAMBLE + <<HTML
510
510
  <!--
511
511
  body {
512
512
  background-color: #EEE;
513
- font-family: #{FONTS};
513
+ font-family: #{FONTS};
514
514
  color: #000;
515
515
  margin: 0px;
516
516
  }
data/doc/parallel.rdoc CHANGED
@@ -29,8 +29,8 @@ short answer is probably that +multitask+ was easy to implement, while
29
29
  dynamically finding parallelizable tasks and safely executing them in
30
30
  separate threads requires a little more code.
31
31
 
32
- Rake now supports the -j option which does exactly this. To run up to
33
- three tasks in parallel,
32
+ Rake now supports the +-j+ option which does exactly this. To run up
33
+ to three tasks in parallel,
34
34
 
35
35
  % rake -j3
36
36
 
@@ -38,33 +38,40 @@ or equivalently,
38
38
 
39
39
  % rake --threads 3
40
40
 
41
+ Without a number,
42
+
43
+ % rake -j
44
+
45
+ means as many tasks as possible will run in parallel: the dependency
46
+ graph alone determines the number.
47
+
41
48
  == A Note on Dependencies
42
49
 
43
- Without +multitask+ or -j (or --randomize, explained below), Rake
44
- invokes tasks in a predetermined order. Rakefile authors inevitably
45
- come to rely on this order. Even though their dependency graph may be
46
- wide and hierarchical, the only graph which has ever been tested is
47
- linear: one which results from visiting each node in sequence.
50
+ Without +multitask+ or +-j+, Rake invokes tasks in a predetermined
51
+ order. Rakefile authors inevitably come to rely on this order. Even
52
+ though their dependency graph may be wide and hierarchical, the only
53
+ graph which has ever been tested is linear: one which results from
54
+ visiting each node in sequence.
48
55
 
49
56
  Consider
50
57
 
51
58
  task :a => [:x, :y, :z]
52
59
 
53
- When Rake runs in single-threaded mode (the default), _x_,_y_,_z_ will
54
- be invoked <em>in that order</em> before _a_ is invoked, assuming no
55
- other rules exist involving these tasks. However with -j _N_ for
56
- _N_ > 1, one should not expect any particular order of execution.
57
- Since there is no dependency specified between _x_,_y_,_z_ above, Rake
58
- is free to run them in any order.
60
+ When Rake runs in single-threaded mode (the default), tasks
61
+ _x_,_y_,_z_ will be invoked <em>in that order</em> before _a_ is
62
+ invoked, assuming no other rules exist involving these tasks. However
63
+ with +-j+ _N_ for _N_ > 1, one should not expect any
64
+ particular order of execution. Since there is no dependency specified
65
+ between _x_,_y_,_z_ above, Rake is free to run them in any order.
59
66
 
60
67
  The problem of underspecified dependencies plagues Makefiles as well
61
- (GNU make has supported -j for some time).
68
+ (GNU make has supported +-j+ for some time).
62
69
 
63
- == Migrating to -j
70
+ == Migrating to +-j+
64
71
 
65
- Suppose -j produces errors from insufficient dependencies in your
66
- Rakefile. Do you want to bother fixing them? If you are satisfied
67
- with your build time, then there is really no reason to use -j.
72
+ Suppose +-j+ produces errors from insufficient dependencies in your
73
+ Rakefile. Do you want to bother fixing them? If you are satisfied with
74
+ your build time then there is really no reason to use +-j+.
68
75
 
69
76
  If on the other hand your build takes twenty minutes to complete, you
70
77
  may be interested in getting the full dependency graph correct in
@@ -76,10 +83,10 @@ saying what you mean:
76
83
 
77
84
  % rake --randomize[=SEED]
78
85
 
79
- This will randomize the order of sibling prerequisites for each task.
80
- When SEED is given, <tt>srand(SEED.hash)</tt> will be called so that
81
- the same permutations will be produced for subsequent runs with the
82
- same SEED.
86
+ where the optional SEED is an integer. This will randomize the order
87
+ of sibling prerequisites for each task. Runs with the same SEED will
88
+ produce the same sibling permutations. If no SEED is given then one
89
+ will be generated. SEED is reported when Rake exits.
83
90
 
84
91
  Though this option may cause an error due to underspecified
85
92
  dependencies, with SEED at least it will be an error which is exactly
@@ -89,15 +96,15 @@ advantage of using a single thread.
89
96
  == Task#invoke inside Task#invoke
90
97
 
91
98
  Parallelizing tasks means surrendering control over the
92
- micro-management of their execution. Manually invoking tasks inside
99
+ micro-management of their execution. Manually invoking tasks inside
93
100
  other tasks is rather contrary to this notion, throwing a monkey
94
- wrench into the system. An exception will be raised when this is
95
- attempted in -j mode.
101
+ wrench into the system. An exception will be raised when this is
102
+ attempted in +-j+ mode.
96
103
 
97
- == What is the Difference Between -j and Multitask?
104
+ == What is the Difference Between +-j+ and Multitask?
98
105
 
99
106
  What if you replaced +task+ with +multitask+ everywhere in your
100
- Rakefile? Isn't that the same as -j?
107
+ Rakefile? Isn't that the same as +-j+?
101
108
 
102
109
  It is effectively the same when the number of tasks is small. However
103
110
  an all-multitask Rakefile becomes problematic as the number of tasks
@@ -107,6 +114,7 @@ Multitask blindly fires off N threads for the N prerequisites of a
107
114
  task.
108
115
 
109
116
  A simplistic +multitask+ setup for compiling 100 C files might spawn
110
- 100 threads running 100 compiler processes all at the same time. To
117
+ 100 threads running 100 compiler processes all at the same time. To
111
118
  reduce the load you could make several reasonably-sized multitasks
112
- then tie them together with a regular +task+. Or you could just use -j.
119
+ then tie them together with a regular +task+. Or you could just use
120
+ +-j+.
data/doc/proto_rake.rdoc CHANGED
@@ -4,54 +4,54 @@ This is the original 100 line prototype rake program.
4
4
 
5
5
  ---
6
6
  #!/usr/bin/env ruby
7
-
7
+
8
8
  require 'ftools'
9
-
9
+
10
10
  class Task
11
11
  TASKS = Hash.new
12
-
12
+
13
13
  attr_reader :prerequisites
14
-
14
+
15
15
  def initialize(task_name)
16
16
  @name = task_name
17
17
  @prerequisites = []
18
18
  @actions = []
19
19
  end
20
-
20
+
21
21
  def enhance(deps=nil, &block)
22
22
  @prerequisites |= deps if deps
23
23
  @actions << block if block_given?
24
24
  self
25
25
  end
26
-
26
+
27
27
  def name
28
28
  @name.to_s
29
29
  end
30
-
30
+
31
31
  def invoke
32
32
  @prerequisites.each { |n| Task[n].invoke }
33
33
  execute if needed?
34
34
  end
35
-
35
+
36
36
  def execute
37
37
  return if @triggered
38
38
  @triggered = true
39
39
  @actions.collect { |act| result = act.call(self) }.last
40
40
  end
41
-
41
+
42
42
  def needed?
43
43
  true
44
44
  end
45
-
45
+
46
46
  def timestamp
47
47
  Time.now
48
48
  end
49
-
49
+
50
50
  class << self
51
51
  def [](task_name)
52
52
  TASKS[intern(task_name)] or fail "Don't know how to rake #{task_name}"
53
53
  end
54
-
54
+
55
55
  def define_task(args, &block)
56
56
  case args
57
57
  when Hash
@@ -66,18 +66,18 @@ This is the original 100 line prototype rake program.
66
66
  deps = deps.collect {|d| intern(d) }
67
67
  get(task_name).enhance(deps, &block)
68
68
  end
69
-
69
+
70
70
  def get(task_name)
71
71
  name = intern(task_name)
72
72
  TASKS[name] ||= self.new(name)
73
73
  end
74
-
74
+
75
75
  def intern(task_name)
76
76
  (Symbol === task_name) ? task_name : task_name.intern
77
77
  end
78
78
  end
79
79
  end
80
-
80
+
81
81
  class FileTask < Task
82
82
  def needed?
83
83
  return true unless File.exist?(name)
@@ -85,25 +85,25 @@ This is the original 100 line prototype rake program.
85
85
  return false if latest_prereq.nil?
86
86
  timestamp < latest_prereq
87
87
  end
88
-
88
+
89
89
  def timestamp
90
90
  File.new(name.to_s).mtime
91
91
  end
92
92
  end
93
-
93
+
94
94
  def task(args, &block)
95
95
  Task.define_task(args, &block)
96
96
  end
97
-
97
+
98
98
  def file(args, &block)
99
99
  FileTask.define_task(args, &block)
100
100
  end
101
-
101
+
102
102
  def sys(cmd)
103
103
  puts cmd
104
104
  system(cmd) or fail "Command Failed: [#{cmd}]"
105
105
  end
106
-
106
+
107
107
  def rake
108
108
  begin
109
109
  here = Dir.pwd
@@ -119,9 +119,9 @@ This is the original 100 line prototype rake program.
119
119
  rescue Exception => ex
120
120
  puts "rake aborted ... #{ex.message}"
121
121
  puts ex.backtrace.find {|str| str =~ /Rakefile/ } || ""
122
- end
122
+ end
123
123
  end
124
-
124
+
125
125
  if __FILE__ == $0 then
126
126
  rake
127
127
  end
data/doc/rake.1.gz CHANGED
Binary file
data/doc/rakefile.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Rakefile Format (as of version 0.8.3)
1
+ = Rakefile Format (as of version 0.8.7)
2
2
 
3
3
  First of all, there is no special format for a Rakefile. A Rakefile
4
4
  contains executable Ruby code. Anything legal in a ruby script is
@@ -27,7 +27,7 @@ parameter that is the name of the task.
27
27
 
28
28
  === Tasks with Prerequisites
29
29
 
30
- Any prerequisites are given as a list (inclosed in square brackets)
30
+ Any prerequisites are given as a list (enclosed in square brackets)
31
31
  following the name and an arrow (=>).
32
32
 
33
33
  task :name => [:prereq1, :prereq2]
@@ -45,7 +45,7 @@ following ...
45
45
 
46
46
  Actions are defined by passing a block to the +task+ method. Any Ruby
47
47
  code can be placed in the block. The block may reference the task
48
- object via the block paramter..
48
+ object via the block parameter.
49
49
 
50
50
  task :name => [:prereq1, :prereq2] do |t|
51
51
  # actions (may reference t)
@@ -119,14 +119,14 @@ Rake allows parallel execution of prerequisites using the following syntax:
119
119
  end
120
120
 
121
121
  In this example, +copy_files+ is a normal rake task. Its actions are
122
- executed whereever all of its prerequisites are done. The big
122
+ executed whenever all of its prerequisites are done. The big
123
123
  difference is that the prerequisites (+copy_src+, +copy_bin+ and
124
124
  +copy_doc+) are executed in parallel. Each of the prerequisites are
125
125
  run in their own Ruby thread, possibly allowing faster overall runtime.
126
126
 
127
127
  === Secondary Prerequisites
128
128
 
129
- If any of the primary prerequites of a multitask have common secondary
129
+ If any of the primary prerequisites of a multitask have common secondary
130
130
  prerequisites, all of the primary/parallel prerequisites will wait
131
131
  until the common prerequisites have been run.
132
132
 
@@ -154,7 +154,7 @@ user must do whatever is necessary to prevent race conditions.
154
154
 
155
155
  Rake now supports the command-line option -j for automatically
156
156
  detecting non-dependent tasks and safely executing them in parallel.
157
- See parallel.rdoc.
157
+ See parallel.rdoc[http://quix.github.com/rake/files/doc/parallel_rdoc.html].
158
158
 
159
159
  == Tasks with Arguments
160
160
 
@@ -189,6 +189,22 @@ argument string should be quoted. Something like this:
189
189
  (Quoting rules vary between operating systems and shells, so make sure
190
190
  you consult the proper docs for your OS/shell).
191
191
 
192
+ === Tasks Arguments and the Environment
193
+
194
+ Task argument values can also be picked up from the environment. For
195
+ example, if the "release" task expected a parameter named
196
+ "release_version", then either
197
+
198
+ rake release[0.8.2]
199
+
200
+ or
201
+
202
+ RELEASE_VERSION rake release
203
+
204
+ will work. Environment variable names must either match the task
205
+ parameter exactly, or match an all-uppercase version of the task
206
+ parameter.
207
+
192
208
  === Tasks that Expect Parameters
193
209
 
194
210
  Parameters are only given to tasks that are setup to expect them. In
@@ -201,10 +217,10 @@ declared as:
201
217
  task :name, [:first_name, :last_name]
202
218
 
203
219
  The first argument is still the name of the task (:name in this case).
204
- The next to argumements are the names of the parameters expected by
220
+ The next two arguments are the names of the parameters expected by
205
221
  :name in an array (:first_name and :last_name in the example).
206
222
 
207
- To access the values of the paramters, the block defining the task
223
+ To access the values of the parameters, the block defining the task
208
224
  behaviour can now accept a second parameter:
209
225
 
210
226
  task :name, [:first_name, :last_name] do |t, args|
@@ -216,7 +232,8 @@ The first argument of the block "t" is always bound to the current
216
232
  task object. The second argument "args" is an open-struct like object
217
233
  that allows access to the task arguments. Extra command line
218
234
  arguments to a task are ignored. Missing command line arguments are
219
- given the nil value.
235
+ picked up from matching environment variables. If there are no
236
+ matching environment variables, they are given the nil value.
220
237
 
221
238
  If you wish to specify default values for the arguments, you can use
222
239
  the with_defaults method in the task body. Here is the above example
@@ -245,11 +262,12 @@ for tasks with arguments. For example:
245
262
  There is an older format for declaring task parameters that omitted
246
263
  the task argument array and used the :needs keyword to introduce the
247
264
  dependencies. That format is still supported for compatibility, but
248
- is not recommended for use.
265
+ is not recommended for use. The older format may be dropped in future
266
+ versions of rake.
249
267
 
250
- == Accessing Task Programatically
268
+ == Accessing Task Programmatically
251
269
 
252
- Sometimes it is useful to manipulate tasks programatically in a
270
+ Sometimes it is useful to manipulate tasks programmatically in a
253
271
  Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
254
272
  <tt>Rake::Task</tt>.
255
273
 
@@ -266,7 +284,7 @@ actions.
266
284
 
267
285
  task :dont do
268
286
  Rake::Task[:doit].clear
269
- end
287
+ end
270
288
 
271
289
  Running this example:
272
290
 
@@ -275,7 +293,7 @@ Running this example:
275
293
  DONE
276
294
  $ rake dont doit
277
295
  (in /Users/jim/working/git/rake/x)
278
- $
296
+ $
279
297
 
280
298
  The ability to programmatically manipulate tasks gives rake very
281
299
  powerful meta-programming capabilities w.r.t. task execution, but
@@ -300,7 +318,7 @@ Rake is able to find a file named "mycode.c", it will automatically
300
318
  create a task that builds "mycode.o" from "mycode.c".
301
319
 
302
320
  If the file "mycode.c" does not exist, rake will attempt
303
- to recursively synthesize a rule for it.
321
+ to recursively synthesize a rule for it.
304
322
 
305
323
  When a task is synthesized from a rule, the +source+ attribute of the
306
324
  task is set to the matching source file. This allows us to write
@@ -318,7 +336,7 @@ The following rule is equivalent to the example above.
318
336
  proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') }
319
337
  ]) do |t|
320
338
  sh "cc #{t.source} -c -o #{t.name}"
321
- end
339
+ end
322
340
 
323
341
  <b>NOTE:</b> Because of a _quirk_ in Ruby syntax, parenthesis are
324
342
  required on *rule* when the first argument is a regular expression.
@@ -328,7 +346,7 @@ The following rule might be used for Java files ...
328
346
  rule '.java' => [
329
347
  proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
330
348
  ] do |t|
331
- java_compile(t.source, t.name)
349
+ java_compile(t.source, t.name)
332
350
  end
333
351
 
334
352
  <b>NOTE:</b> +java_compile+ is a hypothetical method that invokes the
@@ -346,12 +364,17 @@ invoked. This make generated dependency files difficult to use. By
346
364
  the time rake gets around to updating the dependencies file, it is too
347
365
  late to load it.
348
366
 
349
- The +import+ command addresses this by specifying a file to be loaded
350
- _after_ the main rakefile is loaded, but _before_ any targets on the
351
- command line are specified. In addition, if the file name matches an
352
- explicit task, that task is invoked before loading the file. This
353
- allows dependency files to be generated and used in a single rake
354
- command invocation.
367
+ The +Rake.import+ command addresses this by specifying a file to be
368
+ loaded _after_ the main rakefile is loaded, but _before_ any targets
369
+ on the command line are invoked. In addition, if the file name
370
+ matches an explicit task, that task is invoked before loading the
371
+ file. This allows dependency files to be generated and used in a
372
+ single rake command invocation.
373
+
374
+ <b>NOTE:</b> Starting in Rake version 0.9.0, the top level +import+
375
+ command is deprecated and we recommend using the scoped
376
+ "+Rake.import+" command mentioned above. Future versions of Rake will
377
+ drop support for the top level +import+ command.
355
378
 
356
379
  === Example:
357
380
 
@@ -361,7 +384,7 @@ command invocation.
361
384
  sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
362
385
  end
363
386
 
364
- import ".depends.mf"
387
+ Rake.import ".depends.mf"
365
388
 
366
389
  If ".depends" does not exist, or is out of date w.r.t. the source
367
390
  files, a new ".depends" file is generated using +makedepend+ before
@@ -380,9 +403,9 @@ then you need to use the +desc+ command to describe the task.
380
403
  task :package => [ ... ] do ... end
381
404
 
382
405
  The "-T" switch (or "--tasks" if you like to spell things out) will
383
- display a list of tasks that have a defined comment. If you use
384
- +desc+ to describe your major tasks, you have a semi-automatic way of
385
- generating a summary of your Rake file.
406
+ display a list of tasks that have a description. If you use +desc+ to
407
+ describe your major tasks, you have a semi-automatic way of generating
408
+ a summary of your Rake file.
386
409
 
387
410
  traken$ rake -T
388
411
  (in /home/.../rake)
@@ -409,7 +432,7 @@ common for task names to begin to clash. For example, if you might
409
432
  have a main program and a set of sample programs built by a single
410
433
  Rakefile. By placing the tasks related to the main program in one
411
434
  namespace, and the tasks for building the sample programs in a
412
- different namespace, the task names will not will not interfer with
435
+ different namespace, the task names will not will not interfere with
413
436
  each other.
414
437
 
415
438
  For example:
@@ -435,7 +458,7 @@ Nested namespaces are supported, so
435
458
 
436
459
  Note that the name given in the +task+ command is always the unadorned
437
460
  task name without any namespace prefixes. The +task+ command always
438
- defines a task in the current namespace.
461
+ defines a task in the current namespace.
439
462
 
440
463
  === FileTasks
441
464
 
@@ -505,17 +528,17 @@ Or give it a glob pattern:
505
528
 
506
529
  == Odds and Ends
507
530
 
508
- === do/end verses { }
531
+ === do/end versus { }
509
532
 
510
533
  Blocks may be specified with either a +do+/+end+ pair, or with curly
511
534
  braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the
512
535
  actions for tasks and rules. Because the rakefile idiom tends to
513
- leave off parenthesis on the task/file/rule methods, unusual
536
+ leave off parentheses on the task/file/rule methods, unusual
514
537
  ambiguities can arise when using curly braces.
515
538
 
516
539
  For example, suppose that the method +object_files+ returns a list of
517
540
  object files in a project. Now we use +object_files+ as the
518
- prerequistes in a rule specified with actions in curly braces.
541
+ prerequisites in a rule specified with actions in curly braces.
519
542
 
520
543
  # DON'T DO THIS!
521
544
  file "prog" => object_files {
@@ -537,4 +560,4 @@ This is the proper way to specify the task ...
537
560
 
538
561
  == See
539
562
 
540
- * README -- Main documentation for Rake.
563
+ * README.rdoc -- Main documentation for Rake.