rake 0.9.2 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +43 -0
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2386 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +64 -109
  7. data/Rakefile +22 -386
  8. data/bin/bundle +105 -0
  9. data/bin/console +7 -0
  10. data/bin/rake +20 -23
  11. data/bin/rdoc +29 -0
  12. data/bin/rubocop +29 -0
  13. data/bin/setup +6 -0
  14. data/doc/command_line_usage.rdoc +65 -21
  15. data/doc/glossary.rdoc +40 -49
  16. data/doc/jamis.rb +1 -0
  17. data/doc/rake.1 +156 -0
  18. data/doc/rakefile.rdoc +127 -62
  19. data/exe/rake +27 -0
  20. data/lib/rake.rb +37 -31
  21. data/lib/rake/application.rb +507 -272
  22. data/lib/rake/backtrace.rb +24 -0
  23. data/lib/rake/clean.rb +55 -8
  24. data/lib/rake/cloneable.rb +11 -19
  25. data/lib/rake/cpu_counter.rb +107 -0
  26. data/lib/rake/default_loader.rb +5 -0
  27. data/lib/rake/dsl_definition.rb +74 -46
  28. data/lib/rake/early_time.rb +5 -1
  29. data/lib/rake/ext/core.rb +5 -6
  30. data/lib/rake/ext/string.rb +61 -52
  31. data/lib/rake/file_creation_task.rb +4 -3
  32. data/lib/rake/file_list.rb +81 -49
  33. data/lib/rake/file_task.rb +15 -8
  34. data/lib/rake/file_utils.rb +69 -47
  35. data/lib/rake/file_utils_ext.rb +18 -26
  36. data/lib/rake/invocation_chain.rb +25 -19
  37. data/lib/rake/invocation_exception_mixin.rb +1 -0
  38. data/lib/rake/late_time.rb +18 -0
  39. data/lib/rake/linked_list.rb +112 -0
  40. data/lib/rake/loaders/makefile.rb +23 -9
  41. data/lib/rake/multi_task.rb +4 -6
  42. data/lib/rake/name_space.rb +36 -23
  43. data/lib/rake/packagetask.rb +71 -34
  44. data/lib/rake/phony.rb +16 -0
  45. data/lib/rake/private_reader.rb +21 -0
  46. data/lib/rake/promise.rb +100 -0
  47. data/lib/rake/pseudo_status.rb +8 -2
  48. data/lib/rake/rake_module.rb +41 -3
  49. data/lib/rake/rake_test_loader.rb +21 -7
  50. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  51. data/lib/rake/scope.rb +43 -0
  52. data/lib/rake/task.rb +186 -79
  53. data/lib/rake/task_argument_error.rb +1 -0
  54. data/lib/rake/task_arguments.rb +50 -15
  55. data/lib/rake/task_manager.rb +89 -65
  56. data/lib/rake/tasklib.rb +2 -12
  57. data/lib/rake/testtask.rb +61 -63
  58. data/lib/rake/thread_history_display.rb +49 -0
  59. data/lib/rake/thread_pool.rb +163 -0
  60. data/lib/rake/trace_output.rb +23 -0
  61. data/lib/rake/version.rb +7 -7
  62. data/lib/rake/win32.rb +14 -18
  63. data/rake.gemspec +43 -0
  64. metadata +82 -221
  65. data/.gemtest +0 -0
  66. data/CHANGES +0 -509
  67. data/RRR +0 -9
  68. data/TODO +0 -20
  69. data/doc/rake.1.gz +0 -0
  70. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  71. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  72. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  73. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  74. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  75. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  76. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  77. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  78. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  79. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  80. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  81. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  82. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  83. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  84. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  85. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  86. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  87. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  88. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  89. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  90. data/install.rb +0 -90
  91. data/lib/rake/alt_system.rb +0 -109
  92. data/lib/rake/classic_namespace.rb +0 -9
  93. data/lib/rake/contrib/compositepublisher.rb +0 -21
  94. data/lib/rake/contrib/ftptools.rb +0 -150
  95. data/lib/rake/contrib/publisher.rb +0 -69
  96. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  97. data/lib/rake/contrib/sshpublisher.rb +0 -45
  98. data/lib/rake/contrib/sys.rb +0 -191
  99. data/lib/rake/ext/module.rb +0 -39
  100. data/lib/rake/ext/time.rb +0 -14
  101. data/lib/rake/gempackagetask.rb +0 -13
  102. data/lib/rake/pathmap.rb +0 -1
  103. data/lib/rake/rdoctask.rb +0 -230
  104. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  105. data/lib/rake/runtest.rb +0 -21
  106. data/test/check_expansion.rb +0 -5
  107. data/test/check_no_expansion.rb +0 -5
  108. data/test/data/access/Rakefile +0 -35
  109. data/test/data/chains/Rakefile +0 -15
  110. data/test/data/comments/Rakefile +0 -18
  111. data/test/data/default/Rakefile +0 -17
  112. data/test/data/deprecated_import/Rakefile +0 -1
  113. data/test/data/dryrun/Rakefile +0 -22
  114. data/test/data/extra/Rakefile +0 -1
  115. data/test/data/file_creation_task/Rakefile +0 -31
  116. data/test/data/imports/Rakefile +0 -19
  117. data/test/data/imports/deps.mf +0 -1
  118. data/test/data/multidesc/Rakefile +0 -15
  119. data/test/data/namespace/Rakefile +0 -64
  120. data/test/data/rakelib/test1.rb +0 -4
  121. data/test/data/rbext/rakefile.rb +0 -3
  122. data/test/data/sample.mf +0 -14
  123. data/test/data/statusreturn/Rakefile +0 -6
  124. data/test/data/unittest/Rakefile +0 -1
  125. data/test/data/verbose/Rakefile +0 -34
  126. data/test/file_creation.rb +0 -34
  127. data/test/helper.rb +0 -44
  128. data/test/in_environment.rb +0 -35
  129. data/test/reqfile.rb +0 -3
  130. data/test/reqfile2.rb +0 -3
  131. data/test/shellcommand.rb +0 -3
  132. data/test/test_rake.rb +0 -38
  133. data/test/test_rake_application.rb +0 -364
  134. data/test/test_rake_application_options.rb +0 -382
  135. data/test/test_rake_clean.rb +0 -12
  136. data/test/test_rake_definitions.rb +0 -80
  137. data/test/test_rake_directory_task.rb +0 -55
  138. data/test/test_rake_dsl.rb +0 -73
  139. data/test/test_rake_early_time.rb +0 -31
  140. data/test/test_rake_extension.rb +0 -59
  141. data/test/test_rake_file_creation_task.rb +0 -62
  142. data/test/test_rake_file_list.rb +0 -633
  143. data/test/test_rake_file_list_path_map.rb +0 -8
  144. data/test/test_rake_file_task.rb +0 -104
  145. data/test/test_rake_file_utils.rb +0 -252
  146. data/test/test_rake_ftp_file.rb +0 -59
  147. data/test/test_rake_functional.rb +0 -468
  148. data/test/test_rake_invocation_chain.rb +0 -52
  149. data/test/test_rake_makefile_loader.rb +0 -23
  150. data/test/test_rake_multi_task.rb +0 -51
  151. data/test/test_rake_name_space.rb +0 -43
  152. data/test/test_rake_package_task.rb +0 -78
  153. data/test/test_rake_path_map.rb +0 -157
  154. data/test/test_rake_path_map_explode.rb +0 -31
  155. data/test/test_rake_path_map_partial.rb +0 -18
  156. data/test/test_rake_pseudo_status.rb +0 -20
  157. data/test/test_rake_rdoc_task.rb +0 -81
  158. data/test/test_rake_require.rb +0 -35
  159. data/test/test_rake_rules.rb +0 -346
  160. data/test/test_rake_task.rb +0 -271
  161. data/test/test_rake_task_argument_parsing.rb +0 -116
  162. data/test/test_rake_task_arguments.rb +0 -86
  163. data/test/test_rake_task_lib.rb +0 -9
  164. data/test/test_rake_task_manager.rb +0 -145
  165. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  166. data/test/test_rake_task_with_arguments.rb +0 -162
  167. data/test/test_rake_test_task.rb +0 -122
  168. data/test/test_rake_top_level_functions.rb +0 -76
  169. data/test/test_rake_win32.rb +0 -83
  170. data/test/test_sys.rb +0 -20
@@ -1,69 +0,0 @@
1
- # Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
2
- # All rights reserved.
3
-
4
- # Configuration information about an upload host system.
5
- # * name :: Name of host system.
6
- # * webdir :: Base directory for the web information for the
7
- # application. The application name (APP) is appended to
8
- # this directory before using.
9
- # * pkgdir :: Directory on the host system where packages can be
10
- # placed.
11
- HostInfo = Struct.new(:name, :webdir, :pkgdir)
12
-
13
- # Manage several publishers as a single entity.
14
- class CompositePublisher
15
- def initialize
16
- @publishers = []
17
- end
18
-
19
- # Add a publisher to the composite.
20
- def add(pub)
21
- @publishers << pub
22
- end
23
-
24
- # Upload all the individual publishers.
25
- def upload
26
- @publishers.each { |p| p.upload }
27
- end
28
- end
29
-
30
- # Publish an entire directory to an existing remote directory using
31
- # SSH.
32
- class SshDirPublisher
33
- def initialize(host, remote_dir, local_dir)
34
- @host = host
35
- @remote_dir = remote_dir
36
- @local_dir = local_dir
37
- end
38
-
39
- def upload
40
- run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
41
- end
42
- end
43
-
44
- # Publish an entire directory to a fresh remote directory using SSH.
45
- class SshFreshDirPublisher < SshDirPublisher
46
- def upload
47
- run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
48
- run %{ssh #{@host} mkdir #{@remote_dir}}
49
- super
50
- end
51
- end
52
-
53
- # Publish a list of files to an existing remote directory.
54
- class SshFilePublisher
55
- # Create a publisher using the give host information.
56
- def initialize(host, remote_dir, local_dir, *files)
57
- @host = host
58
- @remote_dir = remote_dir
59
- @local_dir = local_dir
60
- @files = files
61
- end
62
-
63
- # Upload the local directory to the remote directory.
64
- def upload
65
- @files.each do |fn|
66
- run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
67
- end
68
- end
69
- end
@@ -1,16 +0,0 @@
1
- require 'rake/contrib/sshpublisher'
2
-
3
- module Rake
4
-
5
- class RubyForgePublisher < SshDirPublisher
6
- attr_reader :project, :proj_id, :user
7
-
8
- def initialize(projname, user)
9
- super(
10
- "#{user}@rubyforge.org",
11
- "/var/www/gforge-projects/#{projname}",
12
- "html")
13
- end
14
- end
15
-
16
- end
@@ -1,45 +0,0 @@
1
- require 'rake/contrib/compositepublisher'
2
-
3
- module Rake
4
-
5
- # Publish an entire directory to an existing remote directory using
6
- # SSH.
7
- class SshDirPublisher
8
- def initialize(host, remote_dir, local_dir)
9
- @host = host
10
- @remote_dir = remote_dir
11
- @local_dir = local_dir
12
- end
13
-
14
- def upload
15
- sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
16
- end
17
- end
18
-
19
- # Publish an entire directory to a fresh remote directory using SSH.
20
- class SshFreshDirPublisher < SshDirPublisher
21
- def upload
22
- sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
23
- sh %{ssh #{@host} mkdir #{@remote_dir}}
24
- super
25
- end
26
- end
27
-
28
- # Publish a list of files to an existing remote directory.
29
- class SshFilePublisher
30
- # Create a publisher using the give host information.
31
- def initialize(host, remote_dir, local_dir, *files)
32
- @host = host
33
- @remote_dir = remote_dir
34
- @local_dir = local_dir
35
- @files = files
36
- end
37
-
38
- # Upload the local directory to the remote directory.
39
- def upload
40
- @files.each do |fn|
41
- sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
42
- end
43
- end
44
- end
45
- end
@@ -1,191 +0,0 @@
1
- warn 'Sys has been deprecated in favor of FileUtils'
2
-
3
- #--
4
- # Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
5
- # All rights reserved.
6
- #++
7
- #
8
- begin
9
- require 'ftools'
10
- rescue LoadError
11
- end
12
- require 'rbconfig'
13
-
14
- ######################################################################
15
- # Sys provides a number of file manipulation tools for the convenience
16
- # of writing Rakefiles. All commands in this module will announce
17
- # their activity on standard output if the $verbose flag is set
18
- # ($verbose = true is the default). You can control this by globally
19
- # setting $verbose or by using the +verbose+ and +quiet+ methods.
20
- #
21
- # Sys has been deprecated in favor of the FileUtils module available
22
- # in Ruby 1.8.
23
- #
24
- module Sys
25
- RUBY = RbConfig::CONFIG['ruby_install_name']
26
-
27
- # Install all the files matching +wildcard+ into the +dest_dir+
28
- # directory. The permission mode is set to +mode+.
29
- def install(wildcard, dest_dir, mode)
30
- Dir[wildcard].each do |fn|
31
- File.install(fn, dest_dir, mode, $verbose)
32
- end
33
- end
34
-
35
- # Run the system command +cmd+.
36
- def run(cmd)
37
- log cmd
38
- system(cmd) or fail "Command Failed: [#{cmd}]"
39
- end
40
-
41
- # Run a Ruby interpreter with the given arguments.
42
- def ruby(*args)
43
- run "#{RUBY} #{args.join(' ')}"
44
- end
45
-
46
- # Copy a single file from +file_name+ to +dest_file+.
47
- def copy(file_name, dest_file)
48
- log "Copying file #{file_name} to #{dest_file}"
49
- File.copy(file_name, dest_file)
50
- end
51
-
52
- # Copy all files matching +wildcard+ into the directory +dest_dir+.
53
- def copy_files(wildcard, dest_dir)
54
- for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }
55
- end
56
-
57
- # Link +file_name+ to +dest_file+.
58
- def link(file_name, dest_file)
59
- log "Linking file #{file_name} to #{dest_file}"
60
- File.link(file_name, dest_file)
61
- end
62
-
63
- # Link all files matching +wildcard+ into the directory +dest_dir+.
64
- def link_files(wildcard, dest_dir)
65
- for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
66
- end
67
-
68
- # Symlink +file_name+ to +dest_file+.
69
- def symlink(file_name, dest_file)
70
- log "Symlinking file #{file_name} to #{dest_file}"
71
- File.symlink(file_name, dest_file)
72
- end
73
-
74
- # Symlink all files matching +wildcard+ into the directory +dest_dir+.
75
- def symlink_files(wildcard, dest_dir)
76
- for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
77
- end
78
-
79
- # Remove all files matching +wildcard+. If a matching file is a
80
- # directory, it must be empty to be removed. used +delete_all+ to
81
- # recursively delete directories.
82
- def delete(*wildcards)
83
- wildcards.each do |wildcard|
84
- Dir[wildcard].each do |fn|
85
- if File.directory?(fn)
86
- log "Deleting directory #{fn}"
87
- Dir.delete(fn)
88
- else
89
- log "Deleting file #{fn}"
90
- File.delete(fn)
91
- end
92
- end
93
- end
94
- end
95
-
96
- # Recursively delete all files and directories matching +wildcard+.
97
- def delete_all(*wildcards)
98
- wildcards.each do |wildcard|
99
- Dir[wildcard].each do |fn|
100
- next if ! File.exist?(fn)
101
- if File.directory?(fn)
102
- Dir["#{fn}/*"].each do |subfn|
103
- next if subfn=='.' || subfn=='..'
104
- delete_all(subfn)
105
- end
106
- log "Deleting directory #{fn}"
107
- Dir.delete(fn)
108
- else
109
- log "Deleting file #{fn}"
110
- File.delete(fn)
111
- end
112
- end
113
- end
114
- end
115
-
116
- # Make the directories given in +dirs+.
117
- def makedirs(*dirs)
118
- dirs.each do |fn|
119
- log "Making directory #{fn}"
120
- File.makedirs(fn)
121
- end
122
- end
123
-
124
- # Make +dir+ the current working directory for the duration of
125
- # executing the given block.
126
- def indir(dir)
127
- olddir = Dir.pwd
128
- Dir.chdir(dir)
129
- yield
130
- ensure
131
- Dir.chdir(olddir)
132
- end
133
-
134
- # Split a file path into individual directory names.
135
- #
136
- # For example:
137
- # split_all("a/b/c") => ['a', 'b', 'c']
138
- def split_all(path)
139
- head, tail = File.split(path)
140
- return [tail] if head == '.' || tail == '/'
141
- return [head, tail] if head == '/'
142
- return split_all(head) + [tail]
143
- end
144
-
145
- # Write a message to standard error if $verbose is enabled.
146
- def log(msg)
147
- print " " if $trace && $verbose
148
- $stderr.puts msg if $verbose
149
- end
150
-
151
- # Perform a block with $verbose disabled.
152
- def quiet(&block)
153
- with_verbose(false, &block)
154
- end
155
-
156
- # Perform a block with $verbose enabled.
157
- def verbose(&block)
158
- with_verbose(true, &block)
159
- end
160
-
161
- # Perform a block with each file matching a set of wildcards.
162
- def for_files(*wildcards)
163
- wildcards.each do |wildcard|
164
- Dir[wildcard].each do |fn|
165
- yield(fn)
166
- end
167
- end
168
- end
169
-
170
- extend(self)
171
-
172
- private # ----------------------------------------------------------
173
-
174
- def for_matching_files(wildcard, dest_dir)
175
- Dir[wildcard].each do |fn|
176
- dest_file = File.join(dest_dir, fn)
177
- parent = File.dirname(dest_file)
178
- makedirs(parent) if ! File.directory?(parent)
179
- yield(fn, dest_file)
180
- end
181
- end
182
-
183
- def with_verbose(v)
184
- oldverbose = $verbose
185
- $verbose = v
186
- yield
187
- ensure
188
- $verbose = oldverbose
189
- end
190
-
191
- end
@@ -1,39 +0,0 @@
1
- require 'rake/ext/core'
2
- require 'rake/task'
3
- require 'rake/file_task'
4
- require 'rake/file_creation_task'
5
- require 'rake/application'
6
- require 'rake/task_manager'
7
-
8
- ######################################################################
9
- # Rake extensions to Module.
10
- #
11
- class Module
12
-
13
- # Rename the original handler to make it available.
14
- alias :rake_original_const_missing :const_missing
15
-
16
- # Check for deprecated uses of top level (i.e. in Object) uses of
17
- # Rake class names. If someone tries to reference the constant
18
- # name, display a warning and return the proper object. Using the
19
- # --classic-namespace command line option will define these
20
- # constants in Object and avoid this handler.
21
- def const_missing(const_name)
22
- case const_name
23
- when :Task
24
- Rake.application.const_warning(const_name)
25
- Rake::Task
26
- when :FileTask
27
- Rake.application.const_warning(const_name)
28
- Rake::FileTask
29
- when :FileCreationTask
30
- Rake.application.const_warning(const_name)
31
- Rake::FileCreationTask
32
- when :RakeApp
33
- Rake.application.const_warning(const_name)
34
- Rake::Application
35
- else
36
- rake_original_const_missing(const_name)
37
- end
38
- end
39
- end
data/lib/rake/ext/time.rb DELETED
@@ -1,14 +0,0 @@
1
- # ###########################################################################
2
- # Extensions to time to allow comparisons with an early time class.
3
- #
4
- class Time
5
- alias rake_original_time_compare :<=>
6
- def <=>(other)
7
- if Rake::EarlyTime === other
8
- - other.<=>(self)
9
- else
10
- rake_original_time_compare(other)
11
- end
12
- end
13
- end # class Time
14
-
@@ -1,13 +0,0 @@
1
- # rake/gempackagetask is deprecated in favor of rubygems/package_task
2
-
3
- warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead'
4
-
5
- require 'rubygems'
6
- require 'rubygems/package_task'
7
-
8
- require 'rake'
9
-
10
- module Rake
11
- GemPackageTask = Gem::PackageTask
12
- end
13
-
data/lib/rake/pathmap.rb DELETED
@@ -1 +0,0 @@
1
- require 'rake/ext/string'
data/lib/rake/rdoctask.rb DELETED
@@ -1,230 +0,0 @@
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
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
127
- end
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
163
- end
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
173
- end
174
-
175
- def quote(str)
176
- if @external
177
- "'#{str}'"
178
- else
179
- str
180
- end
181
- end
182
-
183
- def option_string
184
- option_list.join(' ')
185
- end
186
-
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
192
- end
193
-
194
- private
195
-
196
- def rdoc_target
197
- "#{rdoc_dir}/index.html"
198
- end
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
207
- end
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
225
- end
226
-
227
- end
228
- end
229
- end
230
-