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
@@ -0,0 +1,16 @@
1
+ module Rake
2
+ module InvocationExceptionMixin
3
+ # Return the invocation chain (list of Rake tasks) that were in
4
+ # effect when this exception was detected by rake. May be null if
5
+ # no tasks were active.
6
+ def chain
7
+ @rake_invocation_chain ||= nil
8
+ end
9
+
10
+ # Set the invocation chain in effect when this exception was
11
+ # detected.
12
+ def chain=(value)
13
+ @rake_invocation_chain = value
14
+ end
15
+ end
16
+ end
@@ -1,21 +1,19 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  module Rake
4
2
 
5
3
  # Makefile loader to be used with the import file loader.
6
4
  class MakefileLoader
7
- SPACE_MARK = "__ __"
5
+ include Rake::DSL
6
+
7
+ SPACE_MARK = "\0"
8
8
 
9
9
  # Load the makefile dependencies in +fn+.
10
10
  def load(fn)
11
- open(fn) do |mf|
12
- lines = mf.read
13
- lines.gsub!(/\\ /, SPACE_MARK)
14
- lines.gsub!(/#[^\n]*\n/m, "")
15
- lines.gsub!(/\\\n/, ' ')
16
- lines.split("\n").each do |line|
17
- process_line(line)
18
- end
11
+ lines = File.read fn
12
+ lines.gsub!(/\\ /, SPACE_MARK)
13
+ lines.gsub!(/#[^\n]*\n/m, "")
14
+ lines.gsub!(/\\\n/, ' ')
15
+ lines.each_line do |line|
16
+ process_line(line)
19
17
  end
20
18
  end
21
19
 
@@ -23,17 +21,17 @@ module Rake
23
21
 
24
22
  # Process one logical line of makefile data.
25
23
  def process_line(line)
26
- file_tasks, args = line.split(':')
24
+ file_tasks, args = line.split(':', 2)
27
25
  return if args.nil?
28
26
  dependents = args.split.map { |d| respace(d) }
29
- file_tasks.strip.split.each do |file_task|
27
+ file_tasks.scan(/\S+/) do |file_task|
30
28
  file_task = respace(file_task)
31
29
  file file_task => dependents
32
30
  end
33
31
  end
34
-
32
+
35
33
  def respace(str)
36
- str.gsub(/#{SPACE_MARK}/, ' ')
34
+ str.tr SPACE_MARK, ' '
37
35
  end
38
36
  end
39
37
 
@@ -0,0 +1,16 @@
1
+ module Rake
2
+
3
+ # Same as a regular task, but the immediate prerequisites are done in
4
+ # parallel using Ruby threads.
5
+ #
6
+ class MultiTask < Task
7
+ private
8
+ def invoke_prerequisites(args, invocation_chain)
9
+ threads = @prerequisites.collect { |p|
10
+ Thread.new(p) { |r| application[r, @scope].invoke_with_call_chain(args, invocation_chain) }
11
+ }
12
+ threads.each { |t| t.join }
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,25 @@
1
+ module Rake
2
+
3
+ # The NameSpace class will lookup task names in the the scope
4
+ # defined by a +namespace+ command.
5
+ #
6
+ class NameSpace
7
+
8
+ # Create a namespace lookup object using the given task manager
9
+ # and the list of scopes.
10
+ def initialize(task_manager, scope_list)
11
+ @task_manager = task_manager
12
+ @scope = scope_list.dup
13
+ end
14
+
15
+ # Lookup a task named +name+ in the namespace.
16
+ def [](name)
17
+ @task_manager.lookup(name, @scope)
18
+ end
19
+
20
+ # Return the list of tasks defined in this and nested namespaces.
21
+ def tasks
22
+ @task_manager.tasks_in_scope(@scope)
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,4 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Define a package task libarary to aid in the definition of
1
+ # Define a package task library to aid in the definition of
4
2
  # redistributable package files.
5
3
 
6
4
  require 'rake'
@@ -25,13 +23,13 @@ module Rake
25
23
  # of date.
26
24
  #
27
25
  # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
28
- # Create a gzipped tar package (if <em>need_tar</em> is true).
26
+ # Create a gzipped tar package (if <em>need_tar</em> is true).
29
27
  #
30
28
  # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</b>]
31
- # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
29
+ # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
32
30
  #
33
31
  # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</b>]
34
- # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
32
+ # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
35
33
  #
36
34
  # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
37
35
  # Create a zip package archive (if <em>need_zip</em> is true).
@@ -74,7 +72,10 @@ module Rake
74
72
  # Zip command for zipped archives. The default is 'zip'.
75
73
  attr_accessor :zip_command
76
74
 
77
- # Create a Package Task with the given name and version.
75
+ # Create a Package Task with the given name and version. Use +:noversion+
76
+ # as the version to build a package without a version or to provide a
77
+ # fully-versioned package name.
78
+
78
79
  def initialize(name=nil, version=nil)
79
80
  init(name, version)
80
81
  yield self if block_given?
@@ -102,11 +103,11 @@ module Rake
102
103
 
103
104
  desc "Build all the packages"
104
105
  task :package
105
-
106
+
106
107
  desc "Force a rebuild of the package files"
107
108
  task :repackage => [:clobber_package, :package]
108
-
109
- desc "Remove package products"
109
+
110
+ desc "Remove package products"
110
111
  task :clobber_package do
111
112
  rm_r package_dir rescue nil
112
113
  end
@@ -127,7 +128,7 @@ module Rake
127
128
  end
128
129
  end
129
130
  end
130
-
131
+
131
132
  if need_zip
132
133
  task :package => ["#{package_dir}/#{zip_file}"]
133
134
  file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
@@ -159,7 +160,7 @@ module Rake
159
160
  def package_name
160
161
  @version ? "#{@name}-#{@version}" : @name
161
162
  end
162
-
163
+
163
164
  def package_dir_path
164
165
  "#{package_dir}/#{package_name}"
165
166
  end
data/lib/rake/parallel.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  # arguments. A computation tree is then built with the gathered
10
10
  # tasks.
11
11
  #
12
- # Note that prerequisites are context-dependent; it is therefore not
12
+ # Note that prerequisites are context-dependent. It is therefore not
13
13
  # possible to create a 1-to-1 mapping between Rake::Tasks and
14
14
  # CompTree::Nodes.
15
15
  #
@@ -24,9 +24,6 @@ module Rake
24
24
  # Tasks collected during the dry-run phase.
25
25
  attr_reader :tasks
26
26
 
27
- # Prevent invoke inside invoke.
28
- attr_reader :mutex
29
-
30
27
  def initialize
31
28
  @tasks = Hash.new
32
29
  @mutex = Mutex.new
@@ -64,14 +61,14 @@ module Rake
64
61
  #
65
62
  def compute(root_task, threads)
66
63
  CompTree.build do |driver|
67
- # keep this around for optimization
68
- needed_prereq_names = Array.new
69
-
70
64
  @tasks.each_pair do |task, (task_args, prereqs)|
71
- # if a prereq is not needed then it didn't get into @tasks
72
- needed_prereq_names.clear
65
+ needed_prereq_names = []
66
+
73
67
  prereqs.each do |prereq|
74
- needed_prereq_names << prereq.name if @tasks.has_key? prereq
68
+ # if a prereq is not needed then it didn't get into @tasks
69
+ if @tasks.has_key? prereq
70
+ needed_prereq_names << prereq.name
71
+ end
75
72
  end
76
73
 
77
74
  # define a computation node which executes the task
@@ -99,7 +96,8 @@ module Rake
99
96
  # Called from Task#invoke.
100
97
  #
101
98
  def invoke_parallel(*task_args)
102
- application.parallel.invoke(application.options.threads, self, *task_args)
99
+ application.parallel.
100
+ invoke(application.options.threads, self, *task_args)
103
101
  end
104
102
 
105
103
  #
@@ -107,25 +105,16 @@ module Rake
107
105
  #
108
106
  # Called from Task#invoke_with_call_chain.
109
107
  #
110
- def invoke_with_call_chain_collector(task_args, new_chain, previous_chain)
111
- prereqs = invoke_prerequisites_collector(task_args, new_chain)
112
- parallel = application.parallel
113
- if needed? or prereqs.any? { |p| parallel.tasks[p] }
114
- parallel.tasks[self] = [task_args, prereqs]
108
+ def collect_for_parallel_execution(task_args, new_chain, previous_chain)
109
+ # call Task#invoke_prerequisites directly (avoid overrides)
110
+ prereqs = Task.instance_method(:invoke_prerequisites).
111
+ bind(self).call(task_args, new_chain)
112
+
113
+ tasks = application.parallel.tasks
114
+ if needed? or prereqs.any? { |p| tasks[p] }
115
+ tasks[self] = [task_args, prereqs]
115
116
  end
116
117
  end
117
-
118
- #
119
- # Dry-run invoke prereqs and return the prereq instances.
120
- # This also serves to avoid MultiTask#invoke_prerequisites.
121
- #
122
- # Called from Task#invoke_with_call_chain_collector.
123
- #
124
- def invoke_prerequisites_collector(task_args, invocation_chain)
125
- @prerequisites.map { |n|
126
- invoke_prerequisite(n, task_args, invocation_chain)
127
- }
128
- end
129
118
  end
130
119
  end
131
120
 
@@ -0,0 +1 @@
1
+ require 'rake/ext/string'
@@ -0,0 +1,24 @@
1
+ module Rake
2
+
3
+ ####################################################################
4
+ # Exit status class for times the system just gives us a nil.
5
+ class PseudoStatus
6
+ attr_reader :exitstatus
7
+ def initialize(code=0)
8
+ @exitstatus = code
9
+ end
10
+ def to_i
11
+ @exitstatus << 8
12
+ end
13
+ def >>(n)
14
+ to_i >> n
15
+ end
16
+ def stopped?
17
+ false
18
+ end
19
+ def exited?
20
+ true
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'rake/application'
2
+
3
+ module Rake
4
+
5
+ # Rake module singleton methods.
6
+ #
7
+ class << self
8
+ # Current Rake Application
9
+ def application
10
+ @application ||= Rake::Application.new
11
+ end
12
+
13
+ # Set the current Rake application object.
14
+ def application=(app)
15
+ @application = app
16
+ end
17
+
18
+ # Return the original directory where the Rake application was started.
19
+ def original_dir
20
+ application.original_dir
21
+ end
22
+
23
+ # Load a rakefile.
24
+ def load_rakefile(path)
25
+ load(path)
26
+ end
27
+ end
28
+
29
+ end
@@ -1,5 +1,13 @@
1
- #!/usr/bin/env ruby
1
+ require 'rake'
2
2
 
3
3
  # Load the test files from the command line.
4
4
 
5
- ARGV.each { |f| load f unless f =~ /^-/ }
5
+ ARGV.each do |f|
6
+ next if f =~ /^-/
7
+
8
+ if f =~ /\*/
9
+ FileList[f].to_a.each { |fn| require File.expand_path(fn) }
10
+ else
11
+ require File.expand_path(f)
12
+ end
13
+ end
data/lib/rake/rdoctask.rb CHANGED
@@ -1,209 +1,230 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rake'
4
- require 'rake/tasklib'
5
-
6
- module Rake
7
-
8
- # Create a documentation task that will generate the RDoc files for
9
- # a project.
10
- #
11
- # The RDocTask will create the following targets:
12
- #
13
- # [<b><em>rdoc</em></b>]
14
- # Main task for this RDOC task.
15
- #
16
- # [<b>:clobber_<em>rdoc</em></b>]
17
- # Delete all the rdoc files. This target is automatically
18
- # added to the main clobber target.
19
- #
20
- # [<b>:re<em>rdoc</em></b>]
21
- # Rebuild the rdoc files from scratch, even if they are not out
22
- # of date.
23
- #
24
- # Simple Example:
25
- #
26
- # Rake::RDocTask.new do |rd|
27
- # rd.main = "README.rdoc"
28
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
29
- # end
30
- #
31
- # The +rd+ object passed to the block is an RDocTask object. See the
32
- # attributes list for the RDocTask class for available customization options.
33
- #
34
- # == Specifying different task names
35
- #
36
- # You may wish to give the task a different name, such as if you are
37
- # generating two sets of documentation. For instance, if you want to have a
38
- # development set of documentation including private methods:
39
- #
40
- # Rake::RDocTask.new(:rdoc_dev) do |rd|
41
- # rd.main = "README.doc"
42
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
43
- # rd.options << "--all"
44
- # end
45
- #
46
- # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
47
- # :re<em>rdoc_dev</em>.
48
- #
49
- # If you wish to have completely different task names, then pass a Hash as
50
- # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
51
- # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
52
- # For example:
53
- #
54
- # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
55
- #
56
- # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
57
- # <tt>:rdoc:force</tt>.
58
- #
59
- class RDocTask < TaskLib
60
- # Name of the main, top level task. (default is :rdoc)
61
- attr_accessor :name
62
-
63
- # Name of directory to receive the html output files. (default is "html")
64
- attr_accessor :rdoc_dir
65
-
66
- # Title of RDoc documentation. (defaults to rdoc's default)
67
- attr_accessor :title
68
-
69
- # Name of file to be used as the main, top level file of the
70
- # RDoc. (default is none)
71
- attr_accessor :main
72
-
73
- # Name of template to be used by rdoc. (defaults to rdoc's default)
74
- attr_accessor :template
75
-
76
- # List of files to be included in the rdoc generation. (default is [])
77
- attr_accessor :rdoc_files
78
-
79
- # Additional list of options to be passed rdoc. (default is [])
80
- attr_accessor :options
81
-
82
- # Whether to run the rdoc process as an external shell (default is false)
83
- attr_accessor :external
84
-
85
- attr_accessor :inline_source
86
-
87
- # Create an RDoc task with the given name. See the RDocTask class overview
88
- # for documentation.
89
- def initialize(name = :rdoc) # :yield: self
90
- if name.is_a?(Hash)
91
- invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
92
- if !invalid_options.empty?
93
- raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
1
+ # rake/rdoctask is deprecated in favor of rdoc/task
2
+
3
+ warn 'rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)'
4
+
5
+ require 'rubygems'
6
+
7
+ begin
8
+ gem 'rdoc'
9
+ require 'rdoc'
10
+ require 'rdoc/task'
11
+ rescue LoadError, Gem::LoadError
12
+ end
13
+
14
+ if defined?(RDoc::Task) then
15
+ module Rake
16
+ RDocTask = RDoc::Task unless const_defined? :RDocTask
17
+ end
18
+ else
19
+ require 'rake'
20
+ require 'rake/tasklib'
21
+
22
+ module Rake
23
+
24
+ # NOTE: Rake::RDocTask is deprecated in favor of RDoc:Task which is included
25
+ # in RDoc 2.4.2+. Use require 'rdoc/task' to require it.
26
+ #
27
+ # Create a documentation task that will generate the RDoc files for
28
+ # a project.
29
+ #
30
+ # The RDocTask will create the following targets:
31
+ #
32
+ # [<b><em>rdoc</em></b>]
33
+ # Main task for this RDOC task.
34
+ #
35
+ # [<b>:clobber_<em>rdoc</em></b>]
36
+ # Delete all the rdoc files. This target is automatically
37
+ # added to the main clobber target.
38
+ #
39
+ # [<b>:re<em>rdoc</em></b>]
40
+ # Rebuild the rdoc files from scratch, even if they are not out
41
+ # of date.
42
+ #
43
+ # Simple Example:
44
+ #
45
+ # Rake::RDocTask.new do |rd|
46
+ # rd.main = "README.rdoc"
47
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
48
+ # end
49
+ #
50
+ # The +rd+ object passed to the block is an RDocTask object. See the
51
+ # attributes list for the RDocTask class for available customization options.
52
+ #
53
+ # == Specifying different task names
54
+ #
55
+ # You may wish to give the task a different name, such as if you are
56
+ # generating two sets of documentation. For instance, if you want to have a
57
+ # development set of documentation including private methods:
58
+ #
59
+ # Rake::RDocTask.new(:rdoc_dev) do |rd|
60
+ # rd.main = "README.doc"
61
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
62
+ # rd.options << "--all"
63
+ # end
64
+ #
65
+ # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
66
+ # :re<em>rdoc_dev</em>.
67
+ #
68
+ # If you wish to have completely different task names, then pass a Hash as
69
+ # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
70
+ # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
71
+ # For example:
72
+ #
73
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
74
+ #
75
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
76
+ # <tt>:rdoc:force</tt>.
77
+ #
78
+ class RDocTask < TaskLib
79
+ # Name of the main, top level task. (default is :rdoc)
80
+ attr_accessor :name
81
+
82
+ # Name of directory to receive the html output files. (default is "html")
83
+ attr_accessor :rdoc_dir
84
+
85
+ # Title of RDoc documentation. (defaults to rdoc's default)
86
+ attr_accessor :title
87
+
88
+ # Name of file to be used as the main, top level file of the
89
+ # RDoc. (default is none)
90
+ attr_accessor :main
91
+
92
+ # Name of template to be used by rdoc. (defaults to rdoc's default)
93
+ attr_accessor :template
94
+
95
+ # List of files to be included in the rdoc generation. (default is [])
96
+ attr_accessor :rdoc_files
97
+
98
+ # Additional list of options to be passed rdoc. (default is [])
99
+ attr_accessor :options
100
+
101
+ # Whether to run the rdoc process as an external shell (default is false)
102
+ attr_accessor :external
103
+
104
+ attr_accessor :inline_source
105
+
106
+ # Create an RDoc task with the given name. See the RDocTask class overview
107
+ # for documentation.
108
+ def initialize(name = :rdoc) # :yield: self
109
+ if name.is_a?(Hash)
110
+ invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
111
+ if !invalid_options.empty?
112
+ raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
113
+ end
94
114
  end
115
+
116
+ @name = name
117
+ @rdoc_files = Rake::FileList.new
118
+ @rdoc_dir = 'html'
119
+ @main = nil
120
+ @title = nil
121
+ @template = nil
122
+ @external = false
123
+ @inline_source = true
124
+ @options = []
125
+ yield self if block_given?
126
+ define
95
127
  end
96
-
97
- @name = name
98
- @rdoc_files = Rake::FileList.new
99
- @rdoc_dir = 'html'
100
- @main = nil
101
- @title = nil
102
- @template = nil
103
- @external = false
104
- @inline_source = true
105
- @options = []
106
- yield self if block_given?
107
- define
108
- end
109
-
110
- # Create the tasks defined by this task lib.
111
- def define
112
- if rdoc_task_name != "rdoc"
113
- desc "Build the RDOC HTML Files"
114
- else
115
- desc "Build the #{rdoc_task_name} HTML Files"
128
+
129
+ # Create the tasks defined by this task lib.
130
+ def define
131
+ if rdoc_task_name != "rdoc"
132
+ desc "Build the RDOC HTML Files"
133
+ else
134
+ desc "Build the #{rdoc_task_name} HTML Files"
135
+ end
136
+ task rdoc_task_name
137
+
138
+ desc "Force a rebuild of the RDOC files"
139
+ task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
140
+
141
+ desc "Remove rdoc products"
142
+ task clobber_task_name do
143
+ rm_r rdoc_dir rescue nil
144
+ end
145
+
146
+ task :clobber => [clobber_task_name]
147
+
148
+ directory @rdoc_dir
149
+ task rdoc_task_name => [rdoc_target]
150
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
151
+ rm_r @rdoc_dir rescue nil
152
+ @before_running_rdoc.call if @before_running_rdoc
153
+ args = option_list + @rdoc_files
154
+ if @external
155
+ argstring = args.join(' ')
156
+ sh %{ruby -Ivendor vendor/rd #{argstring}}
157
+ else
158
+ require 'rdoc/rdoc'
159
+ RDoc::RDoc.new.document(args)
160
+ end
161
+ end
162
+ self
116
163
  end
117
- task rdoc_task_name
118
-
119
- desc "Force a rebuild of the RDOC files"
120
- task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
121
-
122
- desc "Remove rdoc products"
123
- task clobber_task_name do
124
- rm_r rdoc_dir rescue nil
164
+
165
+ def option_list
166
+ result = @options.dup
167
+ result << "-o" << @rdoc_dir
168
+ result << "--main" << quote(main) if main
169
+ result << "--title" << quote(title) if title
170
+ result << "-T" << quote(template) if template
171
+ result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
172
+ result
125
173
  end
126
-
127
- task :clobber => [clobber_task_name]
128
-
129
- directory @rdoc_dir
130
- task rdoc_task_name => [rdoc_target]
131
- file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
132
- rm_r @rdoc_dir rescue nil
133
- @before_running_rdoc.call if @before_running_rdoc
134
- args = option_list + @rdoc_files
174
+
175
+ def quote(str)
135
176
  if @external
136
- argstring = args.join(' ')
137
- sh %{ruby -Ivendor vendor/rd #{argstring}}
177
+ "'#{str}'"
138
178
  else
139
- require 'rdoc/rdoc'
140
- RDoc::RDoc.new.document(args)
179
+ str
141
180
  end
142
181
  end
143
- self
144
- end
145
182
 
146
- def option_list
147
- result = @options.dup
148
- result << "-o" << @rdoc_dir
149
- result << "--main" << quote(main) if main
150
- result << "--title" << quote(title) if title
151
- result << "-T" << quote(template) if template
152
- result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
153
- result
154
- end
183
+ def option_string
184
+ option_list.join(' ')
185
+ end
155
186
 
156
- def quote(str)
157
- if @external
158
- "'#{str}'"
159
- else
160
- str
187
+ # The block passed to this method will be called just before running the
188
+ # RDoc generator. It is allowed to modify RDocTask attributes inside the
189
+ # block.
190
+ def before_running_rdoc(&block)
191
+ @before_running_rdoc = block
161
192
  end
162
- end
163
193
 
164
- def option_string
165
- option_list.join(' ')
166
- end
167
-
168
- # The block passed to this method will be called just before running the
169
- # RDoc generator. It is allowed to modify RDocTask attributes inside the
170
- # block.
171
- def before_running_rdoc(&block)
172
- @before_running_rdoc = block
173
- end
194
+ private
174
195
 
175
- private
176
-
177
- def rdoc_target
178
- "#{rdoc_dir}/index.html"
179
- end
180
-
181
- def rdoc_task_name
182
- case name
183
- when Hash
184
- (name[:rdoc] || "rdoc").to_s
185
- else
186
- name.to_s
196
+ def rdoc_target
197
+ "#{rdoc_dir}/index.html"
187
198
  end
188
- end
189
-
190
- def clobber_task_name
191
- case name
192
- when Hash
193
- (name[:clobber_rdoc] || "clobber_rdoc").to_s
194
- else
195
- "clobber_#{name}"
199
+
200
+ def rdoc_task_name
201
+ case name
202
+ when Hash
203
+ (name[:rdoc] || "rdoc").to_s
204
+ else
205
+ name.to_s
206
+ end
196
207
  end
197
- end
198
-
199
- def rerdoc_task_name
200
- case name
201
- when Hash
202
- (name[:rerdoc] || "rerdoc").to_s
203
- else
204
- "re#{name}"
208
+
209
+ def clobber_task_name
210
+ case name
211
+ when Hash
212
+ (name[:clobber_rdoc] || "clobber_rdoc").to_s
213
+ else
214
+ "clobber_#{name}"
215
+ end
216
+ end
217
+
218
+ def rerdoc_task_name
219
+ case name
220
+ when Hash
221
+ (name[:rerdoc] || "rerdoc").to_s
222
+ else
223
+ "re#{name}"
224
+ end
205
225
  end
206
- end
207
226
 
227
+ end
208
228
  end
209
229
  end
230
+