+++ /dev/null
-= Rake Changelog
-
-== Master (for 0.9.3)
-
-* The rake test loader now removes arguments it has processed. Issue #51
-* Rake::TaskArguments now responds to #values_at
-* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7
-* Rake tests are now directory-independent
-* Rake tests are no longer require flexmock
-* Commands constant is no longer polluting top level namespace.
-
-== Version 0.9.2
-
-* Unknown
-
-== Version 0.9.1
-
-* Added deprecation warnings to the Rake DSL methods.
-
-== Version 0.9.0
-
-* *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.) are
- no longer private methods in Object. If you need to call 'task :xzy' inside
- your class, include Rake::DSL into the class. The DSL is still available at
- the top level scope (via the top level object which extends Rake::DSL).
-
-* Rake now warns when the deprecated :needs syntax used.
-
-* Rake history is now UTF-8 encoded.
-
-* Rake now uses case-insensitive comparisons to find the Rakefile on Windows.
- Based on patch by Roger Pack.
-
-* Rake now requires (instead of loads) files in the test task. Patch by Cezary
- Baginski.
-
-* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow.
-
-* Rake now prints the Rakefile directory only when it's different from the
- current directory. Patch by Alex Chaffee.
-
-* Improved rakefile_location discovery on Windows. Patch by James Tucker.
-
-* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias
- Lüdtke
-
-* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require
- 'rdoc/task')
-
-* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require
- 'rubygems/package_task')
-
-* Rake now outputs various messages to $stderr instead of $stdout.
-
-* Rake no longer emits warnings for Config. Patch by Santiago Pastorino.
-
-* Split rake.rb into individual files.
-
-* Support for the --where (-W) flag for showing where a task is defined.
-
-* Fixed quoting in test task.
- (http://onestepback.org/redmine/issues/show/44,
- http://www.pivotaltracker.com/story/show/1223138)
-
-* Fixed the silent option parsing problem.
- (http://onestepback.org/redmine/issues/show/47)
-
-* Fixed :verbose=>false flag on sh and ruby commands.
-
-* Rake command line options may be given by default in a RAKEOPT
- environment variable.
-
-* Errors in Rake will now display the task invocation chain in effect
- at the time of the error.
-
-* Accepted change by warnickr to not expand test patterns in shell
- (allowing more files in the test suite).
-
-* Fixed that file tasks did not perform prereq lookups in scope
- (Redmine #57).
-
-== Version 0.8.7
-
-* Fixed EXEEXT for JRuby on windows.
-
-== Version 0.8.6
-
-* Minor fixes to the RDoc generation (removed dependency on darkfish
- and removed inline source option).
-
-== PreVersion 0.8.6
-
-* Now allow # comments to comment a task definition.
-
-== Version 0.8.5
-
-* Better support for the system command on Windows.
-
-== Version 0.8.4
-
-* Preserve case when locating rakefiles (patch from James
- M. Lawrence/quix)
-
-* Better support for windows paths in the test task (patch from Simon
- Chiang/bahuvrihi)
-
-* Windows system dir search order is now: HOME, HOMEDRIVE + HOMEPATH,
- APPDATA, USERPROFILE (patch from Luis Lavena)
-
-* MingGW is now recognized as a windows platform. (patch from Luis
- Lavena)
-
-* Numerous fixes to the windows test suite (patch from Luis Lavena).
-
-* Improved Rakefile case insensitivity testing (patch from Luis
- Lavena).
-
-* Fixed stray ARGV option problem that was interfering with
- Test::Unit::Runner.
-
-* Fixed default verbose mode (was accidently changed to false).
-
-* Removed reference to manage_gem to fix the warning produced by the
- gem package task.
-
-== Version 0.8.3
-
-* Enhanced the system directory detection in windows. We now check
- HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch
- supplied by James Tucker). Rake no long aborts if it can't find the
- directory.
-
-* Added fix to handle ruby installations in directories with spaces in
- their name.
-
-== Version 0.8.2
-
-* Fixed bug in package task so that it will include the subdir
- directory in the package for testing. (Bug found by Adam Majer)
-
-* Added ENV var to rakefile to prevent OS X from including extended
- attribute junk in a tar file. (Bug found by Adam Majer)
-
-* Fixed filename dependency order bug in test_inspect_pending and
- test_to_s_pending. (Bug found by Adam Majer)
-
-* Fixed check for file utils options to make them immune to the
- symbol/string differences. (Patch supplied by Edwin Pratomo)
-
-* Fixed bug with rules involving multiple source (Patch supplied by
- Emanuel Indermühle)
-
-* Switched from getoptlong to optparse (patches supplied by Edwin
- Pratomo)
-
-* The -T option will now attempt to dynamically sense the size of the
- terminal. RAKE_COLUMNS will override any dynamic sensing.
-
-* FileList#clone and FileList#dup have better sematics w.r.t. taint
- and freeze.
-
-* Added ability clear prerequisites, and/or actions from an existing
- task.
-
-* Added the ability to reenable a task to be invoked a second time.
-
-* Changed RDoc test task to have no default template. This makes it
- easier for the tempate to pick up the template from the environment.
-
-* Changed from using Mutex to Monitor. Evidently Mutex causes thread
- join errors when Ruby is compiled with -disable-pthreads. (Patch
- supplied by Ittay Dror)
-
-* Fixed bug in makefile parser that had problems with extra spaces in
- file task names. (Patch supplied by Ittay Dror)
-
-* Added a performance patch for reading large makefile dependency
- files. (Patch supplied by Ittay Dror)
-
-* Default values for task arguments can easily be specified with the
- :with_defaults method. (Idea for default argument merging supplied
- by (Adam Q. Salter)
-
-* The -T output will only self-truncate if the output is a tty.
- However, if RAKE_COLUMNS is explicitly set, it will be honored in
- any case. (Patch provided by Gavin Stark).
-
-* Numerous fixes for running under windows. A big thanks to Bheeshmar
- Redheendran for spending a good part of the afternoon at the
- Lonestar Ruby Conference to help me work out these issues.
-
-== Version 0.8.1
-
-* Removed requires on parsedate.rb (in Ftptools)
-* Removed ftools from rake.rb. Made it options in sys.rb
-
-== Version 0.8.0
-
-* Added task parameters (e.g. "rake build[version7]")
-* Made task parameters passable to prerequisites.
-* Comments are limited to 80 columns or so (suggested by Jamis Buck).
-* Added -D to display full comments (suggested by Jamis Buck).
-* The rake program will set the status value used in any explicit
- exit(n) calls. (patch provided by Stephen Touset)
-* Fixed error in functional tests that were not including session (and
- silently skipping the functionl tests.
-* Removed --usage and make -h the same as -H.
-* Make a prettier inspect for tasks.
-
-== Version 0.7.3
-
-* Added existing and existing! methods to FileList
-* FileLists now claim to be Arrays (via is_a?) to get better support
- from the FileUtil module.
-* Added init and top_level for custom rake applications.
-
-== Version 0.7.2
-
-* Error messages are now send to stderr rather than stdout (from
- Payton Quackenbush).
-* Better error handling on invalid command line arguments (from Payton
- Quackenbush).
-* Added rcov task and updated unit testing for better code coverage.
-* Fixed some bugs where the application object was going to the global
- appliation instead of using its own data.
-* Added square and curly bracket patterns to FileList#include (Tilman
- Sauerbeck).
-* Added plain filename support to rule dependents (suggested by Nobu
- Nakada).
-* Added pathmap support to rule dependents.
-* Added a 'tasks' method to a namespace to get a list of tasks
- associated with the namespace.
-* Fixed the method name leak from FileUtils (bug found by Glenn
- Vanderburg).
-* Added rake_extension to handle detection of extension collisions.
-* Added test for noop, bad_option and verbose flags to sh command.
-* Removed dependency on internal fu_xxx functions from FileUtils.
-* Added a 'shame' task to the Rakefile.
-* Added tar_command and zip_command options to the Package task.
-* Added a description to the gem task in GemPackageTask.
-* Fixed a bug when rules have multiple prerequisites (patch by Joel
- VanderWerf)
-* Added a protected 'require "rubygems"' to test/test_application to
- unbreak cruisecontrol.rb.
-* Added the handful of RakeFileUtils to the private method as well.
-* Added block based exclusion.
-* The clean task will no longer delete 'core' if it is a directory.
-* Removed rake_dup. Now we just simply rescue a bad dup.
-* Refactored the FileList reject logic to remove duplication.
-* Removed if __FILE__ at the end of the rake.rb file.
-
-== Version 0.7.1
-
-* Added optional filter parameter to the --tasks command line option.
-* Added flatten to allow rule transform procs to return lists of
- prereqs (Joel VanderWerf provided patch).
-* Added pathmap to String and FileList.
-* The -r option will now load .rake files (but a straight require
- doesn't yet). NOTE: This is experimental ... it may be
- discontinued.
-* The -f option without a value will disable the search for a
- Rakefile. The assumption is that the -r files are adequate.
-* Fixed the safe_ln function to fall back to cp in more error
- scenarios.
-
-== Version 0.7.0
-
-* Added Rake.original_dir to return the original starting directory of
- the rake application.
-* Added safe_ln support for openAFS (from Ludvig Omholt).
-* Added --trace reminder on short exception messages (David Heinemeier
- Hansson suggestion).
-* Added multitask declaration that executes prerequisites in
- parallel. (Doug Young providied an initial implementation).
-* Fixed missing_const hack to be compatible with Rails. (Jamis Buck
- supplied test case).
-* Made the RDoc task default to internal (in-process) RDoc formatting.
- The old behavior is still available by setting the +external+ flag
- to true.
-* Rakefiles are now loaded with the expanded path to prevent
- accidental polution from the Ruby load path.
-* The +namespace+ command now returns a NameSpace object that can be
- used to lookup tasks defined in that namespace. This allows for
- better anonymous namespace behavior.
-* Task objects my now be used in prerequisite lists directly.
-
-== Version 0.6.1
-
-* Rebuilt 0.6.0 gem without signing.
-
-== Version 0.6.0
-
-* Fixed file creation bug in the unit tests (caused infinite loop on
- windows).
-* Fixed bug where session based functional tests were run under
- windows.
-* Fixed bug in directory tasks so that updating a directory will not
- retrigger file tasks depending on the directory (see
- FileCreationTask and EarlyTime).
-* Added egrep to FileList
-* ruby command now runs same ruby version as rake.
-* Added investigation to task object. (suggested by Martin Fowler)
-* Added ruby_opts to the test task to allow arbitrary ruby options to
- be passed to the test script. (Greg Fast)
-* Fixed the test loader to ignore options. (Greg Fast)
-* Moved Task, FileTask, FileCreationTask and RakeApp into the Rake
- module namespace. Old style namespace behavior can be invoked via
- the --classic-namespace option. (requested by Kelly Felkins).
-* GemTask is now sensitive to the gem platform (Masao Mutoh).
-* A non-existing file prerequisite will no longer cause an exception
- (Philipp Neubeck).
-* Multiple prerequisites on Rake rules now allowed (initial patch
- supplied by Stuart Jansen).
-
-== Version 0.5.4
-
-* Added double quotes to the test runner.
-* Added .svn to default ignore list.
-* Updated FileList#include to support nested arrays and filelists.
-
-== Version 0.5.3
-
-* Added support for importing Rakefile and other dependencies.
-* Fixed bug so that now rules can chain off of existing tasks as well
- as existing files.
-* Fixed verbose flag bug in the testing task. Shortened some failure
- messages.
-* Make FileUtils methods private at the top level module to avoid
- accidental method leaking into other objects.
-* Added test loader option to test task. "testrb" is no longer the
- default test loader. It is now eating syntax errors that should
- halt the unit tests.
-* Revamped FileList so that it works more like and array (addressed
- flatten bug). Added many tests around file list.
-* Added +ext+ method to both String and FileList.
-
-== Version 0.5.0
-
-* Fixed documentation that was lacking the Rake module name (Tilman
- Sauerbeck).
-* Added tar.gz and tar.bz2 support to package task (Tilman Sauerbeck).
-* Recursive rules are now supported (Tilman Sauerbeck).
-* Added warning option for the Test Task (requested by Eric Hodel).
-* The jamis rdoc template is only used if it exists.
-* Added fix for Ruby 1.8.2 test/unit and rails problem.
-* Added contributed rake man file (Jani Monoses).
-* Added Brian Candler's fix for problems in --trace and --dry-run
- mode.
-
-== Version 0.4.15
-
-* Fixed a bug that prevented the TESTOPTS flag from working with the
- revised for 1.8.2 test task.
-* Updated the docs on --trace to indicate that it also enables a full
- backtrace on errors.
-
-== Version 0.4.14
-
-* Modified the TestTask to workaround the Ruby 1.8.2 change in
- autoexecuting unit tests.
-
-== Version 0.4.13
-
-* Fixed the dry-run flag so it is operating again.
-* Multiple arguments to sh and ruby commands will not be interpreted
- by the shell (patch provided by Jonathan Paisley).
-
-== Version 0.4.12
-
-* Added --silent (-s) to suppress the (in directory) rake message.
-
-== Version 0.4.11
-
-* Changed the "don't know how to rake" message (finally)
-* Changes references to a literal "Rakefile" to reference the global
- variable $rakefile (which contains the actual name of the rakefile).
-
-== Version 0.4.10
-
-* Added block support to the "sh" command, allowing users to take
- special actions on the result of the system call. E.g.
-
- sh "shell_command" do |ok, res|
- puts "Program returned #{res.exitstatus}" if ! ok
- end
-
-== Version 0.4.9
-
-* Switched to Jamis Buck's RDoc template.
-* Removed autorequire from Rake's gem spec. This prevents the Rake
- libraries from loading while using rails.
-
-== Version 0.4.8
-
-* Added support for .rb versions of Rakefile.
-* Removed \\\n's from test task.
-* Fixed Ruby 1.9 compatibility issue with FileList.
-
-== Version 0.4.7
-
-* Fixed problem in FileList that caused Ruby 1.9 to go into infinite
- recursion. Since to_a was removed from Object, it does not need to
- added back into the list of methods to rewrite in FileList. (Thanks
- to Kent Sibilev for pointing this out).
-
-== Version 0.4.6
-* Removed test version of ln in FileUtils that prevented safe_ln from
- using ln.
-
-== Version 0.4.5
-* Upgraded comments in TestTask.
-* FileList to_s and inspect now automatically resolve pending changes.
-* FileList#exclude properly returns the FileList.
-
-== Version 0.4.4
-* Fixed initialization problem with @comment.
-* Now using multi -r technique in TestTask. Switch Rakefile back to
- using the built-in test task macros because the rake runtime is no
- longer needed.
-* Added 'TEST=filename' and 'TESTOPTS=options' to the Test Task
- macros.
-* Allow a +test_files+ attribute in test tasks. This allows more
- flexibility in specifying test files.
-
-== Version 0.4.3
-* Fixed Comment leakage.
-
-== Version 0.4.2
-* Added safe_ln that falls back to a copy if a file link is not supported.
-* Package builder now uses safe_ln.
-
-== Version 0.4.1
-* Task comments are now additive, combined with "/".
-* Works with (soon to be released) rubygems 0.6.2 (or 0.7.0)
-
-== Version 0.4.0
-* FileList now uses deferred loading. The file system is not searched
- until the first call that needs the file names.
-* VAR=VALUE options are now accepted on the command line and are
- treated like environment variables. The values may be tested in a
- Rakefile by referencing ENV['VAR'].
-* File.mtime is now used (instead of File.new().mtime).
-
-== Version 0.3.2.x
-
-* Removed some hidden dependencies on rubygems. Tests now will test
- gems only if they are installed.
-* Removed Sys from some example files. I believe that is that last
- reference to Sys outside of the contrib area.
-* Updated all copyright notices to include 2004.
-
-== Version 0.3.2
-
-* GEM Installation now works with the application stub.
-
-== Version 0.3.1
-
-* FileLists now automatically ignore CVS, .bak, !
-* GEM Installation now works.
-
-== Version 0.3.0
-
-Promoted 0.2.10.
-
-== Version 0.2.10
-General
-
-* Added title to Rake's rdocs
-* Contrib packages are no longer included in the documentation.
-
-RDoc Issues
-
-* Removed default for the '--main' option
-* Fixed rendering of the rdoc options
-* Fixed clean/clobber confusion with rerdoc
-* 'title' attribute added
-
-Package Task Library Issues
-
-* Version (or explicit :noversion) is required.
-* +package_file+ attribute is now writable
-
-FileList Issues
-
-* Dropped bang version of exclude. Now using ant-like include/exclude semantics.
-* Enabled the "yield self" idiom in FileList#initialize.
-
-== Version 0.2.9
-
-This version contains numerous changes as the RubyConf.new(2003)
-presentation was being prepared. The changes include:
-
-* The monolithic rubyapp task library is in the process of being
- dropped in favor of lighter weight task libraries.
-
-== Version 0.2.7
-
-* Added "desc" for task descriptions.
-* -T will now display tasks with descriptions.
-* -P will display tasks and prerequisites.
-* Dropped the Sys module in favor of the 1.8.x FileUtils module. Sys
- is still supported in the contrib area.
-
-== Version 0.2.6
-
-* Moved to RubyForge
-
-== Version 0.2.5
-
-* Switched to standard ruby app builder.
-* Added no_match option to file matcher.
-
-== Version 0.2.4
-
-* Fixed indir, which neglected to actually change directories.
-
-== Version 0.2.3
-
-* Added rake module for a help target
-* Added 'for_files' to Sys
-* Added a $rakefile constant
-* Added test for selecting proper rule with multiple targets.
+++ /dev/null
-Copyright (c) 2003, 2004 Jim Weirich
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
+++ /dev/null
-= RAKE -- Ruby Make
-
-This package contains Rake, a simple ruby build program with capabilities
-similar to make.
-
-Rake has the following features:
-
-* Rakefiles (rake's version of Makefiles) are completely defined in
- standard Ruby syntax. No XML files to edit. No quirky Makefile
- syntax to worry about (is that a tab or a space?)
-
-* Users can specify tasks with prerequisites.
-
-* Rake supports rule patterns to synthesize implicit tasks.
-
-* Flexible FileLists that act like arrays but know about manipulating
- file names and paths.
-
-* A library of prepackaged tasks to make building rakefiles easier. For example,
- tasks for building tarballs and publishing to FTP or SSH sites. (Formerly
- tasks for building RDoc and Gems were included in rake but they're now
- available in RDoc and RubyGems respectively.)
-
-* Supports parallel execution of tasks.
-
-== Installation
-
-=== Gem Installation
-
-Download and install rake with the following.
-
- gem install rake
-
-=== Normal Installation
-
-You can download the source tarball of the latest version of Rake from
-
-* http://rubyforge.org/project/showfiles.php?group_id=50
-
-Extract the tarball and run
-
- % ruby install.rb
-
-from its distribution directory.
-
-== Usage
-
-=== Simple Example
-
-First, you must write a "Rakefile" file which contains the build rules. Here's
-a simple example:
-
- task :default => [:test]
-
- task :test do
- ruby "test/unittest.rb"
- end
-
-This Rakefile has two tasks:
-
-* A task named "test", which - upon invocation - will run a unit test file in
- Ruby.
-* A task named "default". This task does nothing by itself, but it has exactly
- one dependency, namely the "test" task. Invoking the "default" task will
- cause Rake to invoke the "test" task as well.
-
-Running the "rake" command without any options will cause it to run the
-"default" task in the Rakefile:
-
- % ls
- Rakefile test/
- % rake
- (in /home/some_user/Projects/rake)
- ruby test/unittest.rb
- ....unit test output here...
-
-Type "rake --help" for all available options.
-
-
-=== More Information
-
-* For details on Rake's command-line invocation, read
- doc/command_line_usage.rdoc[http://rake.rubyforge.org/files/doc/command_line_usage_rdoc.html]
-* For details on writing Rakefiles, see
- doc/rakefile.rdoc[http://rake.rubyforge.org/files/doc/rakefile_rdoc.html].
-* For the original announcement of Rake, see
- doc/rational.rdoc[http://rake.rubyforge.org/files/doc/rational_rdoc.html].
-* For a glossary of terms, see
- doc/glossary.rdoc[http://rake.rubyforge.org/files/doc/glossary_rdoc.html].
-
-== Development
-
-=== Source Repository
-
-Rake is currently hosted at github. The github web page is
-http://github.com/jimweirich/rake. The public git clone URL is
-
-* git://github.com/jimweirich/rake.git
-
-=== Running the Rake Test Suite
-
-If you wish to run the unit and functional tests that come with Rake:
-
-* Install the 'flexmock' gem
-* Install the 'session' gem in order to run the functional tests.
-* CD into the top project directory of rake.
-* Type one of the following:
-
- rake # If you have a version of rake installed
- ruby -Ilib bin/rake # If you do not have a version of rake installed.
-
-=== Issues and Bug Reports
-
-Feature requests and bug reports can be made here
-
-* https://github.com/jimweirich/rake/issues
-
-Issues and bug reports can also be tracked here:
-
-* http://www.pivotaltracker.com/projects/28469
-
-== Online Resources
-
-=== Rake References
-
-* Rake Documentation Home: http://docs.rubyrake.org
-* Rake Project Page: http://rubyforge.org/projects/rake
-* Rake API Documents: http://rake.rubyforge.org
-* Rake Source Code Repo: http://github.com/jimweirich/rake
-* Rake Git Repo Clone URL: git://github.com/jimweirich/rake.git
-* Rake Issue Tracking: http://www.pivotaltracker.com/projects/28469
-* Rake Bug Reports: https://github.com/jimweirich/rake/issues
-
-=== Presentations and Articles about Rake
-
-* Jim Weirich's 2003 RubyConf presentation:
- http://onestepback.org/articles/buildingwithrake/
-* Martin Fowler's article on Rake: http://martinfowler.com/articles/rake.html
-
-== Other Make Reinvisionings ...
-
-Rake is a late entry in the make replacement field. Here are links to
-other projects with similar (and not so similar) goals.
-
-* http://directory.fsf.org/bras.html -- Bras, one of earliest
- implementations of "make in a scripting language".
-* http://www.a-a-p.org -- Make in Python
-* http://www.aromatic.com/tools/jam.txt -- JAM, Java Automated Make
-* http://ant.apache.org -- The Ant project
-* http://ppt.perl.org/commands/make/index.html -- Make from the Perl
- Power Tools implementation.
-* http://search.cpan.org/search?query=PerlBuildSystem -- The Perl Build System
-* http://make.rubyforge.org -- Rant, another Ruby make tool.
-
-== Credits
-
-[<b>Ryan Dlugosz</b>] For the initial conversation that sparked Rake.
-
-[<b>nobu.nokada@softhome.net</b>] For the initial patch for rule support.
-
-[<b>Tilman Sauerbeck <tilman@code-monkey.de></b>] For the recursive rule patch.
-
-== License
-
-Rake is available under an MIT-style license.
-
-:include: MIT-LICENSE
-
-== Support
-
-The Rake homepage is http://rake.rubyforge.org. You can find the Rake
-RubyForge page at http://rubyforge.org/projects/rake.
-
-Feel free to submit commits or feature requests. If you send a patch,
-remember to update the corresponding unit tests. In fact, I prefer
-new feature to be submitted in the form of new unit tests.
-
-For other information, feel free to ask on the ruby-talk mailing list
-(which is mirrored to comp.lang.ruby) or contact
-jim dot weirich at gmail.com.
-
----
-
-= Other stuff
-
-Author:: Jim Weirich <jim.weirich@gmail.com>
-Requires:: Ruby 1.8.6 or later
-License:: Copyright 2003-2008 by Jim Weirich.
- Released under an MIT-style license. See the LICENSE file
- included in the distribution.
-
-== Warranty
-
-This software is provided "as is" and without any express or
-implied warranties, including, without limitation, the implied
-warranties of merchantibility and fitness for a particular
-purpose.
+++ /dev/null
-# Rakefile for rake -*- ruby -*-
-
-# Copyright 2003, 2004, 2005 by Jim Weirich (jim@weirichhouse.org)
-# All rights reserved.
-
-# This file may be distributed under an MIT style license. See
-# MIT-LICENSE for details.
-
-require 'rbconfig'
-require 'rubygems'
-
-system_rake = File.join RbConfig::CONFIG['rubylibdir'], 'rake.rb'
-
-# Use our rake, not the installed rake from system
-if $".include? system_rake or $".grep(/rake\/name_space\.rb$/).empty? then
- exec Gem.ruby, '-Ilib', 'bin/rake', *ARGV
-end
-
-require 'rubygems/package_task'
-
-require 'rake/clean'
-require 'rake/testtask'
-
-begin
- gem 'rdoc'
- require 'rdoc/task'
-rescue Gem::LoadError
-end
-
-CLEAN.include('**/*.o', '*.dot', '**/*.rbc')
-CLOBBER.include('doc/example/main')
-CLOBBER.include('TAGS')
-CLOBBER.include('coverage', 'rcov_aggregate')
-
-# Prevent OS X from including extended attribute junk in the tar output
-ENV['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
-
-def announce(msg='')
- STDERR.puts msg
-end
-
-# Determine the current version of the software
-
-if `ruby -Ilib ./bin/rake --version` =~ /rake, version ([0-9a-z.]+)$/
- CURRENT_VERSION = $1
-else
- CURRENT_VERSION = "0.0.0"
-end
-
-$package_version = CURRENT_VERSION
-
-SRC_RB = FileList['lib/**/*.rb']
-
-# The default task is run if rake is given no explicit arguments.
-
-desc "Default Task"
-task :default => :test
-
-# Test Tasks ---------------------------------------------------------
-
-Rake::TestTask.new do |t|
- files = FileList['test/helper.rb', 'test/test_*.rb']
- t.test_files = files
- t.libs << "."
- t.warning = true
-end
-
-begin
- require 'rcov/rcovtask'
- IGNORE_COVERAGE_IN = FileList[
- 'lib/rake/rdoctask.rb',
- 'lib/rake/testtask.rb',
- 'lib/rake/packagetask.rb',
- 'lib/rake/clean.rb',
- ]
-
- unless File::ALT_SEPARATOR
- IGNORE_COVERAGE_IN.include(
- 'lib/rake/alt_system.rb',
- 'lib/rake/win32.rb')
- end
-
- Rcov::RcovTask.new do |t|
- t.libs << "test"
- t.rcov_opts = [
- '-xRakefile', '-xrakefile', '-xpublish.rf',
- '-xlib/rake/contrib', '-x/Library', '-x.rvm',
- '--text-report',
- '--sort coverage'
- ] + FileList['rakelib/*.rake'].pathmap("-x%p") +
- IGNORE_COVERAGE_IN.map { |fn| "-x#{fn}" }
- t.test_files = FileList[
- 'test/lib/*_test.rb',
- 'test/contrib/*_test.rb',
- 'test/functional/*_test.rb'
- ]
- t.output_dir = 'coverage'
- t.verbose = true
- end
-rescue LoadError
- task :rcov do
- puts "RCov is not available"
- end
-end
-
-# CVS Tasks ----------------------------------------------------------
-
-# Install rake using the standard install.rb script.
-
-desc "Install the application"
-task :install do
- ruby "install.rb"
-end
-
-# Create a task to build the RDOC documentation tree.
-
-BASE_RDOC_OPTIONS = [
- '--line-numbers', '--show-hash',
- '--main', 'README.rdoc',
- '--title', 'Rake -- Ruby Make'
-]
-
-if defined?(RDoc::Task) then
- RDoc::Task.new do |rdoc|
- rdoc.rdoc_dir = 'html'
- rdoc.title = "Rake -- Ruby Make"
- rdoc.options = BASE_RDOC_OPTIONS.dup
-
- rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES')
- rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
- rdoc.rdoc_files.exclude(/\bcontrib\b/)
- end
-else
- warn "RDoc 2.4.2+ is required to build documentation"
-end
-
-# ====================================================================
-# Create a task that will package the Rake software into distributable
-# tar, zip and gem files.
-
-PKG_FILES = FileList[
- '.gemtest',
- 'install.rb',
- '[A-Z]*',
- 'bin/rake',
- 'lib/**/*.rb',
- 'test/**/*.rb',
- 'doc/**/*'
-]
-PKG_FILES.exclude('doc/example/*.o')
-PKG_FILES.exclude('TAGS')
-PKG_FILES.exclude(%r{doc/example/main$})
-
-if ! defined?(Gem)
- puts "Package Target requires RubyGems"
-else
- SPEC = Gem::Specification.new do |s|
- s.name = 'rake'
- s.version = $package_version
- s.summary = "Ruby based make-like utility."
- s.description = <<-EOF.delete "\n"
-Rake is a Make-like program implemented in Ruby. Tasks and dependencies are
-specified in standard Ruby syntax.
- EOF
-
- s.required_ruby_version = '>= 1.8.6'
- s.required_rubygems_version = '>= 1.3.2'
- s.add_development_dependency 'minitest', '~> 2.1'
-
- s.files = PKG_FILES.to_a
-
- s.executables = ["rake"]
-
- s.extra_rdoc_files = FileList[
- 'README.rdoc',
- 'MIT-LICENSE',
- 'TODO',
- 'CHANGES',
- 'doc/**/*.rdoc'
- ]
-
- s.rdoc_options = BASE_RDOC_OPTIONS
-
- s.author = "Jim Weirich"
- s.email = "jim@weirichhouse.org"
- s.homepage = "http://rake.rubyforge.org"
- s.rubyforge_project = "rake"
- end
-
- Gem::PackageTask.new(SPEC) do |pkg|
- pkg.need_zip = true
- pkg.need_tar = true
- end
-
- file "rake.gemspec" => ["Rakefile", "lib/rake.rb"] do |t|
- require 'yaml'
- open(t.name, "w") { |f| f.puts SPEC.to_yaml }
- end
-
- desc "Create a stand-alone gemspec"
- task :gemspec => "rake.gemspec"
-end
-
-# Misc tasks =========================================================
-
-def count_lines(filename)
- lines = 0
- codelines = 0
- open(filename) { |f|
- f.each do |line|
- lines += 1
- next if line =~ /^\s*$/
- next if line =~ /^\s*#/
- codelines += 1
- end
- }
- [lines, codelines]
-end
-
-def show_line(msg, lines, loc)
- printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
-end
-
-desc "Count lines in the main rake file"
-task :lines do
- total_lines = 0
- total_code = 0
- show_line("File Name", "LINES", "LOC")
- SRC_RB.each do |fn|
- lines, codelines = count_lines(fn)
- show_line(fn, lines, codelines)
- total_lines += lines
- total_code += codelines
- end
- show_line("TOTAL", total_lines, total_code)
-end
-
-# Define an optional publish target in an external file. If the
-# publish.rf file is not found, the publish targets won't be defined.
-
-load "publish.rf" if File.exist? "publish.rf"
-
-# Support Tasks ------------------------------------------------------
-
-RUBY_FILES = FileList['**/*.rb'].exclude('pkg')
-
-desc "Look for TODO and FIXME tags in the code"
-task :todo do
- RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/)
-end
-
-desc "List all ruby files"
-task :rubyfiles do
- puts RUBY_FILES
- puts FileList['bin/*'].exclude('bin/*.rb')
-end
-task :rf => :rubyfiles
-
-# --------------------------------------------------------------------
-# Creating a release
-
-def plugin(plugin_name)
- require "rake/plugins/#{plugin_name}"
-end
-
-task :noop
-#plugin "release_manager"
-
-desc "Make a new release"
-task :release, [:rel, :reuse, :reltest] => [
- :prerelease,
- :clobber,
- :test,
- :update_version,
- :package,
- :tag
- ] do
- announce
- announce "**************************************************************"
- announce "* Release #{$package_version} Complete."
- announce "* Packages ready to upload."
- announce "**************************************************************"
- announce
-end
-
-# Validate that everything is ready to go for a release.
-task :prerelease, :rel, :reuse, :reltest do |t, args|
- $package_version = args.rel
- announce
- announce "**************************************************************"
- announce "* Making RubyGem Release #{$package_version}"
- announce "* (current version #{CURRENT_VERSION})"
- announce "**************************************************************"
- announce
-
- # Is a release number supplied?
- unless args.rel
- fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]"
- end
-
- # Is the release different than the current release.
- # (or is REUSE set?)
- if $package_version == CURRENT_VERSION && ! args.reuse
- fail "Current version is #{$package_version}, must specify REUSE=tag_suffix to reuse version"
- end
-
- # Are all source files checked in?
- if args.reltest
- announce "Release Task Testing, skipping checked-in file test"
- else
- announce "Checking for unchecked-in files..."
- data = `svn st`
- unless data =~ /^$/
- abort "svn status is not clean ... do you have unchecked-in files?"
- end
- announce "No outstanding checkins found ... OK"
- end
-end
-
-task :update_version, [:rel, :reuse, :reltest] => [:prerelease] do |t, args|
- if args.rel == CURRENT_VERSION
- announce "No version change ... skipping version update"
- else
- announce "Updating Rake version to #{args.rel}"
- open("lib/rake.rb") do |rakein|
- open("lib/rake.rb.new", "w") do |rakeout|
- rakein.each do |line|
- if line =~ /^RAKEVERSION\s*=\s*/
- rakeout.puts "RAKEVERSION = '#{args.rel}'"
- else
- rakeout.puts line
- end
- end
- end
- end
- mv "lib/rake.rb.new", "lib/rake.rb"
- if args.reltest
- announce "Release Task Testing, skipping commiting of new version"
- else
- sh %{svn commit -m "Updated to version #{args.rel}" lib/rake.rb} # "
- end
- end
-end
-
-desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
-task :tag, [:rel, :reuse, :reltest] => [:prerelease] do |t, args|
- reltag = "REL_#{args.rel.gsub(/\./, '_')}"
- reltag << args.reuse.gsub(/\./, '_') if args.reuse
- announce "Tagging Repository with [#{reltag}]"
- if args.reltest
- announce "Release Task Testing, skipping CVS tagging"
- else
- sh %{svn copy svn+ssh://rubyforge.org/var/svn/rake/trunk svn+ssh://rubyforge.org/var/svn/rake/tags/#{reltag} -m 'Commiting release #{reltag}'} ###'
- end
-end
-
-# Require experimental XForge/Metaproject support.
-
-load 'xforge.rf' if File.exist?('xforge.rf')
-
-desc "Where is the current directory. This task displays\nthe current rake directory"
-task :where_am_i do
- puts Rake.original_dir
-end
-
-task :failure => :really_fail
-task :really_fail do
- fail "oops"
-end
+++ /dev/null
-= Rake Project -- To Do List
-
-Send suggestions for this list to mailto:jim@weirichhouse.org or on
-the rake-devel@rubyforge.org mailing list.
-
-=== To Do
-* Need a nice API for accessing tasks in namespaces, namespaces in an app, etc.
-* Provide a way to disable -w warning mode.
-* Define a set of default rules that work in the absence of any Rakefile
-* What about cyclic dependencies?
-* Java support utilities
-* Installation support utilities
- * Check out installpkg.rb
-* Autogenerate Dependencies
-* Rules should apply to existing tasks if no actions are defined.
-* How to create multiple package tasks without task name collision?
-* Trap "ln -s" commands that fail and use "cp" instead (SMB mounted
- drives have problems with "ln -s".
-
-(moved DONE list to CHANGES file)
+++ /dev/null
-require 'rbconfig'
-require 'find'
-require 'fileutils'
-
-include RbConfig
-
-$ruby = CONFIG['ruby_install_name']
-
-##
-# Install a binary file. We patch in on the way through to
-# insert a #! line. If this is a Unix install, we name
-# the command (for example) 'rake' and let the shebang line
-# handle running it. Under windows, we add a '.rb' extension
-# and let file associations to their stuff
-#
-
-def installBIN(from, opfile)
-
- tmp_dir = nil
- for t in [".", "/tmp", "c:/temp", $bindir]
- stat = File.stat(t) rescue next
- if stat.directory? and stat.writable?
- tmp_dir = t
- break
- end
- end
-
- fail "Cannot find a temporary directory" unless tmp_dir
- tmp_file = File.join(tmp_dir, "_tmp")
-
- File.open(from) do |ip|
- File.open(tmp_file, "w") do |op|
- ruby = File.join($realbindir, $ruby)
- op.puts "#!#{ruby} -w"
- op.write ip.read
- end
- end
-
- opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
- FileUtils.install(tmp_file, File.join($bindir, opfile),
- {:mode => 0755, :verbose => true})
- File.unlink(tmp_file)
-end
-
-$sitedir = CONFIG["sitelibdir"]
-unless $sitedir
- version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
- $libdir = File.join(CONFIG["libdir"], "ruby", version)
- $sitedir = $:.find {|x| x =~ /site_ruby/}
- if !$sitedir
- $sitedir = File.join($libdir, "site_ruby")
- elsif $sitedir !~ Regexp.quote(version)
- $sitedir = File.join($sitedir, version)
- end
-end
-
-$bindir = CONFIG["bindir"]
-
-$realbindir = $bindir
-
-bindir = CONFIG["bindir"]
-if (destdir = ENV['DESTDIR'])
- $bindir = destdir + $bindir
- $sitedir = destdir + $sitedir
-
- FileUtils.mkdir_p($bindir)
- FileUtils.mkdir_p($sitedir)
-end
-
-rake_dest = File.join($sitedir, "rake")
-FileUtils.mkdir_p(rake_dest, {:verbose => true})
-File.chmod(0755, rake_dest)
-
-# The library files
-
-files = Dir.chdir('lib') { Dir['**/*.rb'] }
-
-for fn in files
- fn_dir = File.dirname(fn)
- target_dir = File.join($sitedir, fn_dir)
- if ! File.exist?(target_dir)
- FileUtils.mkdir_p(target_dir)
- end
- FileUtils.install(File.join('lib', fn), File.join($sitedir, fn),
- {:mode => 0644, :verbose => true})
-end
-
-# and the executable
-
-installBIN("bin/rake", "rake")
+++ /dev/null
-#--
-
-# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#++
-
-require 'rake/version'
-
-# :stopdoc:
-RAKEVERSION = Rake::VERSION
-# :startdoc:
-
-require 'rbconfig'
-require 'fileutils'
-require 'singleton'
-require 'monitor'
-require 'optparse'
-require 'ostruct'
-
-require 'rake/ext/module'
-require 'rake/ext/string'
-require 'rake/ext/time'
-
-require 'rake/win32'
-
-require 'rake/task_argument_error'
-require 'rake/rule_recursion_overflow_error'
-require 'rake/rake_module'
-require 'rake/pseudo_status'
-require 'rake/task_arguments'
-require 'rake/invocation_chain'
-require 'rake/task'
-require 'rake/file_task'
-require 'rake/file_creation_task'
-require 'rake/multi_task'
-require 'rake/dsl_definition'
-require 'rake/file_utils_ext'
-require 'rake/file_list'
-require 'rake/default_loader'
-require 'rake/early_time'
-require 'rake/name_space'
-require 'rake/task_manager'
-require 'rake/application'
-
-$trace = false
-
-# :stopdoc:
-#
-# Some top level Constants.
-
-FileList = Rake::FileList
-RakeFileUtils = Rake::FileUtilsExt
+++ /dev/null
-#
-# Copyright (c) 2008 James M. Lawrence
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation files
-# (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge,
-# publish, distribute, sublicense, and/or sell copies of the Software,
-# and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-require 'rbconfig'
-
-#
-# Alternate implementations of system() and backticks `` on Windows
-# for ruby-1.8 and earlier.
-#
-module Rake::AltSystem
- WINDOWS = RbConfig::CONFIG["host_os"] =~
- %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
-
- class << self
- def define_module_function(name, &block)
- define_method(name, &block)
- module_function(name)
- end
- end
-
- if WINDOWS and RUBY_VERSION < "1.9.0"
- RUNNABLE_EXTS = %w[com exe bat cmd]
- RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
-
- define_module_function :kernel_system, &Kernel.method(:system)
- define_module_function :kernel_backticks, &Kernel.method(:'`')
-
- module_function
-
- def repair_command(cmd)
- "call " + (
- if cmd =~ %r!\A\s*\".*?\"!
- # already quoted
- cmd
- elsif match = cmd.match(%r!\A\s*(\S+)!)
- if match[1] =~ %r!/!
- # avoid x/y.bat interpretation as x with option /y
- %Q!"#{match[1]}"! + match.post_match
- else
- # a shell command will fail if quoted
- cmd
- end
- else
- # empty or whitespace
- cmd
- end
- )
- end
-
- def find_runnable(file)
- if file =~ RUNNABLE_PATTERN
- file
- else
- RUNNABLE_EXTS.each { |ext|
- if File.exist?(test = "#{file}.#{ext}")
- return test
- end
- }
- nil
- end
- end
-
- def system(cmd, *args)
- repaired = (
- if args.empty?
- [repair_command(cmd)]
- elsif runnable = find_runnable(cmd)
- [File.expand_path(runnable), *args]
- else
- # non-existent file
- [cmd, *args]
- end
- )
- kernel_system(*repaired)
- end
-
- def backticks(cmd)
- kernel_backticks(repair_command(cmd))
- end
-
- define_module_function :'`', &method(:backticks)
- else
- # Non-Windows or ruby-1.9+: same as Kernel versions
- define_module_function :system, &Kernel.method(:system)
- define_module_function :backticks, &Kernel.method(:'`')
- define_module_function :'`', &Kernel.method(:'`')
- end
-end
+++ /dev/null
-require 'shellwords'
-require 'optparse'
-
-require 'rake/task_manager'
-require 'rake/win32'
-
-module Rake
-
- ######################################################################
- # Rake main application object. When invoking +rake+ from the
- # command line, a Rake::Application object is created and run.
- #
- class Application
- include TaskManager
-
- # The name of the application (typically 'rake')
- attr_reader :name
-
- # The original directory where rake was invoked.
- attr_reader :original_dir
-
- # Name of the actual rakefile used.
- attr_reader :rakefile
-
- # Number of columns on the terminal
- attr_accessor :terminal_columns
-
- # List of the top level task names (task names from the command line).
- attr_reader :top_level_tasks
-
- DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
-
- # Initialize a Rake::Application object.
- def initialize
- super
- @name = 'rake'
- @rakefiles = DEFAULT_RAKEFILES.dup
- @rakefile = nil
- @pending_imports = []
- @imported = []
- @loaders = {}
- @default_loader = Rake::DefaultLoader.new
- @original_dir = Dir.pwd
- @top_level_tasks = []
- add_loader('rb', DefaultLoader.new)
- add_loader('rf', DefaultLoader.new)
- add_loader('rake', DefaultLoader.new)
- @tty_output = STDOUT.tty?
- @terminal_columns = ENV['RAKE_COLUMNS'].to_i
- end
-
- # Run the Rake application. The run method performs the following
- # three steps:
- #
- # * Initialize the command line options (+init+).
- # * Define the tasks (+load_rakefile+).
- # * Run the top level tasks (+run_tasks+).
- #
- # If you wish to build a custom rake command, you should call
- # +init+ on your application. Then define any tasks. Finally,
- # call +top_level+ to run your top level tasks.
- def run
- standard_exception_handling do
- init
- load_rakefile
- top_level
- end
- end
-
- # Initialize the command line parameters and app name.
- def init(app_name='rake')
- standard_exception_handling do
- @name = app_name
- handle_options
- collect_tasks
- end
- end
-
- # Find the rakefile and then load it and any pending imports.
- def load_rakefile
- standard_exception_handling do
- raw_load_rakefile
- end
- end
-
- # Run the top level tasks of a Rake application.
- def top_level
- standard_exception_handling do
- if options.show_tasks
- display_tasks_and_comments
- elsif options.show_prereqs
- display_prerequisites
- else
- top_level_tasks.each { |task_name| invoke_task(task_name) }
- end
- end
- end
-
- # Add a loader to handle imported files ending in the extension
- # +ext+.
- def add_loader(ext, loader)
- ext = ".#{ext}" unless ext =~ /^\./
- @loaders[ext] = loader
- end
-
- # Application options from the command line
- def options
- @options ||= OpenStruct.new
- end
-
- # private ----------------------------------------------------------------
-
- def invoke_task(task_string)
- name, args = parse_task_string(task_string)
- t = self[name]
- t.invoke(*args)
- end
-
- def parse_task_string(string)
- if string =~ /^([^\[]+)(\[(.*)\])$/
- name = $1
- args = $3.split(/\s*,\s*/)
- else
- name = string
- args = []
- end
- [name, args]
- end
-
- # Provide standard exception handling for the given block.
- def standard_exception_handling
- begin
- yield
- rescue SystemExit => ex
- # Exit silently with current status
- raise
- rescue OptionParser::InvalidOption => ex
- $stderr.puts ex.message
- exit(false)
- rescue Exception => ex
- # Exit with error message
- display_error_message(ex)
- exit(false)
- end
- end
-
- # Display the error message that caused the exception.
- def display_error_message(ex)
- $stderr.puts "#{name} aborted!"
- $stderr.puts ex.message
- if options.trace
- $stderr.puts ex.backtrace.join("\n")
- else
- $stderr.puts rakefile_location(ex.backtrace)
- end
- $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex)
- $stderr.puts "(See full trace by running task with --trace)" unless options.trace
- end
-
- # Warn about deprecated usage.
- #
- # Example:
- # Rake.application.deprecate("import", "Rake.import", caller.first)
- #
- def deprecate(old_usage, new_usage, call_site)
- return if options.ignore_deprecate
- $stderr.puts "WARNING: '#{old_usage}' is deprecated. " +
- "Please use '#{new_usage}' instead.\n" +
- " at #{call_site}"
- end
-
- # Does the exception have a task invocation chain?
- def has_chain?(exception)
- exception.respond_to?(:chain) && exception.chain
- end
- private :has_chain?
-
- # True if one of the files in RAKEFILES is in the current directory.
- # If a match is found, it is copied into @rakefile.
- def have_rakefile
- @rakefiles.each do |fn|
- if File.exist?(fn)
- others = Dir.glob(fn, File::FNM_CASEFOLD)
- return others.size == 1 ? others.first : fn
- elsif fn == ''
- return fn
- end
- end
- return nil
- end
-
- # True if we are outputting to TTY, false otherwise
- def tty_output?
- @tty_output
- end
-
- # Override the detected TTY output state (mostly for testing)
- def tty_output=( tty_output_state )
- @tty_output = tty_output_state
- end
-
- # We will truncate output if we are outputting to a TTY or if we've been
- # given an explicit column width to honor
- def truncate_output?
- tty_output? || @terminal_columns.nonzero?
- end
-
- # Display the tasks and comments.
- def display_tasks_and_comments
- displayable_tasks = tasks.select { |t|
- t.comment && t.name =~ options.show_task_pattern
- }
- case options.show_tasks
- when :tasks
- width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
- max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
-
- displayable_tasks.each do |t|
- printf "#{name} %-#{width}s # %s\n",
- t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
- end
- when :describe
- displayable_tasks.each do |t|
- puts "#{name} #{t.name_with_args}"
- t.full_comment.split("\n").each do |line|
- puts " #{line}"
- end
- puts
- end
- when :lines
- displayable_tasks.each do |t|
- t.locations.each do |loc|
- printf "#{name} %-30s %s\n",t.name_with_args, loc
- end
- end
- else
- fail "Unknown show task mode: '#{options.show_tasks}'"
- end
- end
-
- def terminal_width
- if @terminal_columns.nonzero?
- result = @terminal_columns
- else
- result = unix? ? dynamic_width : 80
- end
- (result < 10) ? 80 : result
- rescue
- 80
- end
-
- # Calculate the dynamic width of the
- def dynamic_width
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
- end
-
- def dynamic_width_stty
- %x{stty size 2>/dev/null}.split[1].to_i
- end
-
- def dynamic_width_tput
- %x{tput cols 2>/dev/null}.to_i
- end
-
- def unix?
- RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
- end
-
- def windows?
- Win32.windows?
- end
-
- def truncate(string, width)
- if string.length <= width
- string
- else
- ( string[0, width-3] || "" ) + "..."
- end
- end
-
- # Display the tasks and prerequisites
- def display_prerequisites
- tasks.each do |t|
- puts "#{name} #{t.name}"
- t.prerequisites.each { |pre| puts " #{pre}" }
- end
- end
-
- # A list of all the standard options used in rake, suitable for
- # passing to OptionParser.
- def standard_rake_options
- [
- ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
- lambda { |value|
- require 'rake/classic_namespace'
- options.classic_namespace = true
- }
- ],
- ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
- lambda { |value|
- options.show_tasks = :describe
- options.show_task_pattern = Regexp.new(value || '')
- TaskManager.record_task_metadata = true
- }
- ],
- ['--dry-run', '-n', "Do a dry run without executing actions.",
- lambda { |value|
- Rake.verbose(true)
- Rake.nowrite(true)
- options.dryrun = true
- options.trace = true
- }
- ],
- ['--execute', '-e CODE', "Execute some Ruby code and exit.",
- lambda { |value|
- eval(value)
- exit
- }
- ],
- ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
- lambda { |value|
- puts eval(value)
- exit
- }
- ],
- ['--execute-continue', '-E CODE',
- "Execute some Ruby code, then continue with normal task processing.",
- lambda { |value| eval(value) }
- ],
- ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
- lambda { |value| $:.push(value) }
- ],
- ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
- lambda { |value| options.nosearch = true }
- ],
- ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
- lambda { |value| options.show_prereqs = true }
- ],
- ['--quiet', '-q', "Do not log messages to standard output.",
- lambda { |value| Rake.verbose(false) }
- ],
- ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
- lambda { |value|
- value ||= ''
- @rakefiles.clear
- @rakefiles << value
- }
- ],
- ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
- # HACK Use File::PATH_SEPARATOR
- lambda { |value| options.rakelib = value.split(':') }
- ],
- ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
- lambda { |value|
- begin
- require value
- rescue LoadError => ex
- begin
- rake_require value
- rescue LoadError
- raise ex
- end
- end
- }
- ],
- ['--rules', "Trace the rules resolution.",
- lambda { |value| options.trace_rules = true }
- ],
- ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
- lambda { |value|
- Rake.verbose(false)
- options.silent = true
- }
- ],
- ['--system', '-g',
- "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
- lambda { |value| options.load_system = true }
- ],
- ['--no-system', '--nosystem', '-G',
- "Use standard project Rakefile search paths, ignore system wide rakefiles.",
- lambda { |value| options.ignore_system = true }
- ],
- ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
- lambda { |value|
- options.show_tasks = :tasks
- options.show_task_pattern = Regexp.new(value || '')
- Rake::TaskManager.record_task_metadata = true
- }
- ],
- ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
- lambda { |value|
- options.trace = true
- Rake.verbose(true)
- }
- ],
- ['--verbose', '-v', "Log message to standard output.",
- lambda { |value| Rake.verbose(true) }
- ],
- ['--version', '-V', "Display the program version.",
- lambda { |value|
- puts "rake, version #{RAKEVERSION}"
- exit
- }
- ],
- ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
- lambda { |value|
- options.show_tasks = :lines
- options.show_task_pattern = Regexp.new(value || '')
- Rake::TaskManager.record_task_metadata = true
- }
- ],
- ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
- lambda { |value|
- options.ignore_deprecate = true
- }
- ],
- ]
- end
-
- # Read and handle the command line options.
- def handle_options
- options.rakelib = ['rakelib']
-
- OptionParser.new do |opts|
- opts.banner = "rake [-f rakefile] {options} targets..."
- opts.separator ""
- opts.separator "Options are ..."
-
- opts.on_tail("-h", "--help", "-H", "Display this help message.") do
- puts opts
- exit
- end
-
- standard_rake_options.each { |args| opts.on(*args) }
- opts.environment('RAKEOPT')
- end.parse!
-
- # If class namespaces are requested, set the global options
- # according to the values in the options structure.
- if options.classic_namespace
- $show_tasks = options.show_tasks
- $show_prereqs = options.show_prereqs
- $trace = options.trace
- $dryrun = options.dryrun
- $silent = options.silent
- end
- end
-
- # Similar to the regular Ruby +require+ command, but will check
- # for *.rake files in addition to *.rb files.
- def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
- fn = file_name + ".rake"
- return false if loaded.include?(fn)
- paths.each do |path|
- full_path = File.join(path, fn)
- if File.exist?(full_path)
- Rake.load_rakefile(full_path)
- loaded << fn
- return true
- end
- end
- fail LoadError, "Can't find #{file_name}"
- end
-
- def find_rakefile_location
- here = Dir.pwd
- while ! (fn = have_rakefile)
- Dir.chdir("..")
- if Dir.pwd == here || options.nosearch
- return nil
- end
- here = Dir.pwd
- end
- [fn, here]
- ensure
- Dir.chdir(Rake.original_dir)
- end
-
- def print_rakefile_directory(location)
- $stderr.puts "(in #{Dir.pwd})" unless
- options.silent or original_dir == location
- end
-
- def raw_load_rakefile # :nodoc:
- rakefile, location = find_rakefile_location
- if (! options.ignore_system) &&
- (options.load_system || rakefile.nil?) &&
- system_dir && File.directory?(system_dir)
- print_rakefile_directory(location)
- glob("#{system_dir}/*.rake") do |name|
- add_import name
- end
- else
- fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
- rakefile.nil?
- @rakefile = rakefile
- Dir.chdir(location)
- print_rakefile_directory(location)
- $rakefile = @rakefile if options.classic_namespace
- Rake.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
- options.rakelib.each do |rlib|
- glob("#{rlib}/*.rake") do |name|
- add_import name
- end
- end
- end
- load_imports
- end
-
- def glob(path, &block)
- Dir[path.gsub("\\", '/')].each(&block)
- end
- private :glob
-
- # The directory path containing the system wide rakefiles.
- def system_dir
- @system_dir ||=
- begin
- if ENV['RAKE_SYSTEM']
- ENV['RAKE_SYSTEM']
- else
- standard_system_dir
- end
- end
- end
-
- # The standard directory containing system wide rake files.
- if Win32.windows?
- def standard_system_dir #:nodoc:
- Win32.win32_system_dir
- end
- else
- def standard_system_dir #:nodoc:
- File.join(File.expand_path('~'), '.rake')
- end
- end
- private :standard_system_dir
-
- # Collect the list of tasks on the command line. If no tasks are
- # given, return a list containing only the default task.
- # Environmental assignments are processed at this time as well.
- def collect_tasks
- @top_level_tasks = []
- ARGV.each do |arg|
- if arg =~ /^(\w+)=(.*)$/
- ENV[$1] = $2
- else
- @top_level_tasks << arg unless arg =~ /^-/
- end
- end
- @top_level_tasks.push("default") if @top_level_tasks.size == 0
- end
-
- # Add a file to the list of files to be imported.
- def add_import(fn)
- @pending_imports << fn
- end
-
- # Load the pending list of imported files.
- def load_imports
- while fn = @pending_imports.shift
- next if @imported.member?(fn)
- if fn_task = lookup(fn)
- fn_task.invoke
- end
- ext = File.extname(fn)
- loader = @loaders[ext] || @default_loader
- loader.load(fn)
- @imported << fn
- end
- end
-
- # Warn about deprecated use of top level constant names.
- def const_warning(const_name)
- @const_warning ||= false
- if ! @const_warning
- $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
- %{found at: #{rakefile_location}} # '
- $stderr.puts %{ Use --classic-namespace on rake command}
- $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
- end
- @const_warning = true
- end
-
- def rakefile_location backtrace = caller
- backtrace.map { |t| t[/([^:]+):/,1] }
-
- re = /^#{@rakefile}$/
- re = /#{re.source}/i if windows?
-
- backtrace.find { |str| str =~ re } || ''
- end
- end
-end
+++ /dev/null
-# The following classes used to be in the top level namespace.
-# Loading this file enables compatibility with older Rakefile that
-# referenced Task from the top level.
-
-warn "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake."
-# :stopdoc:
-Task = Rake::Task
-FileTask = Rake::FileTask
-FileCreationTask = Rake::FileCreationTask
-RakeApp = Rake::Application
-# :startdoc:
+++ /dev/null
-# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
-# two rake tasks (:clean and :clobber).
-#
-# [:clean] Clean up the project by deleting scratch files and backup
-# files. Add files to the CLEAN file list to have the :clean
-# target handle them.
-#
-# [:clobber] Clobber all generated and non-source files in a project.
-# The task depends on :clean, so all the clean files will
-# be deleted as well as files in the CLOBBER file list.
-# The intent of this task is to return a project to its
-# pristine, just unpacked state.
-
-require 'rake'
-
-# :stopdoc:
-CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
-CLEAN.clear_exclude.exclude { |fn|
- fn.pathmap("%f") == 'core' && File.directory?(fn)
-}
-
-desc "Remove any temporary products."
-task :clean do
- CLEAN.each { |fn| rm_r fn rescue nil }
-end
-
-CLOBBER = Rake::FileList.new
-
-desc "Remove any generated file."
-task :clobber => [:clean] do
- CLOBBER.each { |fn| rm_r fn rescue nil }
-end
+++ /dev/null
-module Rake
- # ##########################################################################
- # Mixin for creating easily cloned objects.
- #
- module Cloneable
- # Clone an object by making a new object and setting all the instance
- # variables to the same values.
- def dup
- sibling = self.class.new
- instance_variables.each do |ivar|
- value = self.instance_variable_get(ivar)
- new_value = value.clone rescue value
- sibling.instance_variable_set(ivar, new_value)
- end
- sibling.taint if tainted?
- sibling
- end
-
- def clone
- sibling = dup
- sibling.freeze if frozen?
- sibling
- end
- end
-end
+++ /dev/null
-module Rake
-
- # Manage several publishers as a single entity.
- class CompositePublisher
- def initialize
- @publishers = []
- end
-
- # Add a publisher to the composite.
- def add(pub)
- @publishers << pub
- end
-
- # Upload all the individual publishers.
- def upload
- @publishers.each { |p| p.upload }
- end
- end
-
-end
-
+++ /dev/null
-# = Tools for FTP uploading.
-#
-# This file is still under development and is not released for general
-# use.
-
-require 'date'
-require 'net/ftp'
-
-module Rake # :nodoc:
-
- ####################################################################
- # <b>Note:</b> <em> Not released for general use.</em>
- class FtpFile
- attr_reader :name, :size, :owner, :group, :time
-
- def self.date
- @date_class ||= Date
- end
-
- def self.time
- @time_class ||= Time
- end
-
- def initialize(path, entry)
- @path = path
- @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ')
- @size = size.to_i
- @time = determine_time(d1, d2, d3)
- end
-
- def path
- File.join(@path, @name)
- end
-
- def directory?
- @mode[0] == ?d
- end
-
- def mode
- parse_mode(@mode)
- end
-
- def symlink?
- @mode[0] == ?l
- end
-
- private # --------------------------------------------------------
-
- def parse_mode(m)
- result = 0
- (1..9).each do |i|
- result = 2*result + ((m[i]==?-) ? 0 : 1)
- end
- result
- end
-
- def determine_time(d1, d2, d3)
- now = self.class.time.now
- if /:/ =~ d3
- result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
- if result > now
- result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
- end
- else
- result = Time.parse("#{d1} #{d2} #{d3}")
- end
- result
-# elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
-# if elements[0].nil?
-# today = self.class.date.today
-# if elements[1] > today.month
-# elements[0] = today.year - 1
-# else
-# elements[0] = today.year
-# end
-# end
-# elements = elements.collect { |el| el.nil? ? 0 : el }
-# Time.mktime(*elements[0,7])
- end
- end
-
- ####################################################################
- # Manage the uploading of files to an FTP account.
- class FtpUploader
-
- # Log uploads to standard output when true.
- attr_accessor :verbose
-
- class << FtpUploader
- # Create an uploader and pass it to the given block as +up+.
- # When the block is complete, close the uploader.
- def connect(path, host, account, password)
- up = self.new(path, host, account, password)
- begin
- yield(up)
- ensure
- up.close
- end
- end
- end
-
- # Create an FTP uploader targeting the directory +path+ on +host+
- # using the given account and password. +path+ will be the root
- # path of the uploader.
- def initialize(path, host, account, password)
- @created = Hash.new
- @path = path
- @ftp = Net::FTP.new(host, account, password)
- makedirs(@path)
- @ftp.chdir(@path)
- end
-
- # Create the directory +path+ in the uploader root path.
- def makedirs(path)
- route = []
- File.split(path).each do |dir|
- route << dir
- current_dir = File.join(route)
- if @created[current_dir].nil?
- @created[current_dir] = true
- $stderr.puts "Creating Directory #{current_dir}" if @verbose
- @ftp.mkdir(current_dir) rescue nil
- end
- end
- end
-
- # Upload all files matching +wildcard+ to the uploader's root
- # path.
- def upload_files(wildcard)
- Dir[wildcard].each do |fn|
- upload(fn)
- end
- end
-
- # Close the uploader.
- def close
- @ftp.close
- end
-
- private # --------------------------------------------------------
-
- # Upload a single file to the uploader's root path.
- def upload(file)
- $stderr.puts "Uploading #{file}" if @verbose
- dir = File.dirname(file)
- makedirs(dir)
- @ftp.putbinaryfile(file, file) unless File.directory?(file)
- end
- end
-end
+++ /dev/null
-# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
-# All rights reserved.
-
-# :stopdoc:
-
-# Configuration information about an upload host system.
-# name :: Name of host system.
-# webdir :: Base directory for the web information for the
-# application. The application name (APP) is appended to
-# this directory before using.
-# pkgdir :: Directory on the host system where packages can be
-# placed.
-HostInfo = Struct.new(:name, :webdir, :pkgdir)
-
-# :startdoc:
-
-# Manage several publishers as a single entity.
-class CompositePublisher
- def initialize
- @publishers = []
- end
-
- # Add a publisher to the composite.
- def add(pub)
- @publishers << pub
- end
-
- # Upload all the individual publishers.
- def upload
- @publishers.each { |p| p.upload }
- end
-end
-
-# Publish an entire directory to an existing remote directory using
-# SSH.
-class SshDirPublisher
- def initialize(host, remote_dir, local_dir)
- @host = host
- @remote_dir = remote_dir
- @local_dir = local_dir
- end
-
- def upload
- run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
- end
-end
-
-# Publish an entire directory to a fresh remote directory using SSH.
-class SshFreshDirPublisher < SshDirPublisher
- def upload
- run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
- run %{ssh #{@host} mkdir #{@remote_dir}}
- super
- end
-end
-
-# Publish a list of files to an existing remote directory.
-class SshFilePublisher
- # Create a publisher using the give host information.
- def initialize(host, remote_dir, local_dir, *files)
- @host = host
- @remote_dir = remote_dir
- @local_dir = local_dir
- @files = files
- end
-
- # Upload the local directory to the remote directory.
- def upload
- @files.each do |fn|
- run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
- end
- end
-end
+++ /dev/null
-require 'rake/contrib/sshpublisher'
-
-module Rake
-
- class RubyForgePublisher < SshDirPublisher
- attr_reader :project, :proj_id, :user
-
- def initialize(projname, user)
- super(
- "#{user}@rubyforge.org",
- "/var/www/gforge-projects/#{projname}",
- "html")
- end
- end
-
-end
+++ /dev/null
-require 'rake/dsl_definition'
-require 'rake/contrib/compositepublisher'
-
-module Rake
-
- # Publish an entire directory to an existing remote directory using
- # SSH.
- class SshDirPublisher
- include Rake::DSL
-
- def initialize(host, remote_dir, local_dir)
- @host = host
- @remote_dir = remote_dir
- @local_dir = local_dir
- end
-
- def upload
- sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
- end
- end
-
- # Publish an entire directory to a fresh remote directory using SSH.
- class SshFreshDirPublisher < SshDirPublisher
- def upload
- sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
- sh %{ssh #{@host} mkdir #{@remote_dir}}
- super
- end
- end
-
- # Publish a list of files to an existing remote directory.
- class SshFilePublisher
- include Rake::DSL
-
- # Create a publisher using the give host information.
- def initialize(host, remote_dir, local_dir, *files)
- @host = host
- @remote_dir = remote_dir
- @local_dir = local_dir
- @files = files
- end
-
- # Upload the local directory to the remote directory.
- def upload
- @files.each do |fn|
- sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
- end
- end
- end
-end
+++ /dev/null
-warn 'Sys has been deprecated in favor of FileUtils'
-
-#--
-# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com)
-# All rights reserved.
-#++
-#
-begin
- require 'ftools'
-rescue LoadError
-end
-require 'rbconfig'
-
-######################################################################
-# Sys provides a number of file manipulation tools for the convenience
-# of writing Rakefiles. All commands in this module will announce
-# their activity on standard output if the $verbose flag is set
-# ($verbose = true is the default). You can control this by globally
-# setting $verbose or by using the +verbose+ and +quiet+ methods.
-#
-# Sys has been deprecated in favor of the FileUtils module available
-# in Ruby 1.8.
-#
-module Sys
- RUBY = RbConfig::CONFIG['ruby_install_name']
-
- # Install all the files matching +wildcard+ into the +dest_dir+
- # directory. The permission mode is set to +mode+.
- def install(wildcard, dest_dir, mode)
- Dir[wildcard].each do |fn|
- File.install(fn, dest_dir, mode, $verbose)
- end
- end
-
- # Run the system command +cmd+.
- def run(cmd)
- log cmd
- system(cmd) or fail "Command Failed: [#{cmd}]"
- end
-
- # Run a Ruby interpreter with the given arguments.
- def ruby(*args)
- run "#{RUBY} #{args.join(' ')}"
- end
-
- # Copy a single file from +file_name+ to +dest_file+.
- def copy(file_name, dest_file)
- log "Copying file #{file_name} to #{dest_file}"
- File.copy(file_name, dest_file)
- end
-
- # Copy all files matching +wildcard+ into the directory +dest_dir+.
- def copy_files(wildcard, dest_dir)
- for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }
- end
-
- # Link +file_name+ to +dest_file+.
- def link(file_name, dest_file)
- log "Linking file #{file_name} to #{dest_file}"
- File.link(file_name, dest_file)
- end
-
- # Link all files matching +wildcard+ into the directory +dest_dir+.
- def link_files(wildcard, dest_dir)
- for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
- end
-
- # Symlink +file_name+ to +dest_file+.
- def symlink(file_name, dest_file)
- log "Symlinking file #{file_name} to #{dest_file}"
- File.symlink(file_name, dest_file)
- end
-
- # Symlink all files matching +wildcard+ into the directory +dest_dir+.
- def symlink_files(wildcard, dest_dir)
- for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
- end
-
- # Remove all files matching +wildcard+. If a matching file is a
- # directory, it must be empty to be removed. used +delete_all+ to
- # recursively delete directories.
- def delete(*wildcards)
- wildcards.each do |wildcard|
- Dir[wildcard].each do |fn|
- if File.directory?(fn)
- log "Deleting directory #{fn}"
- Dir.delete(fn)
- else
- log "Deleting file #{fn}"
- File.delete(fn)
- end
- end
- end
- end
-
- # Recursively delete all files and directories matching +wildcard+.
- def delete_all(*wildcards)
- wildcards.each do |wildcard|
- Dir[wildcard].each do |fn|
- next if ! File.exist?(fn)
- if File.directory?(fn)
- Dir["#{fn}/*"].each do |subfn|
- next if subfn=='.' || subfn=='..'
- delete_all(subfn)
- end
- log "Deleting directory #{fn}"
- Dir.delete(fn)
- else
- log "Deleting file #{fn}"
- File.delete(fn)
- end
- end
- end
- end
-
- # Make the directories given in +dirs+.
- def makedirs(*dirs)
- dirs.each do |fn|
- log "Making directory #{fn}"
- File.makedirs(fn)
- end
- end
-
- # Make +dir+ the current working directory for the duration of
- # executing the given block.
- def indir(dir)
- olddir = Dir.pwd
- Dir.chdir(dir)
- yield
- ensure
- Dir.chdir(olddir)
- end
-
- # Split a file path into individual directory names.
- #
- # For example:
- # split_all("a/b/c") => ['a', 'b', 'c']
- def split_all(path)
- head, tail = File.split(path)
- return [tail] if head == '.' || tail == '/'
- return [head, tail] if head == '/'
- return split_all(head) + [tail]
- end
-
- # Write a message to standard error if $verbose is enabled.
- def log(msg)
- print " " if $trace && $verbose
- $stderr.puts msg if $verbose
- end
-
- # Perform a block with $verbose disabled.
- def quiet(&block)
- with_verbose(false, &block)
- end
-
- # Perform a block with $verbose enabled.
- def verbose(&block)
- with_verbose(true, &block)
- end
-
- # Perform a block with each file matching a set of wildcards.
- def for_files(*wildcards)
- wildcards.each do |wildcard|
- Dir[wildcard].each do |fn|
- yield(fn)
- end
- end
- end
-
- extend(self)
-
- private # ----------------------------------------------------------
-
- def for_matching_files(wildcard, dest_dir)
- Dir[wildcard].each do |fn|
- dest_file = File.join(dest_dir, fn)
- parent = File.dirname(dest_file)
- makedirs(parent) if ! File.directory?(parent)
- yield(fn, dest_file)
- end
- end
-
- def with_verbose(v)
- oldverbose = $verbose
- $verbose = v
- yield
- ensure
- $verbose = oldverbose
- end
-
-end
+++ /dev/null
-module Rake
-
- # Default Rakefile loader used by +import+.
- class DefaultLoader
- def load(fn)
- Rake.load_rakefile(File.expand_path(fn))
- end
- end
-
-end
+++ /dev/null
-# Rake DSL functions.
-require 'rake/file_utils_ext'
-
-module Rake
-
- ##
- # DSL is a module that provides #task, #desc, #namespace, etc. Use this
- # when you'd like to use rake outside the top level scope.
-
- module DSL
-
- #--
- # Include the FileUtils file manipulation functions in the top
- # level module, but mark them private so that they don't
- # unintentionally define methods on other objects.
- #++
-
- include FileUtilsExt
- private(*FileUtils.instance_methods(false))
- private(*FileUtilsExt.instance_methods(false))
-
- private
-
- # Declare a basic task.
- #
- # Example:
- # task :clobber => [:clean] do
- # rm_rf "html"
- # end
- #
- def task(*args, &block)
- Rake::Task.define_task(*args, &block)
- end
-
-
- # Declare a file task.
- #
- # Example:
- # file "config.cfg" => ["config.template"] do
- # open("config.cfg", "w") do |outfile|
- # open("config.template") do |infile|
- # while line = infile.gets
- # outfile.puts line
- # end
- # end
- # end
- # end
- #
- def file(*args, &block)
- Rake::FileTask.define_task(*args, &block)
- end
-
- # Declare a file creation task.
- # (Mainly used for the directory command).
- def file_create(args, &block)
- Rake::FileCreationTask.define_task(args, &block)
- end
-
- # Declare a set of files tasks to create the given directories on
- # demand.
- #
- # Example:
- # directory "testdata/doc"
- #
- def directory(dir)
- Rake.each_dir_parent(dir) do |d|
- file_create d do |t|
- mkdir_p t.name if ! File.exist?(t.name)
- end
- end
- end
-
- # Declare a task that performs its prerequisites in
- # parallel. Multitasks does *not* guarantee that its prerequisites
- # will execute in any given order (which is obvious when you think
- # about it)
- #
- # Example:
- # multitask :deploy => [:deploy_gem, :deploy_rdoc]
- #
- def multitask(args, &block)
- Rake::MultiTask.define_task(args, &block)
- end
-
- # Create a new rake namespace and use it for evaluating the given
- # block. Returns a NameSpace object that can be used to lookup
- # tasks defined in the namespace.
- #
- # E.g.
- #
- # ns = namespace "nested" do
- # task :run
- # end
- # task_run = ns[:run] # find :run in the given namespace.
- #
- def namespace(name=nil, &block)
- name = name.to_s if name.kind_of?(Symbol)
- name = name.to_str if name.respond_to?(:to_str)
- unless name.kind_of?(String) || name.nil?
- raise ArgumentError, "Expected a String or Symbol for a namespace name"
- end
- Rake.application.in_namespace(name, &block)
- end
-
- # Declare a rule for auto-tasks.
- #
- # Example:
- # rule '.o' => '.c' do |t|
- # sh %{cc -o #{t.name} #{t.source}}
- # end
- #
- def rule(*args, &block)
- Rake::Task.create_rule(*args, &block)
- end
-
- # Describe the next rake task.
- #
- # Example:
- # desc "Run the Unit Tests"
- # task :test => [:build]
- # runtests
- # end
- #
- def desc(description)
- Rake.application.last_description = description
- end
-
- # Import the partial Rakefiles +fn+. Imported files are loaded
- # _after_ the current file is completely loaded. This allows the
- # import statement to appear anywhere in the importing file, and yet
- # allowing the imported files to depend on objects defined in the
- # importing file.
- #
- # A common use of the import statement is to include files
- # containing dependency declarations.
- #
- # See also the --rakelibdir command line option.
- #
- # Example:
- # import ".depend", "my_rules"
- #
- def import(*fns)
- fns.each do |fn|
- Rake.application.add_import(fn)
- end
- end
-
- end
-
- DeprecatedCommands = Object.new.extend(DSL)
-
- module DeprecatedObjectDSL # :nodoc:
- DSL.private_instance_methods(false).each do |name|
- line = __LINE__+1
- class_eval %{
- def #{name}(*args, &block)
- unless Rake.application.options.ignore_deprecate
- unless @rake_dsl_warning
- $stderr.puts "WARNING: Global access to Rake DSL methods is deprecated. Please include"
- $stderr.puts " ... Rake::DSL into classes and modules which use the Rake DSL methods."
- @rake_dsl_warning = true
- end
- $stderr.puts "WARNING: DSL method \#{self.class}##{name} called at \#{caller.first}"
- end
- Rake::DeprecatedCommands.send(:#{name}, *args, &block)
- end
- private :#{name}
- }, __FILE__, line
- end
- end
-
- extend FileUtilsExt
-end
-
-self.extend Rake::DSL
-include Rake::DeprecatedObjectDSL
+++ /dev/null
-module Rake
-
- # EarlyTime is a fake timestamp that occurs _before_ any other time value.
- class EarlyTime
- include Comparable
- include Singleton
-
- def <=>(other)
- -1
- end
-
- def to_s
- "<EARLY TIME>"
- end
- end
-
- EARLY = EarlyTime.instance
-end
+++ /dev/null
-######################################################################
-# Core extension library
-#
-class Module
- # Check for an existing method in the current class before extending. IF
- # the method already exists, then a warning is printed and the extension is
- # not added. Otherwise the block is yielded and any definitions in the
- # block will take effect.
- #
- # Usage:
- #
- # class String
- # rake_extension("xyz") do
- # def xyz
- # ...
- # end
- # end
- # end
- #
- def rake_extension(method)
- if method_defined?(method)
- $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
- else
- yield
- end
- end
-end
+++ /dev/null
-require 'rake/ext/core'
-require 'rake/task'
-require 'rake/file_task'
-require 'rake/file_creation_task'
-require 'rake/application'
-require 'rake/task_manager'
-
-######################################################################
-# Rake extensions to Module.
-#
-class Module
-
- # Rename the original handler to make it available.
- alias :rake_original_const_missing :const_missing
-
- # Check for deprecated uses of top level (i.e. in Object) uses of
- # Rake class names. If someone tries to reference the constant
- # name, display a warning and return the proper object. Using the
- # --classic-namespace command line option will define these
- # constants in Object and avoid this handler.
- def const_missing(const_name)
- case const_name
- when :Task
- Rake.application.const_warning(const_name)
- Rake::Task
- when :FileTask
- Rake.application.const_warning(const_name)
- Rake::FileTask
- when :FileCreationTask
- Rake.application.const_warning(const_name)
- Rake::FileCreationTask
- when :RakeApp
- Rake.application.const_warning(const_name)
- Rake::Application
- else
- rake_original_const_missing(const_name)
- end
- end
-end
+++ /dev/null
-require 'rake/ext/core'
-
-######################################################################
-# Rake extension methods for String.
-#
-class String
- rake_extension("ext") do
- # Replace the file extension with +newext+. If there is no extension on
- # the string, append the new extension to the end. If the new extension
- # is not given, or is the empty string, remove any existing extension.
- #
- # +ext+ is a user added method for the String class.
- def ext(newext='')
- return self.dup if ['.', '..'].include? self
- if newext != ''
- newext = (newext =~ /^\./) ? newext : ("." + newext)
- end
- self.chomp(File.extname(self)) << newext
- end
- end
-
- rake_extension("pathmap") do
- # Explode a path into individual components. Used by +pathmap+.
- def pathmap_explode
- head, tail = File.split(self)
- return [self] if head == self
- return [tail] if head == '.' || tail == '/'
- return [head, tail] if head == '/'
- return head.pathmap_explode + [tail]
- end
- protected :pathmap_explode
-
- # Extract a partial path from the path. Include +n+ directories from the
- # front end (left hand side) if +n+ is positive. Include |+n+|
- # directories from the back end (right hand side) if +n+ is negative.
- def pathmap_partial(n)
- dirs = File.dirname(self).pathmap_explode
- partial_dirs =
- if n > 0
- dirs[0...n]
- elsif n < 0
- dirs.reverse[0...-n].reverse
- else
- "."
- end
- File.join(partial_dirs)
- end
- protected :pathmap_partial
-
- # Preform the pathmap replacement operations on the given path. The
- # patterns take the form 'pat1,rep1;pat2,rep2...'.
- def pathmap_replace(patterns, &block)
- result = self
- patterns.split(';').each do |pair|
- pattern, replacement = pair.split(',')
- pattern = Regexp.new(pattern)
- if replacement == '*' && block_given?
- result = result.sub(pattern, &block)
- elsif replacement
- result = result.sub(pattern, replacement)
- else
- result = result.sub(pattern, '')
- end
- end
- result
- end
- protected :pathmap_replace
-
- # Map the path according to the given specification. The specification
- # controls the details of the mapping. The following special patterns are
- # recognized:
- #
- # * <b>%p</b> -- The complete path.
- # * <b>%f</b> -- The base file name of the path, with its file extension,
- # but without any directories.
- # * <b>%n</b> -- The file name of the path without its file extension.
- # * <b>%d</b> -- The directory list of the path.
- # * <b>%x</b> -- The file extension of the path. An empty string if there
- # is no extension.
- # * <b>%X</b> -- Everything *but* the file extension.
- # * <b>%s</b> -- The alternate file separator if defined, otherwise use
- # the standard file separator.
- # * <b>%%</b> -- A percent sign.
- #
- # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
- # number is positive, only return (up to) +n+ directories in the path,
- # starting from the left hand side. If +n+ is negative, return (up to)
- # |+n+| directories from the right hand side of the path.
- #
- # Examples:
- #
- # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
- # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
- #
- # Also the %d, %p, %f, %n, %x, and %X operators can take a
- # pattern/replacement argument to perform simple string substitutions on a
- # particular part of the path. The pattern and replacement are separated
- # by a comma and are enclosed by curly braces. The replacement spec comes
- # after the % character but before the operator letter. (e.g.
- # "%{old,new}d"). Multiple replacement specs should be separated by
- # semi-colons (e.g. "%{old,new;src,bin}d").
- #
- # Regular expressions may be used for the pattern, and back refs may be
- # used in the replacement text. Curly braces, commas and semi-colons are
- # excluded from both the pattern and replacement text (let's keep parsing
- # reasonable).
- #
- # For example:
- #
- # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
- #
- # returns:
- #
- # "bin/org/onestepback/proj/A.class"
- #
- # If the replacement text is '*', then a block may be provided to perform
- # some arbitrary calculation for the replacement.
- #
- # For example:
- #
- # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
- # ext.downcase
- # }
- #
- # Returns:
- #
- # "/path/to/file.txt"
- #
- def pathmap(spec=nil, &block)
- return self if spec.nil?
- result = ''
- spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
- case frag
- when '%f'
- result << File.basename(self)
- when '%n'
- result << File.basename(self).ext
- when '%d'
- result << File.dirname(self)
- when '%x'
- result << File.extname(self)
- when '%X'
- result << self.ext
- when '%p'
- result << self
- when '%s'
- result << (File::ALT_SEPARATOR || File::SEPARATOR)
- when '%-'
- # do nothing
- when '%%'
- result << "%"
- when /%(-?\d+)d/
- result << pathmap_partial($1.to_i)
- when /^%\{([^}]*)\}(\d*[dpfnxX])/
- patterns, operator = $1, $2
- result << pathmap('%' + operator).pathmap_replace(patterns, &block)
- when /^%/
- fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
- else
- result << frag
- end
- end
- result
- end
- end
-end # class String
-
+++ /dev/null
-#--
-# Extensions to time to allow comparisons with an early time class.
-
-class Time
- alias rake_original_time_compare :<=>
- def <=>(other)
- if Rake::EarlyTime === other
- - other.<=>(self)
- else
- rake_original_time_compare(other)
- end
- end
-end
-
+++ /dev/null
-require 'rake/file_task'
-require 'rake/early_time'
-
-module Rake
-
- # A FileCreationTask is a file task that when used as a dependency will be
- # needed if and only if the file has not been created. Once created, it is
- # not re-triggered if any of its dependencies are newer, nor does trigger
- # any rebuilds of tasks that depend on it whenever it is updated.
- #
- class FileCreationTask < FileTask
- # Is this file task needed? Yes if it doesn't exist.
- def needed?
- ! File.exist?(name)
- end
-
- # Time stamp for file creation task. This time stamp is earlier
- # than any other time stamp.
- def timestamp
- Rake::EARLY
- end
- end
-
-end
+++ /dev/null
-require 'rake/cloneable'
-require 'rake/file_utils_ext'
-require 'rake/pathmap'
-
-######################################################################
-module Rake
-
- # #########################################################################
- # A FileList is essentially an array with a few helper methods defined to
- # make file manipulation a bit easier.
- #
- # FileLists are lazy. When given a list of glob patterns for possible files
- # to be included in the file list, instead of searching the file structures
- # to find the files, a FileList holds the pattern for latter use.
- #
- # This allows us to define a number of FileList to match any number of
- # files, but only search out the actual files when then FileList itself is
- # actually used. The key is that the first time an element of the
- # FileList/Array is requested, the pending patterns are resolved into a real
- # list of file names.
- #
- class FileList
-
- include Cloneable
-
- # == Method Delegation
- #
- # The lazy evaluation magic of FileLists happens by implementing all the
- # array specific methods to call +resolve+ before delegating the heavy
- # lifting to an embedded array object (@items).
- #
- # In addition, there are two kinds of delegation calls. The regular kind
- # delegates to the @items array and returns the result directly. Well,
- # almost directly. It checks if the returned value is the @items object
- # itself, and if so will return the FileList object instead.
- #
- # The second kind of delegation call is used in methods that normally
- # return a new Array object. We want to capture the return value of these
- # methods and wrap them in a new FileList object. We enumerate these
- # methods in the +SPECIAL_RETURN+ list below.
-
- # List of array methods (that are not in +Object+) that need to be
- # delegated.
- ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map { |n| n.to_s }
-
- # List of additional methods that must be delegated.
- MUST_DEFINE = %w[to_a inspect <=>]
-
- # List of methods that should not be delegated here (we define special
- # versions of them explicitly below).
- MUST_NOT_DEFINE = %w[to_a to_ary partition *]
-
- # List of delegated methods that return new array values which need
- # wrapping.
- SPECIAL_RETURN = %w[
- map collect sort sort_by select find_all reject grep
- compact flatten uniq values_at
- + - & |
- ]
-
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
-
- # Now do the delegation.
- DELEGATING_METHODS.each_with_index do |sym, i|
- if SPECIAL_RETURN.include?(sym)
- ln = __LINE__+1
- class_eval %{
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- FileList.new.import(result)
- end
- }, __FILE__, ln
- else
- ln = __LINE__+1
- class_eval %{
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- result.object_id == @items.object_id ? self : result
- end
- }, __FILE__, ln
- end
- end
-
- # Create a file list from the globbable patterns given. If you wish to
- # perform multiple includes or excludes at object build time, use the
- # "yield self" pattern.
- #
- # Example:
- # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb')
- #
- # pkg_files = FileList.new('lib/**/*') do |fl|
- # fl.exclude(/\bCVS\b/)
- # end
- #
- def initialize(*patterns)
- @pending_add = []
- @pending = false
- @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
- @exclude_procs = DEFAULT_IGNORE_PROCS.dup
- @items = []
- patterns.each { |pattern| include(pattern) }
- yield self if block_given?
- end
-
- # Add file names defined by glob patterns to the file list. If an array
- # is given, add each element of the array.
- #
- # Example:
- # file_list.include("*.java", "*.cfg")
- # file_list.include %w( math.c lib.h *.o )
- #
- def include(*filenames)
- # TODO: check for pending
- filenames.each do |fn|
- if fn.respond_to? :to_ary
- include(*fn.to_ary)
- else
- @pending_add << fn
- end
- end
- @pending = true
- self
- end
- alias :add :include
-
- # Register a list of file name patterns that should be excluded from the
- # list. Patterns may be regular expressions, glob patterns or regular
- # strings. In addition, a block given to exclude will remove entries that
- # return true when given to the block.
- #
- # Note that glob patterns are expanded against the file system. If a file
- # is explicitly added to a file list, but does not exist in the file
- # system, then an glob pattern in the exclude list will not exclude the
- # file.
- #
- # Examples:
- # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
- # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c']
- #
- # If "a.c" is a file, then ...
- # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c']
- #
- # If "a.c" is not a file, then ...
- # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
- #
- def exclude(*patterns, &block)
- patterns.each do |pat|
- @exclude_patterns << pat
- end
- if block_given?
- @exclude_procs << block
- end
- resolve_exclude if ! @pending
- self
- end
-
-
- # Clear all the exclude patterns so that we exclude nothing.
- def clear_exclude
- @exclude_patterns = []
- @exclude_procs = []
- self
- end
-
- # Define equality.
- def ==(array)
- to_ary == array
- end
-
- # Return the internal array object.
- def to_a
- resolve
- @items
- end
-
- # Return the internal array object.
- def to_ary
- to_a
- end
-
- # Lie about our class.
- def is_a?(klass)
- klass == Array || super(klass)
- end
- alias kind_of? is_a?
-
- # Redefine * to return either a string or a new file list.
- def *(other)
- result = @items * other
- case result
- when Array
- FileList.new.import(result)
- else
- result
- end
- end
-
- # Resolve all the pending adds now.
- def resolve
- if @pending
- @pending = false
- @pending_add.each do |fn| resolve_add(fn) end
- @pending_add = []
- resolve_exclude
- end
- self
- end
-
- def resolve_add(fn)
- case fn
- when %r{[*?\[\{]}
- add_matching(fn)
- else
- self << fn
- end
- end
- private :resolve_add
-
- def resolve_exclude
- reject! { |fn| exclude?(fn) }
- self
- end
- private :resolve_exclude
-
- # Return a new FileList with the results of running +sub+ against each
- # element of the original list.
- #
- # Example:
- # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
- #
- def sub(pat, rep)
- inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
- end
-
- # Return a new FileList with the results of running +gsub+ against each
- # element of the original list.
- #
- # Example:
- # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
- # => ['lib\\test\\file', 'x\\y']
- #
- def gsub(pat, rep)
- inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
- end
-
- # Same as +sub+ except that the original file list is modified.
- def sub!(pat, rep)
- each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
- self
- end
-
- # Same as +gsub+ except that the original file list is modified.
- def gsub!(pat, rep)
- each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
- self
- end
-
- # Apply the pathmap spec to each of the included file names, returning a
- # new file list with the modified paths. (See String#pathmap for
- # details.)
- def pathmap(spec=nil)
- collect { |fn| fn.pathmap(spec) }
- end
-
- # Return a new FileList with <tt>String#ext</tt> method applied to
- # each member of the array.
- #
- # This method is a shortcut for:
- #
- # array.collect { |item| item.ext(newext) }
- #
- # +ext+ is a user added method for the Array class.
- def ext(newext='')
- collect { |fn| fn.ext(newext) }
- end
-
-
- # Grep each of the files in the filelist using the given pattern. If a
- # block is given, call the block on each matching line, passing the file
- # name, line number, and the matching line of text. If no block is given,
- # a standard emacs style file:linenumber:line message will be printed to
- # standard out. Returns the number of matched items.
- def egrep(pattern, *options)
- matched = 0
- each do |fn|
- begin
- open(fn, "rb", *options) do |inf|
- count = 0
- inf.each do |line|
- count += 1
- if pattern.match(line)
- matched += 1
- if block_given?
- yield fn, count, line
- else
- puts "#{fn}:#{count}:#{line}"
- end
- end
- end
- end
- rescue StandardError => ex
- $stderr.puts "Error while processing '#{fn}': #{ex}"
- end
- end
- matched
- end
-
- # Return a new file list that only contains file names from the current
- # file list that exist on the file system.
- def existing
- select { |fn| File.exist?(fn) }
- end
-
- # Modify the current file list so that it contains only file name that
- # exist on the file system.
- def existing!
- resolve
- @items = @items.select { |fn| File.exist?(fn) }
- self
- end
-
- # FileList version of partition. Needed because the nested arrays should
- # be FileLists in this version.
- def partition(&block) # :nodoc:
- resolve
- result = @items.partition(&block)
- [
- FileList.new.import(result[0]),
- FileList.new.import(result[1]),
- ]
- end
-
- # Convert a FileList to a string by joining all elements with a space.
- def to_s
- resolve
- self.join(' ')
- end
-
- # Add matching glob patterns.
- def add_matching(pattern)
- Dir[pattern].each do |fn|
- self << fn unless exclude?(fn)
- end
- end
- private :add_matching
-
- # Should the given file name be excluded?
- def exclude?(fn)
- return true if @exclude_patterns.any? do |pat|
- case pat
- when Regexp
- fn =~ pat
- when /[*?]/
- File.fnmatch?(pat, fn, File::FNM_PATHNAME)
- else
- fn == pat
- end
- end
- @exclude_procs.any? { |p| p.call(fn) }
- end
-
- DEFAULT_IGNORE_PATTERNS = [
- /(^|[\/\\])CVS([\/\\]|$)/,
- /(^|[\/\\])\.svn([\/\\]|$)/,
- /\.bak$/,
- /~$/
- ]
- DEFAULT_IGNORE_PROCS = [
- proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
- ]
-
- def import(array)
- @items = array
- self
- end
-
- class << self
- # Create a new file list including the files listed. Similar to:
- #
- # FileList.new(*args)
- def [](*args)
- new(*args)
- end
- end
- end
-end
-
-module Rake
- class << self
-
- # Yield each file or directory component.
- def each_dir_parent(dir) # :nodoc:
- old_length = nil
- while dir != '.' && dir.length != old_length
- yield(dir)
- old_length = dir.length
- dir = File.dirname(dir)
- end
- end
- end
-end # module Rake
+++ /dev/null
-require 'rake/task.rb'
-require 'rake/early_time'
-
-module Rake
- # #########################################################################
- # A FileTask is a task that includes time based dependencies. If any of a
- # FileTask's prerequisites have a timestamp that is later than the file
- # represented by this task, then the file must be rebuilt (using the
- # supplied actions).
- #
- class FileTask < Task
-
- # Is this file task needed? Yes if it doesn't exist, or if its time stamp
- # is out of date.
- def needed?
- ! File.exist?(name) || out_of_date?(timestamp)
- end
-
- # Time stamp for file task.
- def timestamp
- if File.exist?(name)
- File.mtime(name.to_s)
- else
- Rake::EARLY
- end
- end
-
- private
-
- # Are there any prerequisites with a later time than the given time stamp?
- def out_of_date?(stamp)
- @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
- end
-
- # ----------------------------------------------------------------
- # Task class methods.
- #
- class << self
- # Apply the scope to the task name according to the rules for this kind
- # of task. File based tasks ignore the scope when creating the name.
- def scope_name(scope, task_name)
- task_name
- end
- end
- end
-end
-
+++ /dev/null
-require 'rbconfig'
-require 'fileutils'
-
-#--
-# This a FileUtils extension that defines several additional commands to be
-# added to the FileUtils utility functions.
-module FileUtils
- # Path to the currently running Ruby program
- RUBY = File.join(
- RbConfig::CONFIG['bindir'],
- RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
- sub(/.*\s.*/m, '"\&"')
-
- OPT_TABLE['sh'] = %w(noop verbose)
- OPT_TABLE['ruby'] = %w(noop verbose)
-
- # Run the system command +cmd+. If multiple arguments are given the command
- # is not run with the shell (same semantics as Kernel::exec and
- # Kernel::system).
- #
- # Example:
- # sh %{ls -ltr}
- #
- # sh 'ls', 'file with spaces'
- #
- # # check exit status after command runs
- # sh %{grep pattern file} do |ok, res|
- # if ! ok
- # puts "pattern not found (status = #{res.exitstatus})"
- # end
- # end
- #
- def sh(*cmd, &block)
- options = (Hash === cmd.last) ? cmd.pop : {}
- shell_runner = block_given? ? block : create_shell_runner(cmd)
- set_verbose_option(options)
- options[:noop] ||= Rake::FileUtilsExt.nowrite_flag
- Rake.rake_check_options options, :noop, :verbose
- Rake.rake_output_message cmd.join(" ") if options[:verbose]
-
- unless options[:noop]
- res = rake_system(*cmd)
- status = $?
- status = PseudoStatus.new(1) if !res && status.nil?
- shell_runner.call(res, status)
- end
- end
-
- def create_shell_runner(cmd) # :nodoc:
- show_command = cmd.join(" ")
- show_command = show_command[0,42] + "..." unless $trace
- lambda { |ok, status|
- ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
- }
- end
- private :create_shell_runner
-
- def set_verbose_option(options) # :nodoc:
- unless options.key? :verbose
- options[:verbose] =
- Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT ||
- Rake::FileUtilsExt.verbose_flag
- end
- end
- private :set_verbose_option
-
- def rake_system(*cmd) # :nodoc:
- Rake::AltSystem.system(*cmd)
- end
- private :rake_system
-
- # Run a Ruby interpreter with the given arguments.
- #
- # Example:
- # ruby %{-pe '$_.upcase!' <README}
- #
- def ruby(*args,&block)
- options = (Hash === args.last) ? args.pop : {}
- if args.length > 1 then
- sh(*([RUBY] + args + [options]), &block)
- else
- sh("#{RUBY} #{args.first}", options, &block)
- end
- end
-
- LN_SUPPORTED = [true]
-
- # Attempt to do a normal file link, but fall back to a copy if the link
- # fails.
- def safe_ln(*args)
- unless LN_SUPPORTED[0]
- cp(*args)
- else
- begin
- ln(*args)
- rescue StandardError, NotImplementedError
- LN_SUPPORTED[0] = false
- cp(*args)
- end
- end
- end
-
- # Split a file path into individual directory names.
- #
- # Example:
- # split_all("a/b/c") => ['a', 'b', 'c']
- #
- def split_all(path)
- head, tail = File.split(path)
- return [tail] if head == '.' || tail == '/'
- return [head, tail] if head == '/'
- return split_all(head) + [tail]
- end
-end
+++ /dev/null
-require 'rake/file_utils'
-
-module Rake
- #
- # FileUtilsExt provides a custom version of the FileUtils methods
- # that respond to the <tt>verbose</tt> and <tt>nowrite</tt>
- # commands.
- #
- module FileUtilsExt
- include FileUtils
-
- class << self
- attr_accessor :verbose_flag, :nowrite_flag
- end
-
- DEFAULT = Object.new
-
- FileUtilsExt.verbose_flag = DEFAULT
- FileUtilsExt.nowrite_flag = false
-
- $fileutils_verbose = true
- $fileutils_nowrite = false
-
- FileUtils::OPT_TABLE.each do |name, opts|
- default_options = []
- if opts.include?(:verbose) || opts.include?("verbose")
- default_options << ':verbose => FileUtilsExt.verbose_flag'
- end
- if opts.include?(:noop) || opts.include?("noop")
- default_options << ':noop => FileUtilsExt.nowrite_flag'
- end
-
- next if default_options.empty?
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}( *args, &block )
- super(
- *rake_merge_option(args,
- #{default_options.join(', ')}
- ), &block)
- end
- EOS
- end
-
- # Get/set the verbose flag controlling output from the FileUtils
- # utilities. If verbose is true, then the utility method is
- # echoed to standard output.
- #
- # Examples:
- # verbose # return the current value of the
- # # verbose flag
- # verbose(v) # set the verbose flag to _v_.
- # verbose(v) { code } # Execute code with the verbose flag set
- # # temporarily to _v_. Return to the
- # # original value when code is done.
- def verbose(value=nil)
- oldvalue = FileUtilsExt.verbose_flag
- FileUtilsExt.verbose_flag = value unless value.nil?
- if block_given?
- begin
- yield
- ensure
- FileUtilsExt.verbose_flag = oldvalue
- end
- end
- FileUtilsExt.verbose_flag
- end
-
- # Get/set the nowrite flag controlling output from the FileUtils
- # utilities. If verbose is true, then the utility method is
- # echoed to standard output.
- #
- # Examples:
- # nowrite # return the current value of the
- # # nowrite flag
- # nowrite(v) # set the nowrite flag to _v_.
- # nowrite(v) { code } # Execute code with the nowrite flag set
- # # temporarily to _v_. Return to the
- # # original value when code is done.
- def nowrite(value=nil)
- oldvalue = FileUtilsExt.nowrite_flag
- FileUtilsExt.nowrite_flag = value unless value.nil?
- if block_given?
- begin
- yield
- ensure
- FileUtilsExt.nowrite_flag = oldvalue
- end
- end
- oldvalue
- end
-
- # Use this function to prevent potentially destructive ruby code
- # from running when the :nowrite flag is set.
- #
- # Example:
- #
- # when_writing("Building Project") do
- # project.build
- # end
- #
- # The following code will build the project under normal
- # conditions. If the nowrite(true) flag is set, then the example
- # will print:
- #
- # DRYRUN: Building Project
- #
- # instead of actually building the project.
- #
- def when_writing(msg=nil)
- if FileUtilsExt.nowrite_flag
- $stderr.puts "DRYRUN: #{msg}" if msg
- else
- yield
- end
- end
-
- # Merge the given options with the default values.
- def rake_merge_option(args, defaults)
- if Hash === args.last
- defaults.update(args.last)
- args.pop
- end
- args.push defaults
- args
- end
-
- # Send the message to the default rake output (which is $stderr).
- def rake_output_message(message)
- $stderr.puts(message)
- end
-
- # Check that the options do not contain options not listed in
- # +optdecl+. An ArgumentError exception is thrown if non-declared
- # options are found.
- def rake_check_options(options, *optdecl)
- h = options.dup
- optdecl.each do |name|
- h.delete name
- end
- raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
- end
-
- extend self
- end
-end
+++ /dev/null
-# rake/gempackagetask is deprecated in favor of rubygems/package_task
-
-warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead'
-
-require 'rubygems'
-require 'rubygems/package_task'
-
-require 'rake'
-
-# :stopdoc:
-
-module Rake
- GemPackageTask = Gem::PackageTask
-end
-
+++ /dev/null
-module Rake
-
- ####################################################################
- # InvocationChain tracks the chain of task invocations to detect
- # circular dependencies.
- class InvocationChain
- def initialize(value, tail)
- @value = value
- @tail = tail
- end
-
- def member?(obj)
- @value == obj || @tail.member?(obj)
- end
-
- def append(value)
- if member?(value)
- fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
- end
- self.class.new(value, self)
- end
-
- def to_s
- "#{prefix}#{@value}"
- end
-
- def self.append(value, chain)
- chain.append(value)
- end
-
- private
-
- def prefix
- "#{@tail.to_s} => "
- end
-
- class EmptyInvocationChain
- def member?(obj)
- false
- end
- def append(value)
- InvocationChain.new(value, self)
- end
- def to_s
- "TOP"
- end
- end
-
- EMPTY = EmptyInvocationChain.new
- end
-end
+++ /dev/null
-module Rake
- module InvocationExceptionMixin
- # Return the invocation chain (list of Rake tasks) that were in
- # effect when this exception was detected by rake. May be null if
- # no tasks were active.
- def chain
- @rake_invocation_chain ||= nil
- end
-
- # Set the invocation chain in effect when this exception was
- # detected.
- def chain=(value)
- @rake_invocation_chain = value
- end
- end
-end
+++ /dev/null
-module Rake
-
- # Makefile loader to be used with the import file loader.
- class MakefileLoader
- include Rake::DSL
-
- SPACE_MARK = "\0"
-
- # Load the makefile dependencies in +fn+.
- def load(fn)
- lines = File.read fn
- lines.gsub!(/\\ /, SPACE_MARK)
- lines.gsub!(/#[^\n]*\n/m, "")
- lines.gsub!(/\\\n/, ' ')
- lines.each_line do |line|
- process_line(line)
- end
- end
-
- private
-
- # Process one logical line of makefile data.
- def process_line(line)
- file_tasks, args = line.split(':', 2)
- return if args.nil?
- dependents = args.split.map { |d| respace(d) }
- file_tasks.scan(/\S+/) do |file_task|
- file_task = respace(file_task)
- file file_task => dependents
- end
- end
-
- def respace(str)
- str.tr SPACE_MARK, ' '
- end
- end
-
- # Install the handler
- Rake.application.add_loader('mf', MakefileLoader.new)
-end
+++ /dev/null
-module Rake
-
- # Same as a regular task, but the immediate prerequisites are done in
- # parallel using Ruby threads.
- #
- class MultiTask < Task
- private
- def invoke_prerequisites(args, invocation_chain)
- threads = @prerequisites.collect { |p|
- Thread.new(p) { |r| application[r, @scope].invoke_with_call_chain(args, invocation_chain) }
- }
- threads.each { |t| t.join }
- end
- end
-
-end
+++ /dev/null
-module Rake
-
- # The NameSpace class will lookup task names in the the scope
- # defined by a +namespace+ command.
- #
- class NameSpace
-
- # Create a namespace lookup object using the given task manager
- # and the list of scopes.
- def initialize(task_manager, scope_list)
- @task_manager = task_manager
- @scope = scope_list.dup
- end
-
- # Lookup a task named +name+ in the namespace.
- def [](name)
- @task_manager.lookup(name, @scope)
- end
-
- # Return the list of tasks defined in this and nested namespaces.
- def tasks
- @task_manager.tasks_in_scope(@scope)
- end
- end
-end
+++ /dev/null
-# Define a package task library to aid in the definition of
-# redistributable package files.
-
-require 'rake'
-require 'rake/tasklib'
-
-module Rake
-
- # Create a packaging task that will package the project into
- # distributable files (e.g zip archive or tar files).
- #
- # The PackageTask will create the following targets:
- #
- # [<b>:package</b>]
- # Create all the requested package files.
- #
- # [<b>:clobber_package</b>]
- # Delete all the package files. This target is automatically
- # added to the main clobber target.
- #
- # [<b>:repackage</b>]
- # Rebuild the package files from scratch, even if they are not out
- # of date.
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
- # Create a gzipped tar package (if <em>need_tar</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</b>]
- # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</b>]
- # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
- # Create a zip package archive (if <em>need_zip</em> is true).
- #
- # Example:
- #
- # Rake::PackageTask.new("rake", "1.2.3") do |p|
- # p.need_tar = true
- # p.package_files.include("lib/**/*.rb")
- # end
- #
- class PackageTask < TaskLib
- # Name of the package (from the GEM Spec).
- attr_accessor :name
-
- # Version of the package (e.g. '1.3.2').
- attr_accessor :version
-
- # Directory used to store the package files (default is 'pkg').
- attr_accessor :package_dir
-
- # True if a gzipped tar file (tgz) should be produced (default is false).
- attr_accessor :need_tar
-
- # True if a gzipped tar file (tar.gz) should be produced (default is false).
- attr_accessor :need_tar_gz
-
- # True if a bzip2'd tar file (tar.bz2) should be produced (default is false).
- attr_accessor :need_tar_bz2
-
- # True if a zip file should be produced (default is false)
- attr_accessor :need_zip
-
- # List of files to be included in the package.
- attr_accessor :package_files
-
- # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
- attr_accessor :tar_command
-
- # Zip command for zipped archives. The default is 'zip'.
- attr_accessor :zip_command
-
- # Create a Package Task with the given name and version. Use +:noversion+
- # as the version to build a package without a version or to provide a
- # fully-versioned package name.
-
- def initialize(name=nil, version=nil)
- init(name, version)
- yield self if block_given?
- define unless name.nil?
- end
-
- # Initialization that bypasses the "yield self" and "define" step.
- def init(name, version)
- @name = name
- @version = version
- @package_files = Rake::FileList.new
- @package_dir = 'pkg'
- @need_tar = false
- @need_tar_gz = false
- @need_tar_bz2 = false
- @need_zip = false
- @tar_command = 'tar'
- @zip_command = 'zip'
- end
-
- # Create the tasks defined by this task library.
- def define
- fail "Version required (or :noversion)" if @version.nil?
- @version = nil if :noversion == @version
-
- desc "Build all the packages"
- task :package
-
- desc "Force a rebuild of the package files"
- task :repackage => [:clobber_package, :package]
-
- desc "Remove package products"
- task :clobber_package do
- rm_r package_dir rescue nil
- end
-
- task :clobber => [:clobber_package]
-
- [
- [need_tar, tgz_file, "z"],
- [need_tar_gz, tar_gz_file, "z"],
- [need_tar_bz2, tar_bz2_file, "j"]
- ].each do |(need, file, flag)|
- if need
- task :package => ["#{package_dir}/#{file}"]
- file "#{package_dir}/#{file}" => [package_dir_path] + package_files do
- chdir(package_dir) do
- sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
- end
- end
- end
- end
-
- if need_zip
- task :package => ["#{package_dir}/#{zip_file}"]
- file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
- chdir(package_dir) do
- sh %{#{@zip_command} -r #{zip_file} #{package_name}}
- end
- end
- end
-
- directory package_dir
-
- file package_dir_path => @package_files do
- mkdir_p package_dir rescue nil
- @package_files.each do |fn|
- f = File.join(package_dir_path, fn)
- fdir = File.dirname(f)
- mkdir_p(fdir) if !File.exist?(fdir)
- if File.directory?(fn)
- mkdir_p(f)
- else
- rm_f f
- safe_ln(fn, f)
- end
- end
- end
- self
- end
-
- def package_name
- @version ? "#{@name}-#{@version}" : @name
- end
-
- def package_dir_path
- "#{package_dir}/#{package_name}"
- end
-
- def tgz_file
- "#{package_name}.tgz"
- end
-
- def tar_gz_file
- "#{package_name}.tar.gz"
- end
-
- def tar_bz2_file
- "#{package_name}.tar.bz2"
- end
-
- def zip_file
- "#{package_name}.zip"
- end
- end
-
-end
+++ /dev/null
-require 'rake/ext/string'
+++ /dev/null
-module Rake
-
- ####################################################################
- # Exit status class for times the system just gives us a nil.
- class PseudoStatus
- attr_reader :exitstatus
- def initialize(code=0)
- @exitstatus = code
- end
- def to_i
- @exitstatus << 8
- end
- def >>(n)
- to_i >> n
- end
- def stopped?
- false
- end
- def exited?
- true
- end
- end
-
-end
+++ /dev/null
-require 'rake/application'
-
-module Rake
-
- # Rake module singleton methods.
- #
- class << self
- # Current Rake Application
- def application
- @application ||= Rake::Application.new
- end
-
- # Set the current Rake application object.
- def application=(app)
- @application = app
- end
-
- # Return the original directory where the Rake application was started.
- def original_dir
- application.original_dir
- end
-
- # Load a rakefile.
- def load_rakefile(path)
- load(path)
- end
- end
-
-end
+++ /dev/null
-require 'rake'
-
-# Load the test files from the command line.
-argv = ARGV.select do |argument|
- case argument
- when /^-/ then
- argument
- when /\*/ then
- FileList[argument].to_a.each do |file|
- require File.expand_path file
- end
-
- false
- else
- require File.expand_path argument
-
- false
- end
-end
-
-ARGV.replace argv
-
+++ /dev/null
-# rake/rdoctask is deprecated in favor of rdoc/task
-
-if Rake.application
- Rake.application.deprecate('require \'rake/rdoctask\'', 'require \'rdoc/task\' (in RDoc 2.4.2+)', __FILE__)
-end
-
-require 'rubygems'
-
-begin
- gem 'rdoc'
- require 'rdoc'
- require 'rdoc/task'
-rescue LoadError, Gem::LoadError
-end
-
-# :stopdoc:
-
-if defined?(RDoc::Task) then
- module Rake
- RDocTask = RDoc::Task unless const_defined? :RDocTask
- end
-else
- require 'rake'
- require 'rake/tasklib'
-
- module Rake
-
- # NOTE: Rake::RDocTask is deprecated in favor of RDoc:Task which is included
- # in RDoc 2.4.2+. Use require 'rdoc/task' to require it.
- #
- # Create a documentation task that will generate the RDoc files for
- # a project.
- #
- # The RDocTask will create the following targets:
- #
- # [<b><em>rdoc</em></b>]
- # Main task for this RDOC task.
- #
- # [<b>:clobber_<em>rdoc</em></b>]
- # Delete all the rdoc files. This target is automatically
- # added to the main clobber target.
- #
- # [<b>:re<em>rdoc</em></b>]
- # Rebuild the rdoc files from scratch, even if they are not out
- # of date.
- #
- # Simple Example:
- #
- # Rake::RDocTask.new do |rd|
- # rd.main = "README.rdoc"
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
- # end
- #
- # The +rd+ object passed to the block is an RDocTask object. See the
- # attributes list for the RDocTask class for available customization options.
- #
- # == Specifying different task names
- #
- # You may wish to give the task a different name, such as if you are
- # generating two sets of documentation. For instance, if you want to have a
- # development set of documentation including private methods:
- #
- # Rake::RDocTask.new(:rdoc_dev) do |rd|
- # rd.main = "README.doc"
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
- # rd.options << "--all"
- # end
- #
- # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
- # :re<em>rdoc_dev</em>.
- #
- # If you wish to have completely different task names, then pass a Hash as
- # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
- # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
- # For example:
- #
- # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
- #
- # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
- # <tt>:rdoc:force</tt>.
- #
- class RDocTask < TaskLib
- # Name of the main, top level task. (default is :rdoc)
- attr_accessor :name
-
- # Name of directory to receive the html output files. (default is "html")
- attr_accessor :rdoc_dir
-
- # Title of RDoc documentation. (defaults to rdoc's default)
- attr_accessor :title
-
- # Name of file to be used as the main, top level file of the
- # RDoc. (default is none)
- attr_accessor :main
-
- # Name of template to be used by rdoc. (defaults to rdoc's default)
- attr_accessor :template
-
- # List of files to be included in the rdoc generation. (default is [])
- attr_accessor :rdoc_files
-
- # Additional list of options to be passed rdoc. (default is [])
- attr_accessor :options
-
- # Whether to run the rdoc process as an external shell (default is false)
- attr_accessor :external
-
- attr_accessor :inline_source
-
- # Create an RDoc task with the given name. See the RDocTask class overview
- # for documentation.
- def initialize(name = :rdoc) # :yield: self
- if name.is_a?(Hash)
- invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
- if !invalid_options.empty?
- raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
- end
- end
-
- @name = name
- @rdoc_files = Rake::FileList.new
- @rdoc_dir = 'html'
- @main = nil
- @title = nil
- @template = nil
- @external = false
- @inline_source = true
- @options = []
- yield self if block_given?
- define
- end
-
- # Create the tasks defined by this task lib.
- def define
- if rdoc_task_name != "rdoc"
- desc "Build the RDOC HTML Files"
- else
- desc "Build the #{rdoc_task_name} HTML Files"
- end
- task rdoc_task_name
-
- desc "Force a rebuild of the RDOC files"
- task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
-
- desc "Remove rdoc products"
- task clobber_task_name do
- rm_r rdoc_dir rescue nil
- end
-
- task :clobber => [clobber_task_name]
-
- directory @rdoc_dir
- task rdoc_task_name => [rdoc_target]
- file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
- rm_r @rdoc_dir rescue nil
- @before_running_rdoc.call if @before_running_rdoc
- args = option_list + @rdoc_files
- if @external
- argstring = args.join(' ')
- sh %{ruby -Ivendor vendor/rd #{argstring}}
- else
- require 'rdoc/rdoc'
- RDoc::RDoc.new.document(args)
- end
- end
- self
- end
-
- def option_list
- result = @options.dup
- result << "-o" << @rdoc_dir
- result << "--main" << quote(main) if main
- result << "--title" << quote(title) if title
- result << "-T" << quote(template) if template
- result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
- result
- end
-
- def quote(str)
- if @external
- "'#{str}'"
- else
- str
- end
- end
-
- def option_string
- option_list.join(' ')
- end
-
- # The block passed to this method will be called just before running the
- # RDoc generator. It is allowed to modify RDocTask attributes inside the
- # block.
- def before_running_rdoc(&block)
- @before_running_rdoc = block
- end
-
- private
-
- def rdoc_target
- "#{rdoc_dir}/index.html"
- end
-
- def rdoc_task_name
- case name
- when Hash
- (name[:rdoc] || "rdoc").to_s
- else
- name.to_s
- end
- end
-
- def clobber_task_name
- case name
- when Hash
- (name[:clobber_rdoc] || "clobber_rdoc").to_s
- else
- "clobber_#{name}"
- end
- end
-
- def rerdoc_task_name
- case name
- when Hash
- (name[:rerdoc] || "rerdoc").to_s
- else
- "re#{name}"
- end
- end
-
- end
- end
-end
-
+++ /dev/null
-# Local Rake override to fix bug in Ruby 0.8.2
-module Test # :nodoc:
- # Local Rake override to fix bug in Ruby 0.8.2
- module Unit # :nodoc:
- # Local Rake override to fix bug in Ruby 0.8.2
- module Collector # :nodoc:
- # Local Rake override to fix bug in Ruby 0.8.2
- class Dir # :nodoc:
- undef collect_file
- def collect_file(name, suites, already_gathered) # :nodoc:
- dir = File.dirname(File.expand_path(name))
- $:.unshift(dir) unless $:.first == dir
- if(@req)
- @req.require(name)
- else
- require(name)
- end
- find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
- ensure
- $:.delete_at $:.rindex(dir)
- end
- end
- end
- end
-end
+++ /dev/null
-
-module Rake
-
- # Error indicating a recursion overflow error in task selection.
- class RuleRecursionOverflowError < StandardError
- def initialize(*args)
- super
- @targets = []
- end
-
- def add_target(target)
- @targets << target
- end
-
- def message
- super + ": [" + @targets.reverse.join(' => ') + "]"
- end
- end
-
-end
+++ /dev/null
-require 'test/unit'
-require 'test/unit/assertions'
-
-module Rake
- include Test::Unit::Assertions
-
- def run_tests(pattern='test/test*.rb', log_enabled=false)
- Dir["#{pattern}"].each { |fn|
- $stderr.puts fn if log_enabled
- begin
- require fn
- rescue Exception => ex
- $stderr.puts "Error in #{fn}: #{ex.message}"
- $stderr.puts ex.backtrace
- assert false
- end
- }
- end
-
- extend self
-end
+++ /dev/null
-require 'rake/invocation_exception_mixin'
-
-module Rake
-
- # #########################################################################
- # A Task is the basic unit of work in a Rakefile. Tasks have associated
- # actions (possibly more than one) and a list of prerequisites. When
- # invoked, a task will first ensure that all of its prerequisites have an
- # opportunity to run and then it will execute its own actions.
- #
- # Tasks are not usually created directly using the new method, but rather
- # use the +file+ and +task+ convenience methods.
- #
- class Task
- # List of prerequisites for a task.
- attr_reader :prerequisites
-
- # List of actions attached to a task.
- attr_reader :actions
-
- # Application owning this task.
- attr_accessor :application
-
- # Comment for this task. Restricted to a single line of no more than 50
- # characters.
- attr_reader :comment
-
- # Full text of the (possibly multi-line) comment.
- attr_reader :full_comment
-
- # Array of nested namespaces names used for task lookup by this task.
- attr_reader :scope
-
- # File/Line locations of each of the task definitions for this
- # task (only valid if the task was defined with the detect
- # location option set).
- attr_reader :locations
-
- # Return task name
- def to_s
- name
- end
-
- def inspect
- "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
- end
-
- # List of sources for task.
- attr_writer :sources
- def sources
- @sources ||= []
- end
-
- # List of prerequisite tasks
- def prerequisite_tasks
- prerequisites.collect { |pre| lookup_prerequisite(pre) }
- end
-
- def lookup_prerequisite(prerequisite_name)
- application[prerequisite_name, @scope]
- end
- private :lookup_prerequisite
-
- # First source from a rule (nil if no sources)
- def source
- @sources.first if defined?(@sources)
- end
-
- # Create a task named +task_name+ with no actions or prerequisites. Use
- # +enhance+ to add actions and prerequisites.
- def initialize(task_name, app)
- @name = task_name.to_s
- @prerequisites = []
- @actions = []
- @already_invoked = false
- @full_comment = nil
- @comment = nil
- @lock = Monitor.new
- @application = app
- @scope = app.current_scope
- @arg_names = nil
- @locations = []
- end
-
- # Enhance a task with prerequisites or actions. Returns self.
- def enhance(deps=nil, &block)
- @prerequisites |= deps if deps
- @actions << block if block_given?
- self
- end
-
- # Name of the task, including any namespace qualifiers.
- def name
- @name.to_s
- end
-
- # Name of task with argument list description.
- def name_with_args # :nodoc:
- if arg_description
- "#{name}#{arg_description}"
- else
- name
- end
- end
-
- # Argument description (nil if none).
- def arg_description # :nodoc:
- @arg_names ? "[#{(arg_names || []).join(',')}]" : nil
- end
-
- # Name of arguments for this task.
- def arg_names
- @arg_names || []
- end
-
- # Reenable the task, allowing its tasks to be executed if the task
- # is invoked again.
- def reenable
- @already_invoked = false
- end
-
- # Clear the existing prerequisites and actions of a rake task.
- def clear
- clear_prerequisites
- clear_actions
- self
- end
-
- # Clear the existing prerequisites of a rake task.
- def clear_prerequisites
- prerequisites.clear
- self
- end
-
- # Clear the existing actions on a rake task.
- def clear_actions
- actions.clear
- self
- end
-
- # Invoke the task if it is needed. Prerequisites are invoked first.
- def invoke(*args)
- task_args = TaskArguments.new(arg_names, args)
- invoke_with_call_chain(task_args, InvocationChain::EMPTY)
- end
-
- # Same as invoke, but explicitly pass a call chain to detect
- # circular dependencies.
- def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
- new_chain = InvocationChain.append(self, invocation_chain)
- @lock.synchronize do
- if application.options.trace
- $stderr.puts "** Invoke #{name} #{format_trace_flags}"
- end
- return if @already_invoked
- @already_invoked = true
- invoke_prerequisites(task_args, new_chain)
- execute(task_args) if needed?
- end
- rescue Exception => ex
- add_chain_to(ex, new_chain)
- raise ex
- end
- protected :invoke_with_call_chain
-
- def add_chain_to(exception, new_chain)
- exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain)
- exception.chain = new_chain if exception.chain.nil?
- end
- private :add_chain_to
-
- # Invoke all the prerequisites of a task.
- def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
- prerequisite_tasks.each { |prereq|
- prereq_args = task_args.new_scope(prereq.arg_names)
- prereq.invoke_with_call_chain(prereq_args, invocation_chain)
- }
- end
-
- # Format the trace flags for display.
- def format_trace_flags
- flags = []
- flags << "first_time" unless @already_invoked
- flags << "not_needed" unless needed?
- flags.empty? ? "" : "(" + flags.join(", ") + ")"
- end
- private :format_trace_flags
-
- # Execute the actions associated with this task.
- def execute(args=nil)
- args ||= EMPTY_TASK_ARGS
- if application.options.dryrun
- $stderr.puts "** Execute (dry run) #{name}"
- return
- end
- if application.options.trace
- $stderr.puts "** Execute #{name}"
- end
- application.enhance_with_matching_rule(name) if @actions.empty?
- @actions.each do |act|
- case act.arity
- when 1
- act.call(self)
- else
- act.call(self, args)
- end
- end
- end
-
- # Is this task needed?
- def needed?
- true
- end
-
- # Timestamp for this task. Basic tasks return the current time for their
- # time stamp. Other tasks can be more sophisticated.
- def timestamp
- prerequisite_tasks.collect { |pre| pre.timestamp }.max || Time.now
- end
-
- # Add a description to the task. The description can consist of an option
- # argument list (enclosed brackets) and an optional comment.
- def add_description(description)
- return if ! description
- comment = description.strip
- add_comment(comment) if comment && ! comment.empty?
- end
-
- # Writing to the comment attribute is the same as adding a description.
- def comment=(description)
- add_description(description)
- end
-
- # Add a comment to the task. If a comment already exists, separate
- # the new comment with " / ".
- def add_comment(comment)
- if @full_comment
- @full_comment << " / "
- else
- @full_comment = ''
- end
- @full_comment << comment
- if @full_comment =~ /\A([^.]+?\.)( |$)/
- @comment = $1
- else
- @comment = @full_comment
- end
- end
- private :add_comment
-
- # Set the names of the arguments for this task. +args+ should be
- # an array of symbols, one for each argument name.
- def set_arg_names(args)
- @arg_names = args.map { |a| a.to_sym }
- end
-
- # Return a string describing the internal state of a task. Useful for
- # debugging.
- def investigation
- result = "------------------------------\n"
- result << "Investigating #{name}\n"
- result << "class: #{self.class}\n"
- result << "task needed: #{needed?}\n"
- result << "timestamp: #{timestamp}\n"
- result << "pre-requisites: \n"
- prereqs = prerequisite_tasks
- prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
- prereqs.each do |p|
- result << "--#{p.name} (#{p.timestamp})\n"
- end
- latest_prereq = prerequisite_tasks.collect { |pre| pre.timestamp }.max
- result << "latest-prerequisite time: #{latest_prereq}\n"
- result << "................................\n\n"
- return result
- end
-
- # ----------------------------------------------------------------
- # Rake Module Methods
- #
- class << self
-
- # Clear the task list. This cause rake to immediately forget all the
- # tasks that have been assigned. (Normally used in the unit tests.)
- def clear
- Rake.application.clear
- end
-
- # List of all defined tasks.
- def tasks
- Rake.application.tasks
- end
-
- # Return a task with the given name. If the task is not currently
- # known, try to synthesize one from the defined rules. If no rules are
- # found, but an existing file matches the task name, assume it is a file
- # task with no dependencies or actions.
- def [](task_name)
- Rake.application[task_name]
- end
-
- # TRUE if the task name is already defined.
- def task_defined?(task_name)
- Rake.application.lookup(task_name) != nil
- end
-
- # Define a task given +args+ and an option block. If a rule with the
- # given name already exists, the prerequisites and actions are added to
- # the existing task. Returns the defined task.
- def define_task(*args, &block)
- Rake.application.define_task(self, *args, &block)
- end
-
- # Define a rule for synthesizing tasks.
- def create_rule(*args, &block)
- Rake.application.create_rule(*args, &block)
- end
-
- # Apply the scope to the task name according to the rules for
- # this kind of task. Generic tasks will accept the scope as
- # part of the name.
- def scope_name(scope, task_name)
- (scope + [task_name]).join(':')
- end
-
- end # class << Rake::Task
- end # class Rake::Task
-end
+++ /dev/null
-module Rake
-
- # Error indicating an ill-formed task declaration.
- class TaskArgumentError < ArgumentError
- end
-
-end
+++ /dev/null
-module Rake
-
- ####################################################################
- # TaskArguments manage the arguments passed to a task.
- #
- class TaskArguments
- include Enumerable
-
- attr_reader :names
-
- # Create a TaskArgument object with a list of named arguments
- # (given by :names) and a set of associated values (given by
- # :values). :parent is the parent argument object.
- def initialize(names, values, parent=nil)
- @names = names
- @parent = parent
- @hash = {}
- names.each_with_index { |name, i|
- @hash[name.to_sym] = values[i] unless values[i].nil?
- }
- end
-
- # Create a new argument scope using the prerequisite argument
- # names.
- def new_scope(names)
- values = names.collect { |n| self[n] }
- self.class.new(names, values, self)
- end
-
- # Find an argument value by name or index.
- def [](index)
- lookup(index.to_sym)
- end
-
- # Specify a hash of default values for task arguments. Use the
- # defaults only if there is no specific value for the given
- # argument.
- def with_defaults(defaults)
- @hash = defaults.merge(@hash)
- end
-
- def each(&block)
- @hash.each(&block)
- end
-
- def values_at(*keys)
- keys.map { |k| lookup(k) }
- end
-
- def method_missing(sym, *args, &block)
- lookup(sym.to_sym)
- end
-
- def to_hash
- @hash
- end
-
- def to_s
- @hash.inspect
- end
-
- def inspect
- to_s
- end
-
- protected
-
- def lookup(name)
- if @hash.has_key?(name)
- @hash[name]
- elsif @parent
- @parent.lookup(name)
- end
- end
- end
-
- EMPTY_TASK_ARGS = TaskArguments.new([], [])
-end
+++ /dev/null
-module Rake
-
- # The TaskManager module is a mixin for managing tasks.
- module TaskManager
- # Track the last comment made in the Rakefile.
- attr_accessor :last_description
- alias :last_comment :last_description # Backwards compatibility
-
- def initialize
- super
- @tasks = Hash.new
- @rules = Array.new
- @scope = Array.new
- @last_description = nil
- end
-
- def create_rule(*args, &block)
- pattern, _, deps = resolve_args(args)
- pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
- @rules << [pattern, deps, block]
- end
-
- def define_task(task_class, *args, &block)
- task_name, arg_names, deps = resolve_args(args)
- task_name = task_class.scope_name(@scope, task_name)
- deps = [deps] unless deps.respond_to?(:to_ary)
- deps = deps.collect {|d| d.to_s }
- task = intern(task_class, task_name)
- task.set_arg_names(arg_names) unless arg_names.empty?
- if Rake::TaskManager.record_task_metadata
- add_location(task)
- task.add_description(get_description(task))
- end
- task.enhance(deps, &block)
- end
-
- # Lookup a task. Return an existing task if found, otherwise
- # create a task of the current type.
- def intern(task_class, task_name)
- @tasks[task_name.to_s] ||= task_class.new(task_name, self)
- end
-
- # Find a matching task for +task_name+.
- def [](task_name, scopes=nil)
- task_name = task_name.to_s
- self.lookup(task_name, scopes) or
- enhance_with_matching_rule(task_name) or
- synthesize_file_task(task_name) or
- fail "Don't know how to build task '#{task_name}'"
- end
-
- def synthesize_file_task(task_name)
- return nil unless File.exist?(task_name)
- define_task(Rake::FileTask, task_name)
- end
-
- # Resolve the arguments for a task/rule. Returns a triplet of
- # [task_name, arg_name_list, prerequisites].
- def resolve_args(args)
- if args.last.is_a?(Hash)
- deps = args.pop
- resolve_args_with_dependencies(args, deps)
- else
- resolve_args_without_dependencies(args)
- end
- end
-
- # Resolve task arguments for a task or rule when there are no
- # dependencies declared.
- #
- # The patterns recognized by this argument resolving function are:
- #
- # task :t
- # task :t, [:a]
- # task :t, :a (deprecated)
- #
- def resolve_args_without_dependencies(args)
- task_name = args.shift
- if args.size == 1 && args.first.respond_to?(:to_ary)
- arg_names = args.first.to_ary
- else
- arg_names = args
- end
- [task_name, arg_names, []]
- end
- private :resolve_args_without_dependencies
-
- # Resolve task arguments for a task or rule when there are
- # dependencies declared.
- #
- # The patterns recognized by this argument resolving function are:
- #
- # task :t => [:d]
- # task :t, [a] => [:d]
- # task :t, :needs => [:d] (deprecated)
- # task :t, :a, :needs => [:d] (deprecated)
- #
- def resolve_args_with_dependencies(args, hash) # :nodoc:
- fail "Task Argument Error" if hash.size != 1
- key, value = hash.map { |k, v| [k,v] }.first
- if args.empty?
- task_name = key
- arg_names = []
- deps = value
- elsif key == :needs
- Rake.application.deprecate(
- "task :t, arg, :needs => [deps]",
- "task :t, [args] => [deps]",
- caller.detect { |c| c !~ /\blib\/rake\b/ })
- task_name = args.shift
- arg_names = args
- deps = value
- else
- task_name = args.shift
- arg_names = key
- deps = value
- end
- deps = [deps] unless deps.respond_to?(:to_ary)
- [task_name, arg_names, deps]
- end
- private :resolve_args_with_dependencies
-
- # If a rule can be found that matches the task name, enhance the
- # task with the prerequisites and actions from the rule. Set the
- # source attribute of the task appropriately for the rule. Return
- # the enhanced task or nil of no rule was found.
- def enhance_with_matching_rule(task_name, level=0)
- fail Rake::RuleRecursionOverflowError,
- "Rule Recursion Too Deep" if level >= 16
- @rules.each do |pattern, extensions, block|
- if pattern.match(task_name)
- task = attempt_rule(task_name, extensions, block, level)
- return task if task
- end
- end
- nil
- rescue Rake::RuleRecursionOverflowError => ex
- ex.add_target(task_name)
- fail ex
- end
-
- # List of all defined tasks in this application.
- def tasks
- @tasks.values.sort_by { |t| t.name }
- end
-
- # List of all the tasks defined in the given scope (and its
- # sub-scopes).
- def tasks_in_scope(scope)
- prefix = scope.join(":")
- tasks.select { |t|
- /^#{prefix}:/ =~ t.name
- }
- end
-
- # Clear all tasks in this application.
- def clear
- @tasks.clear
- @rules.clear
- end
-
- # Lookup a task, using scope and the scope hints in the task name.
- # This method performs straight lookups without trying to
- # synthesize file tasks or rules. Special scope names (e.g. '^')
- # are recognized. If no scope argument is supplied, use the
- # current scope. Return nil if the task cannot be found.
- def lookup(task_name, initial_scope=nil)
- initial_scope ||= @scope
- task_name = task_name.to_s
- if task_name =~ /^rake:/
- scopes = []
- task_name = task_name.sub(/^rake:/, '')
- elsif task_name =~ /^(\^+)/
- scopes = initial_scope[0, initial_scope.size - $1.size]
- task_name = task_name.sub(/^(\^+)/, '')
- else
- scopes = initial_scope
- end
- lookup_in_scope(task_name, scopes)
- end
-
- # Lookup the task name
- def lookup_in_scope(name, scope)
- n = scope.size
- while n >= 0
- tn = (scope[0,n] + [name]).join(':')
- task = @tasks[tn]
- return task if task
- n -= 1
- end
- nil
- end
- private :lookup_in_scope
-
- # Return the list of scope names currently active in the task
- # manager.
- def current_scope
- @scope.dup
- end
-
- # Evaluate the block in a nested namespace named +name+. Create
- # an anonymous namespace if +name+ is nil.
- def in_namespace(name)
- name ||= generate_name
- @scope.push(name)
- ns = NameSpace.new(self, @scope)
- yield(ns)
- ns
- ensure
- @scope.pop
- end
-
- private
-
- # Add a location to the locations field of the given task.
- def add_location(task)
- loc = find_location
- task.locations << loc if loc
- task
- end
-
- # Find the location that called into the dsl layer.
- def find_location
- locations = caller
- i = 0
- while locations[i]
- return locations[i+1] if locations[i] =~ /rake\/dsl_definition.rb/
- i += 1
- end
- nil
- end
-
- # Generate an anonymous namespace name.
- def generate_name
- @seed ||= 0
- @seed += 1
- "_anon_#{@seed}"
- end
-
- def trace_rule(level, message)
- $stderr.puts "#{" "*level}#{message}" if Rake.application.options.trace_rules
- end
-
- # Attempt to create a rule given the list of prerequisites.
- def attempt_rule(task_name, extensions, block, level)
- sources = make_sources(task_name, extensions)
- prereqs = sources.collect { |source|
- trace_rule level, "Attempting Rule #{task_name} => #{source}"
- if File.exist?(source) || Rake::Task.task_defined?(source)
- trace_rule level, "(#{task_name} => #{source} ... EXIST)"
- source
- elsif parent = enhance_with_matching_rule(source, level+1)
- trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
- parent.name
- else
- trace_rule level, "(#{task_name} => #{source} ... FAIL)"
- return nil
- end
- }
- task = FileTask.define_task({task_name => prereqs}, &block)
- task.sources = prereqs
- task
- end
-
- # Make a list of sources from the list of file name extensions /
- # translation procs.
- def make_sources(task_name, extensions)
- result = extensions.collect { |ext|
- case ext
- when /%/
- task_name.pathmap(ext)
- when %r{/}
- ext
- when /^\./
- task_name.ext(ext)
- when String
- ext
- when Proc
- if ext.arity == 1
- ext.call(task_name)
- else
- ext.call
- end
- else
- fail "Don't know how to handle rule dependent: #{ext.inspect}"
- end
- }
- result.flatten
- end
-
-
- private
-
- # Return the current description, clearing it in the process.
- def get_description(task)
- desc = @last_description
- @last_description = nil
- desc
- end
-
- class << self
- attr_accessor :record_task_metadata
- TaskManager.record_task_metadata = false
- end
- end
-
-end
+++ /dev/null
-require 'rake'
-
-module Rake
-
- # Base class for Task Libraries.
- class TaskLib
- include Cloneable
- include Rake::DSL
-
- # Make a symbol by pasting two strings together.
- #
- # NOTE: DEPRECATED! This method is kinda stupid. I don't know why
- # I didn't just use string interpolation. But now other task
- # libraries depend on this so I can't remove it without breaking
- # other people's code. So for now it stays for backwards
- # compatibility. BUT DON'T USE IT.
- def paste(a,b) # :nodoc:
- (a.to_s + b.to_s).intern
- end
- end
-
-end
+++ /dev/null
-# Define a task library for running unit tests.
-
-require 'rake'
-require 'rake/tasklib'
-
-module Rake
-
- # Create a task that runs a set of tests.
- #
- # Example:
- #
- # Rake::TestTask.new do |t|
- # t.libs << "test"
- # t.test_files = FileList['test/test*.rb']
- # t.verbose = true
- # end
- #
- # If rake is invoked with a "TEST=filename" command line option,
- # then the list of test files will be overridden to include only the
- # filename specified on the command line. This provides an easy way
- # to run just one test.
- #
- # If rake is invoked with a "TESTOPTS=options" command line option,
- # then the given options are passed to the test process after a
- # '--'. This allows Test::Unit options to be passed to the test
- # suite.
- #
- # Examples:
- #
- # rake test # run tests normally
- # rake test TEST=just_one_file.rb # run just one test file.
- # rake test TESTOPTS="-v" # run in verbose mode
- # rake test TESTOPTS="--runner=fox" # use the fox test runner
- #
- class TestTask < TaskLib
-
- # Name of test task. (default is :test)
- attr_accessor :name
-
- # List of directories to added to $LOAD_PATH before running the
- # tests. (default is 'lib')
- attr_accessor :libs
-
- # True if verbose test output desired. (default is false)
- attr_accessor :verbose
-
- # Test options passed to the test suite. An explicit
- # TESTOPTS=opts on the command line will override this. (default
- # is NONE)
- attr_accessor :options
-
- # Request that the tests be run with the warning flag set.
- # E.g. warning=true implies "ruby -w" used to run the tests.
- attr_accessor :warning
-
- # Glob pattern to match test files. (default is 'test/test*.rb')
- attr_accessor :pattern
-
- # Style of test loader to use. Options are:
- #
- # * :rake -- Rake provided test loading script (default).
- # * :testrb -- Ruby provided test loading script.
- # * :direct -- Load tests using command line loader.
- #
- attr_accessor :loader
-
- # Array of commandline options to pass to ruby when running test loader.
- attr_accessor :ruby_opts
-
- # Explicitly define the list of test files to be included in a
- # test. +list+ is expected to be an array of file names (a
- # FileList is acceptable). If both +pattern+ and +test_files+ are
- # used, then the list of test files is the union of the two.
- def test_files=(list)
- @test_files = list
- end
-
- # Create a testing task.
- def initialize(name=:test)
- @name = name
- @libs = ["lib"]
- @pattern = nil
- @options = nil
- @test_files = nil
- @verbose = false
- @warning = false
- @loader = :rake
- @ruby_opts = []
- yield self if block_given?
- @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
- define
- end
-
- # Create the tasks defined by this task lib.
- def define
- desc "Run tests" + (@name==:test ? "" : " for #{@name}")
- task @name do
- FileUtilsExt.verbose(@verbose) do
- ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}"
- end
- end
- self
- end
-
- def option_list # :nodoc:
- (ENV['TESTOPTS'] ||
- ENV['TESTOPT'] ||
- ENV['TEST_OPTS'] ||
- ENV['TEST_OPT'] ||
- @options ||
- "")
- end
-
- def ruby_opts_string
- opts = @ruby_opts.dup
- opts.unshift( "-I\"#{lib_path}\"" ) unless @libs.empty?
- opts.unshift( "-w" ) if @warning
- opts.join(" ")
- end
-
- def lib_path
- @libs.join(File::PATH_SEPARATOR)
- end
-
- def file_list_string
- file_list.collect { |fn| "\"#{fn}\"" }.join(' ')
- end
-
- def file_list # :nodoc:
- if ENV['TEST']
- FileList[ ENV['TEST'] ]
- else
- result = []
- result += @test_files.to_a if @test_files
- result << @pattern if @pattern
- result
- end
- end
-
- def fix # :nodoc:
- case ruby_version
- when '1.8.2'
- "\"#{find_file 'rake/ruby182_test_unit_fix'}\""
- else
- nil
- end || ''
- end
-
- def ruby_version
- RUBY_VERSION
- end
-
- def run_code
- case @loader
- when :direct
- "-e \"ARGV.each{|f| require f}\""
- when :testrb
- "-S testrb #{fix}"
- when :rake
- "-I\"#{rake_lib_dir}\" \"#{rake_loader}\""
- end
- end
-
- def rake_loader # :nodoc:
- find_file('rake/rake_test_loader') or
- fail "unable to find rake test loader"
- end
-
- def find_file(fn) # :nodoc:
- $LOAD_PATH.each do |path|
- file_path = File.join(path, "#{fn}.rb")
- return file_path if File.exist? file_path
- end
- nil
- end
-
- def rake_lib_dir # :nodoc:
- find_dir('rake') or
- fail "unable to find rake lib"
- end
-
- def find_dir(fn) # :nodoc:
- $LOAD_PATH.each do |path|
- file_path = File.join(path, "#{fn}.rb")
- return path if File.exist? file_path
- end
- nil
- end
-
- end
-end
+++ /dev/null
-module Rake
- VERSION = '0.9.2.2'
-
- module Version # :nodoc: all
- MAJOR, MINOR, BUILD, PATCH = VERSION.split('.')
- NUMBERS = [ MAJOR, MINOR, BUILD, PATCH ]
- end
-end
+++ /dev/null
-
-module Rake
- require 'rake/alt_system'
-
- # Win 32 interface methods for Rake. Windows specific functionality
- # will be placed here to collect that knowledge in one spot.
- module Win32
-
- # Error indicating a problem in locating the home directory on a
- # Win32 system.
- class Win32HomeError < RuntimeError
- end
-
- class << self
- # True if running on a windows system.
- def windows?
- AltSystem::WINDOWS
- end
-
- # Run a command line on windows.
- def rake_system(*cmd)
- AltSystem.system(*cmd)
- end
-
- # The standard directory containing system wide rake files on
- # Win 32 systems. Try the following environment variables (in
- # order):
- #
- # * HOME
- # * HOMEDRIVE + HOMEPATH
- # * APPDATA
- # * USERPROFILE
- #
- # If the above are not defined, the return nil.
- def win32_system_dir #:nodoc:
- win32_shared_path = ENV['HOME']
- if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
- win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
- end
-
- win32_shared_path ||= ENV['APPDATA']
- win32_shared_path ||= ENV['USERPROFILE']
- raise Win32HomeError, "Unable to determine home path environment variable." if
- win32_shared_path.nil? or win32_shared_path.empty?
- normalize(File.join(win32_shared_path, 'Rake'))
- end
-
- # Normalize a win32 path so that the slashes are all forward slashes.
- def normalize(path)
- path.gsub(/\\/, '/')
- end
-
- end
- end
-end
+++ /dev/null
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "actionmailer"
- s.version = "2.3.15"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["David Heinemeier Hansson"]
- s.date = "2013-01-08"
- s.description = "Makes it trivial to test and deliver emails sent from a single service layer."
- s.email = "david@loudthinking.com"
- s.homepage = "http://www.rubyonrails.org"
- s.require_paths = ["lib"]
- s.requirements = ["none"]
- s.rubyforge_project = "actionmailer"
- s.rubygems_version = "1.8.23"
- s.summary = "Service layer for easy email delivery and testing."
-
- if s.respond_to? :specification_version then
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<actionpack>, ["= 2.3.15"])
- else
- s.add_dependency(%q<actionpack>, ["= 2.3.15"])
- end
- else
- s.add_dependency(%q<actionpack>, ["= 2.3.15"])
- end
-end
+++ /dev/null
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "activerecord-oracle_enhanced-adapter"
- s.version = "1.4.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Raimonds Simanovskis"]
- s.date = "2011-08-08"
- s.description = "Oracle \"enhanced\" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.\nThis adapter is superset of original ActiveRecord Oracle adapter.\n"
- s.email = "raimonds.simanovskis@gmail.com"
- s.extra_rdoc_files = ["README.md"]
- s.files = ["README.md"]
- s.homepage = "http://github.com/rsim/oracle-enhanced"
- s.require_paths = ["lib"]
- s.rubygems_version = "1.8.23"
- s.summary = "Oracle enhanced adapter for ActiveRecord"
-
- if s.respond_to? :specification_version then
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_development_dependency(%q<rspec>, ["~> 2.4"])
- s.add_development_dependency(%q<activerecord>, [">= 0"])
- s.add_development_dependency(%q<activemodel>, [">= 0"])
- s.add_development_dependency(%q<activesupport>, [">= 0"])
- s.add_development_dependency(%q<actionpack>, [">= 0"])
- s.add_development_dependency(%q<railties>, [">= 0"])
- s.add_development_dependency(%q<arel>, [">= 0"])
- s.add_development_dependency(%q<ruby-plsql>, [">= 0.4.4"])
- s.add_development_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
- else
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_dependency(%q<rspec>, ["~> 2.4"])
- s.add_dependency(%q<activerecord>, [">= 0"])
- s.add_dependency(%q<activemodel>, [">= 0"])
- s.add_dependency(%q<activesupport>, [">= 0"])
- s.add_dependency(%q<actionpack>, [">= 0"])
- s.add_dependency(%q<railties>, [">= 0"])
- s.add_dependency(%q<arel>, [">= 0"])
- s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
- s.add_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
- end
- else
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- s.add_dependency(%q<rspec>, ["~> 2.4"])
- s.add_dependency(%q<activerecord>, [">= 0"])
- s.add_dependency(%q<activemodel>, [">= 0"])
- s.add_dependency(%q<activesupport>, [">= 0"])
- s.add_dependency(%q<actionpack>, [">= 0"])
- s.add_dependency(%q<railties>, [">= 0"])
- s.add_dependency(%q<arel>, [">= 0"])
- s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
- s.add_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
- end
-end
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rake>, [">= 0.8.3"])
+ # sonar - unused
+ #s.add_runtime_dependency(%q<rake>, [">= 0.8.3"])
+ # /sonar
+
s.add_runtime_dependency(%q<activesupport>, ["= 2.3.15"])
s.add_runtime_dependency(%q<activerecord>, ["= 2.3.15"])
s.add_runtime_dependency(%q<actionpack>, ["= 2.3.15"])
- s.add_runtime_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # sonar - unused
+ #s.add_runtime_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # /sonar
s.add_runtime_dependency(%q<activeresource>, ["= 2.3.15"])
else
- s.add_dependency(%q<rake>, [">= 0.8.3"])
+ # sonar - unused
+ #s.add_dependency(%q<rake>, [">= 0.8.3"])
+ # /sonar
s.add_dependency(%q<activesupport>, ["= 2.3.15"])
s.add_dependency(%q<activerecord>, ["= 2.3.15"])
s.add_dependency(%q<actionpack>, ["= 2.3.15"])
- s.add_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # sonar - unused
+ #s.add_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # /sonar
s.add_dependency(%q<activeresource>, ["= 2.3.15"])
end
else
- s.add_dependency(%q<rake>, [">= 0.8.3"])
+ # sonar - unused
+ #s.add_dependency(%q<rake>, [">= 0.8.3"])
+ # /sonar
s.add_dependency(%q<activesupport>, ["= 2.3.15"])
s.add_dependency(%q<activerecord>, ["= 2.3.15"])
s.add_dependency(%q<actionpack>, ["= 2.3.15"])
- s.add_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # sonar - unused
+ #s.add_dependency(%q<actionmailer>, ["= 2.3.15"])
+ # /sonar
s.add_dependency(%q<activeresource>, ["= 2.3.15"])
end
end
+++ /dev/null
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = "rake"
- s.version = "0.9.2.2"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 1.3.2") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jim Weirich"]
- s.date = "2011-10-22"
- s.description = "Rake is a Make-like program implemented in Ruby. Tasks and dependencies arespecified in standard Ruby syntax."
- s.email = "jim@weirichhouse.org"
- s.executables = ["rake"]
- s.extra_rdoc_files = ["README.rdoc", "MIT-LICENSE", "TODO", "CHANGES", "doc/command_line_usage.rdoc", "doc/glossary.rdoc", "doc/proto_rake.rdoc", "doc/rakefile.rdoc", "doc/rational.rdoc", "doc/release_notes/rake-0.4.14.rdoc", "doc/release_notes/rake-0.4.15.rdoc", "doc/release_notes/rake-0.5.0.rdoc", "doc/release_notes/rake-0.5.3.rdoc", "doc/release_notes/rake-0.5.4.rdoc", "doc/release_notes/rake-0.6.0.rdoc", "doc/release_notes/rake-0.7.0.rdoc", "doc/release_notes/rake-0.7.1.rdoc", "doc/release_notes/rake-0.7.2.rdoc", "doc/release_notes/rake-0.7.3.rdoc", "doc/release_notes/rake-0.8.0.rdoc", "doc/release_notes/rake-0.8.2.rdoc", "doc/release_notes/rake-0.8.3.rdoc", "doc/release_notes/rake-0.8.4.rdoc", "doc/release_notes/rake-0.8.5.rdoc", "doc/release_notes/rake-0.8.6.rdoc", "doc/release_notes/rake-0.8.7.rdoc", "doc/release_notes/rake-0.9.0.rdoc", "doc/release_notes/rake-0.9.1.rdoc", "doc/release_notes/rake-0.9.2.rdoc"]
- s.files = ["bin/rake", "README.rdoc", "MIT-LICENSE", "TODO", "CHANGES", "doc/command_line_usage.rdoc", "doc/glossary.rdoc", "doc/proto_rake.rdoc", "doc/rakefile.rdoc", "doc/rational.rdoc", "doc/release_notes/rake-0.4.14.rdoc", "doc/release_notes/rake-0.4.15.rdoc", "doc/release_notes/rake-0.5.0.rdoc", "doc/release_notes/rake-0.5.3.rdoc", "doc/release_notes/rake-0.5.4.rdoc", "doc/release_notes/rake-0.6.0.rdoc", "doc/release_notes/rake-0.7.0.rdoc", "doc/release_notes/rake-0.7.1.rdoc", "doc/release_notes/rake-0.7.2.rdoc", "doc/release_notes/rake-0.7.3.rdoc", "doc/release_notes/rake-0.8.0.rdoc", "doc/release_notes/rake-0.8.2.rdoc", "doc/release_notes/rake-0.8.3.rdoc", "doc/release_notes/rake-0.8.4.rdoc", "doc/release_notes/rake-0.8.5.rdoc", "doc/release_notes/rake-0.8.6.rdoc", "doc/release_notes/rake-0.8.7.rdoc", "doc/release_notes/rake-0.9.0.rdoc", "doc/release_notes/rake-0.9.1.rdoc", "doc/release_notes/rake-0.9.2.rdoc"]
- s.homepage = "http://rake.rubyforge.org"
- s.rdoc_options = ["--line-numbers", "--show-hash", "--main", "README.rdoc", "--title", "Rake -- Ruby Make"]
- s.require_paths = ["lib"]
- s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
- s.rubyforge_project = "rake"
- s.rubygems_version = "1.8.15"
- s.summary = "Ruby based make-like utility."
-
- if s.respond_to? :specification_version then
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<minitest>, ["~> 2.1"])
- else
- s.add_dependency(%q<minitest>, ["~> 2.1"])
- end
- else
- s.add_dependency(%q<minitest>, ["~> 2.1"])
- end
-end