rake 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,6 +1,13 @@
1
1
  = Rake Changelog
2
2
 
3
- == Pre-Version 0.7.2
3
+ == Pre-version 0.7.3
4
+
5
+ * Added existing and existing! methods to FileList
6
+ * FileLists now claim to be Arrays (via is_a?) to get better support
7
+ from the FileUtil module.
8
+ * Added init and top_level for custom rake applications.
9
+
10
+ == Version 0.7.2
4
11
 
5
12
  * Error messages are now send to stderr rather than stdout (from
6
13
  Payton Quackenbush).
data/Rakefile CHANGED
@@ -67,7 +67,7 @@ Rake::TestTask.new(:test_all) do |t|
67
67
  'test/fun*.rb'
68
68
  ]
69
69
  t.warning = true
70
- t.verbose = true
70
+ t.verbose = false
71
71
  end
72
72
 
73
73
  Rake::TestTask.new(:test_units) do |t|
@@ -88,16 +88,20 @@ Rake::TestTask.new(:test_contribs) do |t|
88
88
  t.warning = true
89
89
  end
90
90
 
91
- require 'rcov/rcovtask'
92
-
93
- Rcov::RcovTask.new do |t|
94
- t.libs << "test"
95
- t.rcov_opts = ['-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report']
96
- t.test_files = FileList[
97
- 'test/test*.rb',
98
- 'test/contrib/test*.rb'
99
- ]
100
- t.verbose = true
91
+ begin
92
+ require 'rcov/rcovtask'
93
+
94
+ Rcov::RcovTask.new do |t|
95
+ t.libs << "test"
96
+ t.rcov_opts = ['-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report']
97
+ t.test_files = FileList[
98
+ 'test/test*.rb',
99
+ 'test/contrib/test*.rb'
100
+ ]
101
+ t.verbose = true
102
+ end
103
+ rescue LoadError
104
+ # No rcov available
101
105
  end
102
106
 
103
107
  directory 'testdata'
@@ -0,0 +1,47 @@
1
+ = Rake 0.7.3 Released
2
+
3
+ Rake version 0.7.3 is a minor release that includes some refactoring to better
4
+ support custom Rake applications.
5
+
6
+ == Changes
7
+
8
+ === New Features in Version 0.7.3
9
+
10
+ * Added the +init+ and +top_level+ methods to make the creation of custom Rake applications a bit easier. E.g.
11
+
12
+ gem 'rake', ">= 0.7.3"
13
+ require 'rake'
14
+
15
+ Rake.application.init('myrake')
16
+
17
+ task :default do
18
+ something_interesting
19
+ end
20
+
21
+ Rake.application.top_level
22
+
23
+ == What is Rake
24
+
25
+ Rake is a build tool similar to the make program in many ways. But instead of
26
+ cryptic make recipes, Rake uses standard Ruby code to declare tasks and
27
+ dependencies. You have the full power of a modern scripting language built
28
+ right into your build tool.
29
+
30
+ == Availability
31
+
32
+ The easiest way to get and install rake is via RubyGems ...
33
+
34
+ gem install rake (you may need root/admin privileges)
35
+
36
+ Otherwise, you can get it from the more traditional places:
37
+
38
+ Home Page:: http://rake.rubyforge.org/
39
+ Download:: http://rubyforge.org/project/showfiles.php?group_id=50
40
+
41
+ == Thanks
42
+
43
+ As usual, it was input from users that drove a alot of these changes. The
44
+ following people either contributed patches, made suggestions or made
45
+ otherwise helpful comments. Thanks to ...
46
+
47
+ -- Jim Weirich
@@ -1,35 +1,35 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #--
4
+
4
5
  # Copyright (c) 2003, 2004, 2005, 2006 Jim Weirich
5
6
  #
6
- # Permission is hereby granted, free of charge, to any person obtaining
7
- # a copy of this software and associated documentation files (the
8
- # "Software"), to deal in the Software without restriction, including
9
- # without limitation the rights to use, copy, modify, merge, publish,
10
- # distribute, sublicense, and/or sell copies of the Software, and to
11
- # permit persons to whom the Software is furnished to do so, subject to
12
- # the following conditions:
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to
9
+ # deal in the Software without restriction, including without limitation the
10
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
+ # sell copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
13
  #
14
- # The above copyright notice and this permission notice shall be
15
- # included in all copies or substantial portions of the Software.
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
16
  #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
+ # IN THE SOFTWARE.
24
24
  #++
25
25
  #
26
26
  # = Rake -- Ruby Make
27
- #
28
- # This is the main file for the Rake application. Normally it is
29
- # referenced as a library via a require statement, but it can be
30
- # distributed independently as an application.
27
+ #
28
+ # This is the main file for the Rake application. Normally it is referenced
29
+ # as a library via a require statement, but it can be distributed
30
+ # independently as an application.
31
31
 
32
- RAKEVERSION = '0.7.2'
32
+ RAKEVERSION = '0.7.3'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'ftools'
@@ -44,10 +44,10 @@ require 'ostruct'
44
44
  #
45
45
  class Module
46
46
 
47
- # Check for an existing method in the current class before
48
- # extending. IF the method already exists, then a warning is
49
- # printed and the extension is not added. Otherwise the block is
50
- # yielded and any definitions in the block will take effect.
47
+ # Check for an existing method in the current class before extending. IF
48
+ # the method already exists, then a warning is printed and the extension is
49
+ # not added. Otherwise the block is yielded and any definitions in the
50
+ # block will take effect.
51
51
  #
52
52
  # Usage:
53
53
  #
@@ -74,10 +74,9 @@ end
74
74
  #
75
75
  class String
76
76
  rake_extension("ext") do
77
- # Replace the file extension with +newext+. If there is no
78
- # extenson on the string, append the new extension to the end. If
79
- # the new extension is not given, or is the empty string, remove
80
- # any existing extension.
77
+ # Replace the file extension with +newext+. If there is no extenson on
78
+ # the string, append the new extension to the end. If the new extension
79
+ # is not given, or is the empty string, remove any existing extension.
81
80
  #
82
81
  # +ext+ is a user added method for the String class.
83
82
  def ext(newext='')
@@ -100,10 +99,9 @@ class String
100
99
  end
101
100
  protected :pathmap_explode
102
101
 
103
- # Extract a partial path from the path. Include +n+ directories
104
- # from the front end (left hand side) if +n+ is positive. Include
105
- # |+n+| directories from the back end (right hand side) if +n+ is
106
- # negative.
102
+ # Extract a partial path from the path. Include +n+ directories from the
103
+ # front end (left hand side) if +n+ is positive. Include |+n+|
104
+ # directories from the back end (right hand side) if +n+ is negative.
107
105
  def pathmap_partial(n)
108
106
  target = File.dirname(self)
109
107
  dirs = target.pathmap_explode
@@ -122,8 +120,8 @@ class String
122
120
  end
123
121
  protected :pathmap_partial
124
122
 
125
- # Preform the pathmap replacement operations on the given path.
126
- # The patterns take the form 'pat1,rep1;pat2,rep2...'.
123
+ # Preform the pathmap replacement operations on the given path. The
124
+ # patterns take the form 'pat1,rep1;pat2,rep2...'.
127
125
  def pathmap_replace(patterns, &block)
128
126
  result = self
129
127
  patterns.split(';').each do |pair|
@@ -141,28 +139,26 @@ class String
141
139
  end
142
140
  protected :pathmap_replace
143
141
 
144
- # Map the path according to the given specification. The
145
- # specification controls the details of the mapping. The
146
- # following special patterns are recognized:
142
+ # Map the path according to the given specification. The specification
143
+ # controls the details of the mapping. The following special patterns are
144
+ # recognized:
147
145
  #
148
146
  # * <b>%p</b> -- The complete path.
149
- # * <b>%f</b> -- The base file name of the path, with its file
150
- # extension, but without any directories.
151
- # * <b>%n</b> -- The file name of the path without its file
152
- # extension.
147
+ # * <b>%f</b> -- The base file name of the path, with its file extension,
148
+ # but without any directories.
149
+ # * <b>%n</b> -- The file name of the path without its file extension.
153
150
  # * <b>%d</b> -- The directory list of the path.
154
- # * <b>%x</b> -- The file extension of the path. An empty string
155
- # if there is no extension.
151
+ # * <b>%x</b> -- The file extension of the path. An empty string if there
152
+ # is no extension.
156
153
  # * <b>%X</b> -- Everything *but* the file extension.
157
- # * <b>%s</b> -- The alternate file separater if defined,
158
- # otherwise use the standard file separator.
154
+ # * <b>%s</b> -- The alternate file separater if defined, otherwise use
155
+ # the standard file separator.
159
156
  # * <b>%%</b> -- A percent sign.
160
157
  #
161
- # The %d specifier can also have a numeric prefix (e.g. '%2d').
162
- # If the number is positive, only return (up to) +n+ directories
163
- # in the path, starting from the left hand side. If +n+ is
164
- # negative, return (up to) |+n+| directories from the right hand
165
- # side of the path.
158
+ # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
159
+ # number is positive, only return (up to) +n+ directories in the path,
160
+ # starting from the left hand side. If +n+ is negative, return (up to)
161
+ # |+n+| directories from the right hand side of the path.
166
162
  #
167
163
  # Examples:
168
164
  #
@@ -170,29 +166,28 @@ class String
170
166
  # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
171
167
  #
172
168
  # Also the %d, %p, $f, $n, %x, and %X operators can take a
173
- # pattern/replacement argument to perform simple string
174
- # substititions on a particular part of the path. The pattern and
175
- # replacement are speparated by a comma and are enclosed by curly
176
- # braces. The replacement spec comes after the % character but
177
- # before the operator letter. (e.g. "%{old,new}d"). Muliple
178
- # replacement specs should be separated by semi-colons
179
- # (e.g. "%{old,new;src,bin}d").
169
+ # pattern/replacement argument to perform simple string substititions on a
170
+ # particular part of the path. The pattern and replacement are speparated
171
+ # by a comma and are enclosed by curly braces. The replacement spec comes
172
+ # after the % character but before the operator letter. (e.g.
173
+ # "%{old,new}d"). Muliple replacement specs should be separated by
174
+ # semi-colons (e.g. "%{old,new;src,bin}d").
180
175
  #
181
- # Regular expressions may be used for the pattern, and back refs
182
- # may be used in the replacement text. Curly braces, commas and
183
- # semi-colons are excluded from both the pattern and replacement
184
- # text (let's keep parsing reasonable).
176
+ # Regular expressions may be used for the pattern, and back refs may be
177
+ # used in the replacement text. Curly braces, commas and semi-colons are
178
+ # excluded from both the pattern and replacement text (let's keep parsing
179
+ # reasonable).
185
180
  #
186
181
  # For example:
187
182
  #
188
183
  # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
189
- #
184
+ #
190
185
  # returns:
191
186
  #
192
187
  # "bin/org/onestepback/proj/A.class"
193
188
  #
194
- # If the replacement text is '*', then a block may be provided to
195
- # perform some arbitrary calculation for the replacement.
189
+ # If the replacement text is '*', then a block may be provided to perform
190
+ # some arbitrary calculation for the replacement.
196
191
  #
197
192
  # For example:
198
193
  #
@@ -247,10 +242,10 @@ class String
247
242
  end
248
243
  end
249
244
 
250
- ######################################################################
245
+ ##############################################################################
251
246
  module Rake
252
247
 
253
- # ------------------------------------------------------------------
248
+ # --------------------------------------------------------------------------
254
249
  # Rake module singleton methods.
255
250
  #
256
251
  class << self
@@ -264,20 +259,19 @@ module Rake
264
259
  @application = app
265
260
  end
266
261
 
267
- # Return the original directory where the Rake application was
268
- # started.
262
+ # Return the original directory where the Rake application was started.
269
263
  def original_dir
270
264
  application.original_dir
271
265
  end
272
266
 
273
267
  end
274
268
 
275
- ####################################################################
269
+ # ##########################################################################
276
270
  # Mixin for creating easily cloned objects.
277
271
  #
278
272
  module Cloneable
279
- # Clone an object by making a new object and setting all the
280
- # instance variables to the same values.
273
+ # Clone an object by making a new object and setting all the instance
274
+ # variables to the same values.
281
275
  def clone
282
276
  sibling = self.class.new
283
277
  instance_variables.each do |ivar|
@@ -293,15 +287,14 @@ end
293
287
 
294
288
  module Rake
295
289
 
296
- ######################################################################
297
- # A Task is the basic unit of work in a Rakefile. Tasks have
298
- # associated actions (possibly more than one) and a list of
299
- # prerequisites. When invoked, a task will first ensure that all of
300
- # its prerequisites have an opportunity to run and then it will
301
- # execute its own actions.
290
+ # #########################################################################
291
+ # A Task is the basic unit of work in a Rakefile. Tasks have associated
292
+ # actions (possibly more than one) and a list of prerequisites. When
293
+ # invoked, a task will first ensure that all of its prerequisites have an
294
+ # opportunity to run and then it will execute its own actions.
302
295
  #
303
- # Tasks are not usually created directly using the new method, but
304
- # rather use the +file+ and +task+ convenience methods.
296
+ # Tasks are not usually created directly using the new method, but rather
297
+ # use the +file+ and +task+ convenience methods.
305
298
  #
306
299
  class Task
307
300
  # List of prerequisites for a task.
@@ -332,8 +325,8 @@ module Rake
332
325
  @sources.first if defined?(@sources)
333
326
  end
334
327
 
335
- # Create a task named +task_name+ with no actions or prerequisites..
336
- # use +enhance+ to add actions and prerequisites.
328
+ # Create a task named +task_name+ with no actions or prerequisites. Use
329
+ # +enhance+ to add actions and prerequisites.
337
330
  def initialize(task_name, app)
338
331
  @name = task_name.to_s
339
332
  @prerequisites = FileList[]
@@ -404,8 +397,8 @@ module Rake
404
397
  true
405
398
  end
406
399
 
407
- # Timestamp for this task. Basic tasks return the current time for
408
- # their time stamp. Other tasks can be more sophisticated.
400
+ # Timestamp for this task. Basic tasks return the current time for their
401
+ # time stamp. Other tasks can be more sophisticated.
409
402
  def timestamp
410
403
  @prerequisites.collect { |p| application[p].timestamp }.max || Time.now
411
404
  end
@@ -422,8 +415,8 @@ module Rake
422
415
  @comment << comment
423
416
  end
424
417
 
425
- # Return a string describing the internal state of a task. Useful
426
- # for debugging.
418
+ # Return a string describing the internal state of a task. Useful for
419
+ # debugging.
427
420
  def investigation
428
421
  result = "------------------------------\n"
429
422
  result << "Investigating #{name}\n"
@@ -447,9 +440,8 @@ module Rake
447
440
  #
448
441
  class << self
449
442
 
450
- # Clear the task list. This cause rake to immediately forget all
451
- # the tasks that have been assigned. (Normally used in the unit
452
- # tests.)
443
+ # Clear the task list. This cause rake to immediately forget all the
444
+ # tasks that have been assigned. (Normally used in the unit tests.)
453
445
  def clear
454
446
  Rake.application.clear
455
447
  end
@@ -460,9 +452,9 @@ module Rake
460
452
  end
461
453
 
462
454
  # Return a task with the given name. If the task is not currently
463
- # known, try to synthesize one from the defined rules. If no
464
- # rules are found, but an existing file matches the task name,
465
- # assume it is a file task with no dependencies or actions.
455
+ # known, try to synthesize one from the defined rules. If no rules are
456
+ # found, but an existing file matches the task name, assume it is a file
457
+ # task with no dependencies or actions.
466
458
  def [](task_name)
467
459
  Rake.application[task_name]
468
460
  end
@@ -472,9 +464,9 @@ module Rake
472
464
  Rake.application.lookup(task_name) != nil
473
465
  end
474
466
 
475
- # Define a task given +args+ and an option block. If a rule with
476
- # the given name already exists, the prerequisites and actions are
477
- # added to the existing task. Returns the defined task.
467
+ # Define a task given +args+ and an option block. If a rule with the
468
+ # given name already exists, the prerequisites and actions are added to
469
+ # the existing task. Returns the defined task.
478
470
  def define_task(args, &block)
479
471
  Rake.application.define_task(self, args, &block)
480
472
  end
@@ -495,16 +487,16 @@ module Rake
495
487
  end
496
488
 
497
489
 
498
- ######################################################################
499
- # A FileTask is a task that includes time based dependencies. If
500
- # any of a FileTask's prerequisites have a timestamp that is later
501
- # than the file represented by this task, then the file must be
502
- # rebuilt (using the supplied actions).
490
+ # #########################################################################
491
+ # A FileTask is a task that includes time based dependencies. If any of a
492
+ # FileTask's prerequisites have a timestamp that is later than the file
493
+ # represented by this task, then the file must be rebuilt (using the
494
+ # supplied actions).
503
495
  #
504
496
  class FileTask < Task
505
497
 
506
- # Is this file task needed? Yes if it doesn't exist, or if its time
507
- # stamp is out of date.
498
+ # Is this file task needed? Yes if it doesn't exist, or if its time stamp
499
+ # is out of date.
508
500
  def needed?
509
501
  return true unless File.exist?(name)
510
502
  return true if out_of_date?(timestamp)
@@ -522,8 +514,7 @@ module Rake
522
514
 
523
515
  private
524
516
 
525
- # Are there any prerequisites with a later time than the given
526
- # time stamp?
517
+ # Are there any prerequisites with a later time than the given time stamp?
527
518
  def out_of_date?(stamp)
528
519
  @prerequisites.any? { |n| application[n].timestamp > stamp}
529
520
  end
@@ -532,21 +523,20 @@ module Rake
532
523
  # Task class methods.
533
524
  #
534
525
  class << self
535
- # Apply the scope to the task name according to the rules for
536
- # this kind of task. File based tasks ignore the scope when
537
- # creating the name.
526
+ # Apply the scope to the task name according to the rules for this kind
527
+ # of task. File based tasks ignore the scope when creating the name.
538
528
  def scope_name(scope, task_name)
539
529
  task_name
540
530
  end
541
531
  end
542
532
  end
543
533
 
544
- ######################################################################
545
- # A FileCreationTask is a file task that when used as a dependency
546
- # will be needed if and only if the file has not been created. Once
547
- # created, it is not re-triggered if any of its dependencies are
548
- # newer, nor does trigger any rebuilds of tasks that depend on it
549
- # whenever it is updated.
534
+ # #########################################################################
535
+ # A FileCreationTask is a file task that when used as a dependency will be
536
+ # needed if and only if the file has not been created. Once created, it is
537
+ # not re-triggered if any of its dependencies are newer, nor does trigger
538
+ # any rebuilds of tasks that depend on it whenever it is updated.
539
+ #
550
540
  class FileCreationTask < FileTask
551
541
  # Is this file task needed? Yes if it doesn't exist.
552
542
  def needed?
@@ -560,9 +550,9 @@ module Rake
560
550
  end
561
551
  end
562
552
 
563
- ####################################################################
564
- # Same as a regular task, but the immediate prerequisites are done
565
- # in parallel using Ruby threads.
553
+ # #########################################################################
554
+ # Same as a regular task, but the immediate prerequisites are done in
555
+ # parallel using Ruby threads.
566
556
  #
567
557
  class MultiTask < Task
568
558
  def invoke_prerequisites
@@ -574,7 +564,7 @@ module Rake
574
564
  end
575
565
  end
576
566
 
577
- ######################################################################
567
+ # ###########################################################################
578
568
  # Task Definition Functions ...
579
569
 
580
570
  # Declare a basic task.
@@ -612,8 +602,7 @@ def file_create(args, &block)
612
602
  Rake::FileCreationTask.define_task(args, &block)
613
603
  end
614
604
 
615
- # Declare a set of files tasks to create the given directories on
616
- # demand.
605
+ # Declare a set of files tasks to create the given directories on demand.
617
606
  #
618
607
  # Example:
619
608
  # directory "testdata/doc"
@@ -626,9 +615,9 @@ def directory(dir)
626
615
  end
627
616
  end
628
617
 
629
- # Declare a task that performs its prerequisites in parallel.
630
- # Multitasks does *not* guarantee that its prerequisites will execute
631
- # in any given order (which is obvious when you think about it)
618
+ # Declare a task that performs its prerequisites in parallel. Multitasks does
619
+ # *not* guarantee that its prerequisites will execute in any given order
620
+ # (which is obvious when you think about it)
632
621
  #
633
622
  # Example:
634
623
  # multitask :deploy => [:deploy_gem, :deploy_rdoc]
@@ -637,9 +626,9 @@ def multitask(args, &block)
637
626
  Rake::MultiTask.define_task(args, &block)
638
627
  end
639
628
 
640
- # Create a new rake namespace and use it for evaluating the given
641
- # block. Returns a NameSpace object that can be used to lookup tasks
642
- # defined in the namespace.
629
+ # Create a new rake namespace and use it for evaluating the given block.
630
+ # Returns a NameSpace object that can be used to lookup tasks defined in the
631
+ # namespace.
643
632
  #
644
633
  # E.g.
645
634
  #
@@ -675,11 +664,10 @@ def desc(comment)
675
664
  Rake.application.last_comment = comment
676
665
  end
677
666
 
678
- # Import the partial Rakefiles +fn+. Imported files are loaded
679
- # _after_ the current file is completely loaded. This allows the
680
- # import statement to appear anywhere in the importing file, and yet
681
- # allowing the imported files to depend on objects defined in the
682
- # importing file.
667
+ # Import the partial Rakefiles +fn+. Imported files are loaded _after_ the
668
+ # current file is completely loaded. This allows the import statement to
669
+ # appear anywhere in the importing file, and yet allowing the imported files
670
+ # to depend on objects defined in the importing file.
683
671
  #
684
672
  # A common use of the import statement is to include files containing
685
673
  # dependency declarations.
@@ -695,9 +683,9 @@ def import(*fns)
695
683
  end
696
684
  end
697
685
 
698
- ######################################################################
699
- # This a FileUtils extension that defines several additional commands
700
- # to be added to the FileUtils utility functions.
686
+ # ###########################################################################
687
+ # This a FileUtils extension that defines several additional commands to be
688
+ # added to the FileUtils utility functions.
701
689
  #
702
690
  module FileUtils
703
691
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
@@ -705,9 +693,9 @@ module FileUtils
705
693
  OPT_TABLE['sh'] = %w(noop verbose)
706
694
  OPT_TABLE['ruby'] = %w(noop verbose)
707
695
 
708
- # Run the system command +cmd+. If multiple arguments are given
709
- # the command is not run with the shell (same semantics as
710
- # Kernel::exec and Kernel::system).
696
+ # Run the system command +cmd+. If multiple arguments are given the command
697
+ # is not run with the shell (same semantics as Kernel::exec and
698
+ # Kernel::system).
711
699
  #
712
700
  # Example:
713
701
  # sh %{ls -ltr}
@@ -725,7 +713,8 @@ module FileUtils
725
713
  options = (Hash === cmd.last) ? cmd.pop : {}
726
714
  unless block_given?
727
715
  show_command = cmd.join(" ")
728
- show_command = show_command[0,42] + "..." if show_command.length > 45
716
+ show_command = show_command[0,42] + "..."
717
+ # TODO code application logic heref show_command.length > 45
729
718
  block = lambda { |ok, status|
730
719
  ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
731
720
  }
@@ -754,8 +743,8 @@ module FileUtils
754
743
 
755
744
  LN_SUPPORTED = [true]
756
745
 
757
- # Attempt to do a normal file link, but fall back to a copy if the
758
- # link fails.
746
+ # Attempt to do a normal file link, but fall back to a copy if the link
747
+ # fails.
759
748
  def safe_ln(*args)
760
749
  unless LN_SUPPORTED[0]
761
750
  cp(*args)
@@ -782,9 +771,9 @@ module FileUtils
782
771
  end
783
772
  end
784
773
 
785
- ######################################################################
786
- # RakeFileUtils provides a custom version of the FileUtils methods
787
- # that respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
774
+ # ###########################################################################
775
+ # RakeFileUtils provides a custom version of the FileUtils methods that
776
+ # respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
788
777
  #
789
778
  module RakeFileUtils
790
779
  include FileUtils
@@ -818,9 +807,8 @@ module RakeFileUtils
818
807
  EOS
819
808
  end
820
809
 
821
- # Get/set the verbose flag controlling output from the FileUtils
822
- # utilities. If verbose is true, then the utility method is echoed
823
- # to standard output.
810
+ # Get/set the verbose flag controlling output from the FileUtils utilities.
811
+ # If verbose is true, then the utility method is echoed to standard output.
824
812
  #
825
813
  # Examples:
826
814
  # verbose # return the current value of the verbose flag
@@ -840,9 +828,8 @@ module RakeFileUtils
840
828
  RakeFileUtils.verbose_flag
841
829
  end
842
830
 
843
- # Get/set the nowrite flag controlling output from the FileUtils
844
- # utilities. If verbose is true, then the utility method is echoed
845
- # to standard output.
831
+ # Get/set the nowrite flag controlling output from the FileUtils utilities.
832
+ # If verbose is true, then the utility method is echoed to standard output.
846
833
  #
847
834
  # Examples:
848
835
  # nowrite # return the current value of the nowrite flag
@@ -862,8 +849,8 @@ module RakeFileUtils
862
849
  oldvalue
863
850
  end
864
851
 
865
- # Use this function to prevent protentially destructive ruby code
866
- # from running when the :nowrite flag is set.
852
+ # Use this function to prevent protentially destructive ruby code from
853
+ # running when the :nowrite flag is set.
867
854
  #
868
855
  # Example:
869
856
  #
@@ -871,8 +858,8 @@ module RakeFileUtils
871
858
  # project.build
872
859
  # end
873
860
  #
874
- # The following code will build the project under normal conditions.
875
- # If the nowrite(true) flag is set, then the example will print:
861
+ # The following code will build the project under normal conditions. If the
862
+ # nowrite(true) flag is set, then the example will print:
876
863
  # DRYRUN: Building Project
877
864
  # instead of actually building the project.
878
865
  #
@@ -901,9 +888,8 @@ module RakeFileUtils
901
888
  end
902
889
  private :rake_output_message
903
890
 
904
- # Check that the options do not contain options not listed in
905
- # +optdecl+. An ArgumentError exception is thrown if non-declared
906
- # options are found.
891
+ # Check that the options do not contain options not listed in +optdecl+. An
892
+ # ArgumentError exception is thrown if non-declared options are found.
907
893
  def rake_check_options(options, *optdecl)
908
894
  h = options.dup
909
895
  optdecl.each do |name|
@@ -916,10 +902,10 @@ module RakeFileUtils
916
902
  extend self
917
903
  end
918
904
 
919
- ######################################################################
920
- # Include the FileUtils file manipulation functions in the top level
921
- # module, but mark them private so that they don't unintentionally
922
- # define methods on other objects.
905
+ # ###########################################################################
906
+ # Include the FileUtils file manipulation functions in the top level module,
907
+ # but mark them private so that they don't unintentionally define methods on
908
+ # other objects.
923
909
 
924
910
  include RakeFileUtils
925
911
  private(*FileUtils.instance_methods(false))
@@ -943,20 +929,19 @@ module Rake
943
929
  end
944
930
  end
945
931
 
946
- ####################################################################
947
- # A FileList is essentially an array with a few helper methods
948
- # defined to make file manipulation a bit easier.
932
+ # #########################################################################
933
+ # A FileList is essentially an array with a few helper methods defined to
934
+ # make file manipulation a bit easier.
949
935
  #
950
- # FileLists are lazy. When given a list of glob patterns for
951
- # possible files to be included in the file list, instead of
952
- # searching the file structures to find the files, a FileList holds
953
- # the pattern for latter use.
936
+ # FileLists are lazy. When given a list of glob patterns for possible files
937
+ # to be included in the file list, instead of searching the file structures
938
+ # to find the files, a FileList holds the pattern for latter use.
954
939
  #
955
940
  # This allows us to define a number of FileList to match any number of
956
- # files, but only search out the actual files when then FileList
957
- # itself is actually used. The key is that the first time an
958
- # element of the FileList/Array is requested, the pending patterns
959
- # are resolved into a real list of file names.
941
+ # files, but only search out the actual files when then FileList itself is
942
+ # actually used. The key is that the first time an element of the
943
+ # FileList/Array is requested, the pending patterns are resolved into a real
944
+ # list of file names.
960
945
  #
961
946
  class FileList
962
947
 
@@ -964,22 +949,19 @@ module Rake
964
949
 
965
950
  # == Method Delegation
966
951
  #
967
- # The lazy evaluation magic of FileLists happens by implementing
968
- # all the array specific methods to call +resolve+ before
969
- # delegating the heavy lifting to an embedded array object
970
- # (@items).
952
+ # The lazy evaluation magic of FileLists happens by implementing all the
953
+ # array specific methods to call +resolve+ before delegating the heavy
954
+ # lifting to an embedded array object (@items).
971
955
  #
972
- # In addition, there are two kinds of delegation calls. The
973
- # regular kind delegates to the @items array and returns the
974
- # result directly. Well, almost directly. It checks if the
975
- # returned value is the @items object itself, and if so will
976
- # return the FileList object instead.
956
+ # In addition, there are two kinds of delegation calls. The regular kind
957
+ # delegates to the @items array and returns the result directly. Well,
958
+ # almost directly. It checks if the returned value is the @items object
959
+ # itself, and if so will return the FileList object instead.
977
960
  #
978
- # The second kind of delegation call is used in methods that
979
- # normally return a new Array object. We want to capture the
980
- # return value of these methods and wrap them in a new FileList
981
- # object. We enumerate these methods in the +SPECIAL_RETURN+ list
982
- # below.
961
+ # The second kind of delegation call is used in methods that normally
962
+ # return a new Array object. We want to capture the return value of these
963
+ # methods and wrap them in a new FileList object. We enumerate these
964
+ # methods in the +SPECIAL_RETURN+ list below.
983
965
 
984
966
  # List of array methods (that are not in +Object+) that need to be
985
967
  # delegated.
@@ -988,19 +970,19 @@ module Rake
988
970
  # List of additional methods that must be delegated.
989
971
  MUST_DEFINE = %w[to_a inspect]
990
972
 
991
- # List of methods that should not be delegated here (we define
992
- # special versions of them explicitly below).
973
+ # List of methods that should not be delegated here (we define special
974
+ # versions of them explicitly below).
993
975
  MUST_NOT_DEFINE = %w[to_a to_ary partition *]
994
976
 
995
- # List of delegated methods that return new array values which
996
- # need wrapping.
977
+ # List of delegated methods that return new array values which need
978
+ # wrapping.
997
979
  SPECIAL_RETURN = %w[
998
980
  map collect sort sort_by select find_all reject grep
999
981
  compact flatten uniq values_at
1000
982
  + - & |
1001
983
  ]
1002
984
 
1003
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).sort.uniq
985
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
1004
986
 
1005
987
  # Now do the delegation.
1006
988
  DELEGATING_METHODS.each_with_index do |sym, i|
@@ -1025,14 +1007,14 @@ module Rake
1025
1007
  end
1026
1008
  end
1027
1009
 
1028
- # Create a file list from the globbable patterns given. If you
1029
- # wish to perform multiple includes or excludes at object build
1030
- # time, use the "yield self" pattern.
1010
+ # Create a file list from the globbable patterns given. If you wish to
1011
+ # perform multiple includes or excludes at object build time, use the
1012
+ # "yield self" pattern.
1031
1013
  #
1032
1014
  # Example:
1033
- # file_list = FileList.new['lib/**/*.rb', 'test/test*.rb']
1015
+ # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb')
1034
1016
  #
1035
- # pkg_files = FileList.new['lib/**/*'] do |fl|
1017
+ # pkg_files = FileList.new('lib/**/*') do |fl|
1036
1018
  # fl.exclude(/\bCVS\b/)
1037
1019
  # end
1038
1020
  #
@@ -1047,8 +1029,8 @@ module Rake
1047
1029
  yield self if block_given?
1048
1030
  end
1049
1031
 
1050
- # Add file names defined by glob patterns to the file list. If an
1051
- # array is given, add each element of the array.
1032
+ # Add file names defined by glob patterns to the file list. If an array
1033
+ # is given, add each element of the array.
1052
1034
  #
1053
1035
  # Example:
1054
1036
  # file_list.include("*.java", "*.cfg")
@@ -1068,16 +1050,15 @@ module Rake
1068
1050
  end
1069
1051
  alias :add :include
1070
1052
 
1071
- # Register a list of file name patterns that should be excluded
1072
- # from the list. Patterns may be regular expressions, glob
1073
- # patterns or regular strings. In addition, a block given to
1074
- # exclude will remove entries that return true when given to the
1075
- # block.
1053
+ # Register a list of file name patterns that should be excluded from the
1054
+ # list. Patterns may be regular expressions, glob patterns or regular
1055
+ # strings. In addition, a block given to exclude will remove entries that
1056
+ # return true when given to the block.
1076
1057
  #
1077
- # Note that glob patterns are expanded against the file system.
1078
- # If a file is explicitly added to a file list, but does not exist
1079
- # in the file system, then an glob pattern in the exclude list
1080
- # will not exclude the file.
1058
+ # Note that glob patterns are expanded against the file system. If a file
1059
+ # is explicitly added to a file list, but does not exist in the file
1060
+ # system, then an glob pattern in the exclude list will not exclude the
1061
+ # file.
1081
1062
  #
1082
1063
  # Examples:
1083
1064
  # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
@@ -1122,9 +1103,14 @@ module Rake
1122
1103
 
1123
1104
  # Return the internal array object.
1124
1105
  def to_ary
1125
- resolve
1126
- @items
1106
+ to_a
1107
+ end
1108
+
1109
+ # Lie about our class.
1110
+ def is_a?(klass)
1111
+ klass == Array || super(klass)
1127
1112
  end
1113
+ alias kind_of? is_a?
1128
1114
 
1129
1115
  # Redefine * to return either a string or a new file list.
1130
1116
  def *(other)
@@ -1185,8 +1171,8 @@ module Rake
1185
1171
  end
1186
1172
  private :resolve_exclude
1187
1173
 
1188
- # Return a new FileList with the results of running +sub+ against
1189
- # each element of the oringal list.
1174
+ # Return a new FileList with the results of running +sub+ against each
1175
+ # element of the oringal list.
1190
1176
  #
1191
1177
  # Example:
1192
1178
  # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
@@ -1195,8 +1181,8 @@ module Rake
1195
1181
  inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
1196
1182
  end
1197
1183
 
1198
- # Return a new FileList with the results of running +gsub+ against
1199
- # each element of the original list.
1184
+ # Return a new FileList with the results of running +gsub+ against each
1185
+ # element of the original list.
1200
1186
  #
1201
1187
  # Example:
1202
1188
  # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
@@ -1218,15 +1204,15 @@ module Rake
1218
1204
  self
1219
1205
  end
1220
1206
 
1221
- # Apply the pathmap spec to each of the included file names,
1222
- # returning a new file list with the modified paths. (See
1223
- # String#pathmap for details.)
1207
+ # Apply the pathmap spec to each of the included file names, returning a
1208
+ # new file list with the modified paths. (See String#pathmap for
1209
+ # details.)
1224
1210
  def pathmap(spec=nil)
1225
1211
  collect { |fn| fn.pathmap(spec) }
1226
1212
  end
1227
1213
 
1228
- # Return a new array with <tt>String#ext</tt> method applied to
1229
- # each member of the array.
1214
+ # Return a new array with <tt>String#ext</tt> method applied to each
1215
+ # member of the array.
1230
1216
  #
1231
1217
  # This method is a shortcut for:
1232
1218
  #
@@ -1238,11 +1224,11 @@ module Rake
1238
1224
  end
1239
1225
 
1240
1226
 
1241
- # Grep each of the files in the filelist using the given pattern.
1242
- # If a block is given, call the block on each matching line,
1243
- # passing the file name, line number, and the matching line of
1244
- # text. If no block is given, a standard emac style
1245
- # file:linenumber:line message will be printed to standard out.
1227
+ # Grep each of the files in the filelist using the given pattern. If a
1228
+ # block is given, call the block on each matching line, passing the file
1229
+ # name, line number, and the matching line of text. If no block is given,
1230
+ # a standard emac style file:linenumber:line message will be printed to
1231
+ # standard out.
1246
1232
  def egrep(pattern)
1247
1233
  each do |fn|
1248
1234
  open(fn) do |inf|
@@ -1261,8 +1247,22 @@ module Rake
1261
1247
  end
1262
1248
  end
1263
1249
 
1264
- # FileList version of partition. Needed because the nested arrays
1265
- # should be FileLists in this version.
1250
+ # Return a new file list that only contains file names from the current
1251
+ # file list that exist on the file system.
1252
+ def existing
1253
+ select { |fn| File.exists?(fn) }
1254
+ end
1255
+
1256
+ # Modify the current file list so that it contains only file name that
1257
+ # exist on the file system.
1258
+ def existing!
1259
+ resolve
1260
+ @items = @items.select { |fn| File.exists?(fn) }
1261
+ self
1262
+ end
1263
+
1264
+ # FileList version of partition. Needed because the nested arrays should
1265
+ # be FileLists in this version.
1266
1266
  def partition(&block) # :nodoc:
1267
1267
  resolve
1268
1268
  result = @items.partition(&block)
@@ -1316,17 +1316,17 @@ module Rake
1316
1316
  new(*args)
1317
1317
  end
1318
1318
 
1319
- # Set the ignore patterns back to the default value. The
1320
- # default patterns will ignore files
1319
+ # Set the ignore patterns back to the default value. The default
1320
+ # patterns will ignore files
1321
1321
  # * containing "CVS" in the file path
1322
1322
  # * containing ".svn" in the file path
1323
1323
  # * ending with ".bak"
1324
1324
  # * ending with "~"
1325
1325
  # * named "core"
1326
1326
  #
1327
- # Note that file names beginning with "." are automatically
1328
- # ignored by Ruby's glob patterns and are not specifically
1329
- # listed in the ignore patterns.
1327
+ # Note that file names beginning with "." are automatically ignored by
1328
+ # Ruby's glob patterns and are not specifically listed in the ignore
1329
+ # patterns.
1330
1330
  def select_default_ignore_patterns
1331
1331
  @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
1332
1332
  end
@@ -1357,7 +1357,7 @@ end
1357
1357
  # Alias FileList to be available at the top level.
1358
1358
  FileList = Rake::FileList
1359
1359
 
1360
- ######################################################################
1360
+ # ###########################################################################
1361
1361
  module Rake
1362
1362
 
1363
1363
  # Default Rakefile loader used by +import+.
@@ -1367,8 +1367,7 @@ module Rake
1367
1367
  end
1368
1368
  end
1369
1369
 
1370
- # EarlyTime is a fake timestamp that occurs _before_ any other time
1371
- # value.
1370
+ # EarlyTime is a fake timestamp that occurs _before_ any other time value.
1372
1371
  class EarlyTime
1373
1372
  include Comparable
1374
1373
  include Singleton
@@ -1385,7 +1384,7 @@ module Rake
1385
1384
  EARLY = EarlyTime.instance
1386
1385
  end
1387
1386
 
1388
- ######################################################################
1387
+ # ###########################################################################
1389
1388
  # Extensions to time to allow comparisons with an early time class.
1390
1389
  #
1391
1390
  class Time
@@ -1631,12 +1630,21 @@ module Rake
1631
1630
  class Application
1632
1631
  include TaskManager
1633
1632
 
1633
+ # The name of the application (typically 'rake')
1634
+ attr_reader :name
1635
+
1634
1636
  # The original directory where rake was invoked.
1635
- attr_reader :original_dir, :rakefile
1637
+ attr_reader :original_dir
1638
+
1639
+ # Name of the actual rakefile used.
1640
+ attr_reader :rakefile
1641
+
1642
+ # List of the top level task names (task names from the command line).
1643
+ attr_reader :top_level_tasks
1636
1644
 
1637
1645
  DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
1638
1646
 
1639
- OPTIONS = [
1647
+ OPTIONS = [ # :nodoc:
1640
1648
  ['--dry-run', '-n', GetoptLong::NO_ARGUMENT,
1641
1649
  "Do a dry run without executing actions."],
1642
1650
  ['--help', '-H', GetoptLong::NO_ARGUMENT,
@@ -1671,9 +1679,10 @@ module Rake
1671
1679
  "Put Task and FileTask in the top level namespace"],
1672
1680
  ]
1673
1681
 
1674
- # Create a Rake::Application object.
1682
+ # Initialize a Rake::Application object.
1675
1683
  def initialize
1676
1684
  super
1685
+ @name = 'rake'
1677
1686
  @rakefiles = DEFAULT_RAKEFILES.dup
1678
1687
  @rakefile = nil
1679
1688
  @pending_imports = []
@@ -1681,15 +1690,92 @@ module Rake
1681
1690
  @loaders = {}
1682
1691
  @default_loader = Rake::DefaultLoader.new
1683
1692
  @original_dir = Dir.pwd
1693
+ @top_level_tasks = []
1684
1694
  add_loader('rf', DefaultLoader.new)
1685
1695
  add_loader('rake', DefaultLoader.new)
1686
1696
  end
1697
+
1698
+ # Run the Rake application. The run method performs the following three steps:
1699
+ #
1700
+ # * Initialize the command line options (+init+).
1701
+ # * Define the tasks (+load_rakefile+).
1702
+ # * Run the top level tasks (+run_tasks+).
1703
+ #
1704
+ # If you wish to build a custom rake command, you should call +init+ on your
1705
+ # application. The define any tasks. Finally, call +top_level+ to run your top
1706
+ # level tasks.
1707
+ def run
1708
+ standard_exception_handling do
1709
+ init
1710
+ load_rakefile
1711
+ top_level
1712
+ end
1713
+ end
1714
+
1715
+ # Initialize the command line parameters and app name.
1716
+ def init(app_name='rake')
1717
+ standard_exception_handling do
1718
+ @name = app_name
1719
+ handle_options
1720
+ collect_tasks
1721
+ end
1722
+ end
1723
+
1724
+ # Find the rakefile and then load it and any pending imports.
1725
+ def load_rakefile
1726
+ standard_exception_handling do
1727
+ raw_load_rakefile
1728
+ end
1729
+ end
1730
+
1731
+ # Run the top level tasks of a Rake application.
1732
+ def top_level
1733
+ standard_exception_handling do
1734
+ if options.show_tasks
1735
+ display_tasks_and_comments
1736
+ elsif options.show_prereqs
1737
+ display_prerequisites
1738
+ else
1739
+ top_level_tasks.each { |task_name| self[task_name].invoke }
1740
+ end
1741
+ end
1742
+ end
1743
+
1744
+ # Add a loader to handle imported files ending in the extension
1745
+ # +ext+.
1746
+ def add_loader(ext, loader)
1747
+ ext = ".#{ext}" unless ext =~ /^\./
1748
+ @loaders[ext] = loader
1749
+ end
1687
1750
 
1688
1751
  # Application options from the command line
1689
1752
  def options
1690
1753
  @options ||= OpenStruct.new
1691
1754
  end
1692
1755
 
1756
+ # private ----------------------------------------------------------------
1757
+
1758
+ # Provide standard execption handling for the given block.
1759
+ def standard_exception_handling
1760
+ begin
1761
+ yield
1762
+ rescue SystemExit, GetoptLong::InvalidOption => ex
1763
+ # Exit silently
1764
+ exit(1)
1765
+ rescue Exception => ex
1766
+ # Exit with error message
1767
+ $stderr.puts "rake aborted!"
1768
+ $stderr.puts ex.message
1769
+ if options.trace
1770
+ $stderr.puts ex.backtrace.join("\n")
1771
+ else
1772
+ $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
1773
+ $stderr.puts "(See full trace by running task with --trace)"
1774
+ end
1775
+ exit(1)
1776
+ end
1777
+ end
1778
+
1693
1779
  # True if one of the files in RAKEFILES is in the current directory.
1694
1780
  # If a match is found, it is copied into @rakefile.
1695
1781
  def have_rakefile
@@ -1731,7 +1817,7 @@ module Rake
1731
1817
  }
1732
1818
  width = displayable_tasks.collect { |t| t.name.length }.max
1733
1819
  displayable_tasks.each do |t|
1734
- printf "rake %-#{width}s # %s\n", t.name, t.comment
1820
+ printf "#{name} %-#{width}s # %s\n", t.name, t.comment
1735
1821
  end
1736
1822
  end
1737
1823
 
@@ -1840,8 +1926,7 @@ module Rake
1840
1926
  fail LoadError, "Can't find #{file_name}"
1841
1927
  end
1842
1928
 
1843
- # Find the rakefile and then load it and any pending imports.
1844
- def load_rakefile
1929
+ def raw_load_rakefile # :nodoc:
1845
1930
  here = Dir.pwd
1846
1931
  while ! have_rakefile
1847
1932
  Dir.chdir("..")
@@ -1863,16 +1948,15 @@ module Rake
1863
1948
  # given, return a list containing only the default task.
1864
1949
  # Environmental assignments are processed at this time as well.
1865
1950
  def collect_tasks
1866
- tasks = []
1951
+ @top_level_tasks = []
1867
1952
  ARGV.each do |arg|
1868
1953
  if arg =~ /^(\w+)=(.*)$/
1869
1954
  ENV[$1] = $2
1870
1955
  else
1871
- tasks << arg
1956
+ @top_level_tasks << arg
1872
1957
  end
1873
1958
  end
1874
- tasks.push("default") if tasks.size == 0
1875
- tasks
1959
+ @top_level_tasks.push("default") if @top_level_tasks.size == 0
1876
1960
  end
1877
1961
 
1878
1962
  # Add a file to the list of files to be imported.
@@ -1894,18 +1978,11 @@ module Rake
1894
1978
  end
1895
1979
  end
1896
1980
 
1897
- # Add a loader to handle imported files ending in the extension
1898
- # +ext+.
1899
- def add_loader(ext, loader)
1900
- ext = ".#{ext}" unless ext =~ /^\./
1901
- @loaders[ext] = loader
1902
- end
1903
-
1904
1981
  # Warn about deprecated use of top level constant names.
1905
1982
  def const_warning(const_name)
1906
1983
  @const_warning ||= false
1907
1984
  if ! @const_warning
1908
- $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}'} +
1985
+ $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
1909
1986
  %{found at: #{rakefile_location}} # '
1910
1987
  $stderr.puts %{ Use --classic-namespace on rake command}
1911
1988
  $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
@@ -1920,36 +1997,6 @@ module Rake
1920
1997
  ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
1921
1998
  end
1922
1999
  end
1923
-
1924
- # Run the +rake+ application.
1925
- def run
1926
- begin
1927
- handle_options
1928
- tasks = collect_tasks
1929
- load_rakefile
1930
- if options.show_tasks
1931
- display_tasks_and_comments
1932
- elsif options.show_prereqs
1933
- display_prerequisites
1934
- else
1935
- tasks.each { |task_name| self[task_name].invoke }
1936
- end
1937
- rescue SystemExit, GetoptLong::InvalidOption => ex
1938
- # Exit silently
1939
- exit(1)
1940
- rescue Exception => ex
1941
- # Exit with error message
1942
- $stderr.puts "rake aborted!"
1943
- $stderr.puts ex.message
1944
- if options.trace
1945
- $stderr.puts ex.backtrace.join("\n")
1946
- else
1947
- $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
1948
- $stderr.puts "(See full trace by running task with --trace)"
1949
- end
1950
- exit(1)
1951
- end
1952
- end
1953
2000
  end
1954
2001
  end
1955
2002