Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* NEWS (with all sufficient information):

* lib/rake:  Update to rake 10.1.0
* bin/rake:  ditto.
* test/rake:  ditto.

* NEWS:  Update NEWS to include rake 10.1.0 and links to release notes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 9cadc95b28da1cf6ca8f802292d12cc96a4f2c2d 1 parent 52c1331
@drbrain drbrain authored
Showing with 1,723 additions and 2,953 deletions.
  1. +8 −0 ChangeLog
  2. +11 −0 NEWS
  3. +0 −4 bin/rake
  4. +2 −0  lib/rake.rb
  5. +3 −4 lib/rake/alt_system.rb
  6. +134 −108 lib/rake/application.rb
  7. +9 −7 lib/rake/backtrace.rb
  8. +0 −11 lib/rake/classic_namespace.rb
  9. +27 −4 lib/rake/clean.rb
  10. +6 −18 lib/rake/contrib/ftptools.rb
  11. +2 −192 lib/rake/contrib/sys.rb
  12. +0 −21 lib/rake/doc/MIT-LICENSE
  13. +0 −187 lib/rake/doc/README.rdoc
  14. +0 −152 lib/rake/doc/command_line_usage.rdoc
  15. +0 −51 lib/rake/doc/glossary.rdoc
  16. +0 −557 lib/rake/doc/rakefile.rdoc
  17. +0 −151 lib/rake/doc/rational.rdoc
  18. +2 −27 lib/rake/dsl_definition.rb
  19. +2 −1  lib/rake/ext/core.rb
  20. +0 −39 lib/rake/ext/module.rb
  21. +1 −3 lib/rake/ext/string.rb
  22. +24 −18 lib/rake/file_list.rb
  23. +1 −2  lib/rake/file_task.rb
  24. +11 −9 lib/rake/file_utils.rb
  25. +3 −5 lib/rake/file_utils_ext.rb
  26. +2 −15 lib/rake/gempackagetask.rb
  27. +24 −18 lib/rake/invocation_chain.rb
  28. +103 −0 lib/rake/linked_list.rb
  29. +1 −1  lib/rake/name_space.rb
  30. +11 −6 lib/rake/packagetask.rb
  31. +1 −1  lib/rake/promise.rb
  32. +5 −0 lib/rake/pseudo_status.rb
  33. +2 −234 lib/rake/rdoctask.rb
  34. +4 −2 lib/rake/ruby182_test_unit_fix.rb
  35. +2 −2 lib/rake/runtest.rb
  36. +42 −0 lib/rake/scope.rb
  37. +74 −46 lib/rake/task.rb
  38. +13 −2 lib/rake/task_arguments.rb
  39. +25 −35 lib/rake/task_manager.rb
  40. +1 −1  lib/rake/tasklib.rb
  41. +11 −8 lib/rake/testtask.rb
  42. +1 −1  lib/rake/thread_history_display.rb
  43. +10 −4 lib/rake/thread_pool.rb
  44. +4 −1 lib/rake/trace_output.rb
  45. +3 −8 lib/rake/version.rb
  46. +3 −2 lib/rake/win32.rb
  47. +36 −470 test/rake/helper.rb
  48. +444 −0 test/rake/support/rakefile_definitions.rb
  49. +33 −0 test/rake/support/ruby_runner.rb
  50. +14 −28 test/rake/test_rake_application.rb
  51. +33 −36 test/rake/test_rake_application_options.rb
  52. +38 −14 test/rake/test_rake_backtrace.rb
  53. +36 −4 test/rake/test_rake_clean.rb
  54. +2 −3 test/rake/test_rake_definitions.rb
  55. +0 −37 test/rake/test_rake_dsl.rb
  56. +2 −2 test/rake/test_rake_file_creation_task.rb
  57. +23 −24 test/rake/test_rake_file_list.rb
  58. +6 −6 test/rake/test_rake_file_task.rb
  59. +6 −2 test/rake/test_rake_file_utils.rb
  60. +28 −13 test/rake/test_rake_ftp_file.rb
  61. +6 −36 test/rake/test_rake_functional.rb
  62. +15 −3 test/rake/test_rake_invocation_chain.rb
  63. +84 −0 test/rake/test_rake_linked_list.rb
  64. +3 −1 test/rake/test_rake_makefile_loader.rb
  65. +2 −3 test/rake/test_rake_multi_task.rb
  66. +1 −1  test/rake/test_rake_name_space.rb
  67. +23 −12 test/rake/test_rake_path_map.rb
  68. +2 −3 test/rake/test_rake_rake_test_loader.rb
  69. +0 −83 test/rake/test_rake_rdoc_task.rb
  70. +4 −43 test/rake/test_rake_reduce_compat.rb
  71. +50 −15 test/rake/test_rake_rules.rb
  72. +44 −0 test/rake/test_rake_scope.rb
  73. +73 −13 test/rake/test_rake_task.rb
  74. +35 −2 test/rake/test_rake_task_arguments.rb
  75. +16 −15 test/rake/test_rake_task_manager.rb
  76. +0 −17 test/rake/test_rake_task_manager_argument_resolution.rb
  77. +7 −17 test/rake/test_rake_task_with_arguments.rb
  78. +1 −2  test/rake/test_rake_test_task.rb
  79. +43 −24 test/rake/test_rake_thread_pool.rb
  80. +0 −40 test/rake/test_rake_top_level_functions.rb
  81. +0 −20 test/rake/test_sys.rb
  82. +16 −6 test/rake/test_thread_history_display.rb
  83. +9 −0 test/rake/test_trace_output.rb
View
8 ChangeLog
@@ -1,3 +1,11 @@
+2013-10-11 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rake: Update to rake 10.1.0
+ * bin/rake: ditto.
+ * test/rake: ditto.
+
+ * NEWS: Update NEWS to include rake 10.1.0 and links to release notes.
+
Sat Oct 12 03:26:04 2013 Koichi Sasada <ko1@atdot.net>
* class.c, variable.c, gc.c (rb_class_tbl): removed.
View
11 NEWS
@@ -174,6 +174,17 @@ with all sufficient information, see the ChangeLog file.
* open-uri
* Support multiple fields with same field name (like Set-Cookie).
+* rake
+ * Updated to 10.1.0. Major changes include removal of the class namespace,
+ Rake::DSL to hold the rake DSL methods and removal of support for legacy
+ rake features.
+
+ For a complete list of changes since rake 0.9.6 see:
+
+ http://rake.rubyforge.org/doc/release_notes/rake-10_1_0_rdoc.html
+
+ http://rake.rubyforge.org/doc/release_notes/rake-10_0_3_rdoc.html
+
* RDoc
* Updated to 4.1.0.preview.1. Major enhancements include a modified default
template and accessibility enhancements.
View
4 bin/rake
@@ -28,10 +28,6 @@ begin
rescue LoadError
end
-module Rake
- REDUCE_COMPAT = true if ARGV.include?("--reduce-compat")
-end
-
require 'rake'
Rake.application.run
View
2  lib/rake.rb
@@ -40,6 +40,8 @@
require 'rake/win32'
+require 'rake/linked_list'
+require 'rake/scope'
require 'rake/task_argument_error'
require 'rake/rule_recursion_overflow_error'
require 'rake/rake_module'
View
7 lib/rake/alt_system.rb
@@ -39,7 +39,7 @@ def define_module_function(name, &block)
end
end
- if WINDOWS and RUBY_VERSION < "1.9.0"
+ if WINDOWS && RUBY_VERSION < "1.9.0"
RUNNABLE_EXTS = %w[com exe bat cmd]
RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
@@ -73,9 +73,8 @@ def find_runnable(file)
file
else
RUNNABLE_EXTS.each { |ext|
- if File.exist?(test = "#{file}.#{ext}")
- return test
- end
+ test = "#{file}.#{ext}"
+ return test if File.exist?(test)
}
nil
end
View
242 lib/rake/application.rb
@@ -35,7 +35,12 @@ class Application
# 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
+ DEFAULT_RAKEFILES = [
+ 'rakefile',
+ 'Rakefile',
+ 'rakefile.rb',
+ 'Rakefile.rb'
+ ].freeze
# Initialize a Rake::Application object.
def initialize
@@ -115,7 +120,8 @@ def run_with_threads
puts "Maximum active threads: #{stats[:max_active_threads]}"
puts "Total threads in play: #{stats[:total_threads_in_play]}"
end
- ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history
+ ThreadHistoryDisplay.new(thread_pool.history).show if
+ options.job_stats == :history
end
# Add a loader to handle imported files ending in the extension
@@ -132,7 +138,7 @@ def options
# Return the thread pool used for multithreaded processing.
def thread_pool # :nodoc:
- @thread_pool ||= ThreadPool.new(options.thread_pool_size||FIXNUM_MAX)
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size || FIXNUM_MAX)
end
# private ----------------------------------------------------------------
@@ -156,19 +162,23 @@ def parse_task_string(string)
# 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
+ yield
+ rescue SystemExit
+ # 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_because_of_exception(ex)
+ end
+
+ # Exit the program because of an unhandle exception.
+ # (may be overridden by subclasses)
+ def exit_because_of_exception(ex)
+ exit(false)
end
# Display the error message that caused the exception.
@@ -181,7 +191,8 @@ def display_error_message(ex)
trace Backtrace.collapse(ex.backtrace).join("\n")
end
trace "Tasks: #{ex.chain}" if has_chain?(ex)
- trace "(See full trace by running task with --trace)" unless options.backtrace
+ trace "(See full trace by running task with --trace)" unless
+ options.backtrace
end
# Warn about deprecated usage.
@@ -190,10 +201,11 @@ def display_error_message(ex)
# 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}"
+ unless options.ignore_deprecate
+ $stderr.puts "WARNING: '#{old_usage}' is deprecated. " +
+ "Please use '#{new_usage}' instead.\n" +
+ " at #{call_site}"
+ end
end
# Does the exception have a task invocation chain?
@@ -222,7 +234,7 @@ def tty_output?
end
# Override the detected TTY output state (mostly for testing)
- def tty_output=( tty_output_state )
+ def tty_output=(tty_output_state)
@tty_output = tty_output_state
end
@@ -235,16 +247,22 @@ def truncate_output?
# Display the tasks and comments.
def display_tasks_and_comments
displayable_tasks = tasks.select { |t|
- (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern
+ (options.show_all_tasks || 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
+ width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10
+ if truncate_output?
+ max_column = terminal_width - name.size - width - 7
+ else
+ max_column = nil
+ end
displayable_tasks.each do |t|
- printf "#{name} %-#{width}s # %s\n",
- t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
+ 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|
@@ -258,7 +276,7 @@ def display_tasks_and_comments
when :lines
displayable_tasks.each do |t|
t.locations.each do |loc|
- printf "#{name} %-30s %s\n",t.name_with_args, loc
+ printf "#{name} %-30s %s\n", t.name_with_args, loc
end
end
else
@@ -291,7 +309,8 @@ def dynamic_width_tput
end
def unix?
- RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
+ RbConfig::CONFIG['host_os'] =~
+ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
end
def windows?
@@ -304,7 +323,7 @@ def truncate(string, width)
elsif string.length <= width
string
else
- ( string[0, width-3] || "" ) + "..."
+ (string[0, width - 3] || "") + "..."
end
end
@@ -333,34 +352,33 @@ def sort_options(options)
def standard_rake_options
sort_options(
[
- ['--all', '-A', "Show all tasks, even uncommented ones",
+ ['--all', '-A',
+ "Show all tasks, even uncommented ones",
lambda { |value|
options.show_all_tasks = value
}
],
- ['--backtrace=[OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
+ ['--backtrace=[OUT]',
+ "Enable full backtrace. OUT can be stderr (default) or stdout.",
lambda { |value|
options.backtrace = true
select_trace_output(options, 'backtrace', value)
}
],
- ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
- lambda { |value|
- require 'rake/classic_namespace'
- options.classic_namespace = true
- }
- ],
- ['--comments', "Show commented tasks only",
+ ['--comments',
+ "Show commented tasks only",
lambda { |value|
options.show_all_tasks = !value
}
],
- ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
+ ['--describe', '-D [PATTERN]',
+ "Describe the tasks (matching optional PATTERN), then exit.",
lambda { |value|
select_tasks_to_show(options, :describe, value)
}
],
- ['--dry-run', '-n', "Do a dry run without executing actions.",
+ ['--dry-run', '-n',
+ "Do a dry run without executing actions.",
lambda { |value|
Rake.verbose(true)
Rake.nowrite(true)
@@ -368,28 +386,35 @@ def standard_rake_options
options.trace = true
}
],
- ['--execute', '-e CODE', "Execute some Ruby code and exit.",
+ ['--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.",
+ ['--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.",
+ "Execute some Ruby code, " +
+ "then continue with normal task processing.",
lambda { |value| eval(value) }
],
['--jobs', '-j [NUMBER]',
- "Specifies the maximum number of tasks to execute in parallel. (default:2)",
- lambda { |value| options.thread_pool_size = [(value || 2).to_i,2].max }
+ "Specifies the maximum number of tasks to execute in parallel. " +
+ "(default is 2)",
+ lambda { |value|
+ options.thread_pool_size = [(value || 2).to_i, 2].max
+ }
],
['--job-stats [LEVEL]',
- "Display job statistics. LEVEL=history displays a complete job list",
+ "Display job statistics. " +
+ "LEVEL=history displays a complete job list",
lambda { |value|
if value =~ /^history/i
options.job_stats = :history
@@ -398,22 +423,28 @@ def standard_rake_options
end
}
],
- ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
+ ['--libdir', '-I LIBDIR',
+ "Include LIBDIR in the search path for required modules.",
lambda { |value| $:.push(value) }
],
- ['--multitask', '-m', "Treat all tasks as multitasks.",
+ ['--multitask', '-m',
+ "Treat all tasks as multitasks.",
lambda { |value| options.always_multitask = true }
],
- ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
+ ['--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.",
+ ['--prereqs', '-P',
+ "Display the tasks and dependencies, then exit.",
lambda { |value| options.show_prereqs = true }
],
- ['--quiet', '-q', "Do not log messages to standard output.",
+ ['--quiet', '-q',
+ "Do not log messages to standard output.",
lambda { |value| Rake.verbose(false) }
],
- ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
+ ['--rakefile', '-f [FILE]',
+ "Use FILE as the rakefile.",
lambda { |value|
value ||= ''
@rakefiles.clear
@@ -421,15 +452,14 @@ def standard_rake_options
}
],
['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
- lambda { |value| options.rakelib = value.split(File::PATH_SEPARATOR) }
- ],
- ['--reduce-compat', "Remove DSL in Object; remove Module#const_missing which defines ::Task etc.",
- # Load-time option.
- # Handled in bin/rake where Rake::REDUCE_COMPAT is defined (or not).
- lambda { |_| }
+ "Auto-import any .rake files in RAKELIBDIR. " +
+ "(default is 'rakelib')",
+ lambda { |value|
+ options.rakelib = value.split(File::PATH_SEPARATOR)
+ }
],
- ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
+ ['--require', '-r MODULE',
+ "Require MODULE before executing rakefile.",
lambda { |value|
begin
require value
@@ -442,34 +472,45 @@ def standard_rake_options
end
}
],
- ['--rules', "Trace the rules resolution.",
+ ['--rules',
+ "Trace the rules resolution.",
lambda { |value| options.trace_rules = true }
],
- ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
+ ['--silent', '-s',
+ "Like --quiet, but also suppresses the " +
+ "'in directory' announcement.",
lambda { |value|
Rake.verbose(false)
options.silent = true
}
],
- ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.",
+ ['--suppress-backtrace PATTERN',
+ "Suppress backtrace lines matching regexp PATTERN. " +
+ "Ignored if --trace is on.",
lambda { |value|
options.suppress_backtrace_pattern = Regexp.new(value)
}
],
['--system', '-g',
- "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
+ "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.",
+ "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.",
+ ['--tasks', '-T [PATTERN]',
+ "Display the tasks (matching optional PATTERN) " +
+ "with descriptions, then exit.",
lambda { |value|
select_tasks_to_show(options, :tasks, value)
}
],
- ['--trace=[OUT]', '-t', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
+ ['--trace=[OUT]', '-t',
+ "Turn on invoke/execute tracing, enable full backtrace. " +
+ "OUT can be stderr (default) or stdout.",
lambda { |value|
options.trace = true
options.backtrace = true
@@ -477,22 +518,26 @@ def standard_rake_options
Rake.verbose(true)
}
],
- ['--verbose', '-v', "Log message to standard output.",
+ ['--verbose', '-v',
+ "Log message to standard output.",
lambda { |value| Rake.verbose(true) }
],
- ['--version', '-V', "Display the program version.",
+ ['--version', '-V',
+ "Display the program version.",
lambda { |value|
puts "rake, version #{RAKEVERSION}"
exit
}
],
- ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
+ ['--where', '-W [PATTERN]',
+ "Describe the tasks (matching optional PATTERN), then exit.",
lambda { |value|
select_tasks_to_show(options, :lines, value)
options.show_all_tasks = true
}
],
- ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
+ ['--no-deprecation-warnings', '-X',
+ "Disable the deprecation warnings.",
lambda { |value|
options.ignore_deprecate = true
}
@@ -515,7 +560,8 @@ def select_trace_output(options, trace_option, value)
when 'stderr', nil
options.trace_output = $stderr
else
- fail CommandLineOptionError, "Unrecognized --#{trace_option} option '#{value}'"
+ fail CommandLineOptionError,
+ "Unrecognized --#{trace_option} option '#{value}'"
end
end
private :select_trace_output
@@ -526,7 +572,7 @@ def handle_options
options.trace_output = $stderr
OptionParser.new do |opts|
- opts.banner = "rake [-f rakefile] {options} targets..."
+ opts.banner = "#{Rake.application.name} [-f rakefile] {options} targets..."
opts.separator ""
opts.separator "Options are ..."
@@ -538,16 +584,6 @@ def handle_options
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
@@ -568,11 +604,9 @@ def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
def find_rakefile_location
here = Dir.pwd
- while ! (fn = have_rakefile)
+ until (fn = have_rakefile)
Dir.chdir("..")
- if Dir.pwd == here || options.nosearch
- return nil
- end
+ return nil if Dir.pwd == here || options.nosearch
here = Dir.pwd
end
[fn, here]
@@ -600,8 +634,8 @@ def raw_load_rakefile # :nodoc:
@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 != ''
+ Rake.load_rakefile(File.expand_path(@rakefile)) if
+ @rakefile && @rakefile != ''
options.rakelib.each do |rlib|
glob("#{rlib}/*.rake") do |name|
add_import name
@@ -646,13 +680,19 @@ def standard_system_dir #:nodoc:
def collect_tasks
@top_level_tasks = []
ARGV.each do |arg|
- if arg =~ /^(\w+)=(.*)$/
+ if arg =~ /^(\w+)=(.*)$/m
ENV[$1] = $2
else
@top_level_tasks << arg unless arg =~ /^-/
end
end
- @top_level_tasks.push("default") if @top_level_tasks.size == 0
+ @top_level_tasks.push(default_task_name) if @top_level_tasks.empty?
+ end
+
+ # Default task name ("default").
+ # (May be overridden by subclasses)
+ def default_task_name
+ "default"
end
# Add a file to the list of files to be imported.
@@ -664,9 +704,7 @@ def add_import(fn)
def load_imports
while fn = @pending_imports.shift
next if @imported.member?(fn)
- if fn_task = lookup(fn)
- fn_task.invoke
- end
+ fn_task = lookup(fn) and fn_task.invoke
ext = File.extname(fn)
loader = @loaders[ext] || @default_loader
loader.load(fn)
@@ -674,20 +712,8 @@ def load_imports
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] }
+ backtrace.map { |t| t[/([^:]+):/, 1] }
re = /^#{@rakefile}$/
re = /#{re.source}/i if windows?
View
16 lib/rake/backtrace.rb
@@ -1,13 +1,15 @@
module Rake
module Backtrace
- SUPPRESSED_PATHS =
- RbConfig::CONFIG.values_at(*RbConfig::CONFIG.
- keys.grep(/(prefix|libdir)/)).uniq + [
- File.join(File.dirname(__FILE__), ".."),
- ].map { |f| Regexp.quote(File.expand_path(f)) }
- SUPPRESSED_PATHS.reject! { |s| s.nil? || s =~ /^ *$/ }
+ SYS_KEYS = RbConfig::CONFIG.keys.grep(/(prefix|libdir)/)
+ SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq +
+ [ File.join(File.dirname(__FILE__), "..") ]
- SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!i
+ SUPPRESSED_PATHS = SYS_PATHS.
+ map { |s| s.gsub("\\", "/") }.
+ map { |f| File.expand_path(f) }.
+ reject { |s| s.nil? || s =~ /^ *$/ }
+ SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|")
+ SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
def self.collapse(backtrace)
pattern = Rake.application.options.suppress_backtrace_pattern ||
View
11 lib/rake/classic_namespace.rb
@@ -1,11 +0,0 @@
-# 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:
View
31 lib/rake/clean.rb
@@ -14,19 +14,42 @@
require 'rake'
# :stopdoc:
-CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
+
+module Rake
+ module Cleaner
+ extend FileUtils
+
+ module_function
+
+ def cleanup_files(file_names)
+ file_names.each do |file_name|
+ cleanup(file_name)
+ end
+ end
+
+ def cleanup(file_name, opts={})
+ begin
+ rm_r file_name, opts
+ rescue StandardError => ex
+ puts "Failed to remove #{file_name}: #{ex}"
+ end
+ end
+ end
+end
+
+CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"]
CLEAN.clear_exclude.exclude { |fn|
fn.pathmap("%f").downcase == 'core' && File.directory?(fn)
}
desc "Remove any temporary products."
task :clean do
- CLEAN.each { |fn| rm_r fn rescue nil }
+ Rake::Cleaner.cleanup_files(CLEAN)
end
-CLOBBER = Rake::FileList.new
+CLOBBER = ::Rake::FileList.new
desc "Remove any generated file."
task :clobber => [:clean] do
- CLOBBER.each { |fn| rm_r fn rescue nil }
+ Rake::Cleaner.cleanup_files(CLOBBER)
end
View
24 lib/rake/contrib/ftptools.rb
@@ -50,33 +50,21 @@ def symlink?
def parse_mode(m)
result = 0
(1..9).each do |i|
- result = 2*result + ((m[i]==?-) ? 0 : 1)
+ 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
+ if /:/ !~ d3
result = Time.parse("#{d1} #{d2} #{d3}")
+ else
+ result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
+ result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if
+ result > now
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
View
194 lib/rake/contrib/sys.rb
@@ -1,192 +1,2 @@
-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'
-require 'rake/file_list'
-
-######################################################################
-# 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)
- FileList.glob(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|
- FileList.glob(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|
- FileList.glob(wildcard).each do |fn|
- next if ! File.exist?(fn)
- if File.directory?(fn)
- FileList.glob("#{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|
- FileList.glob(wildcard).each do |fn|
- yield(fn)
- end
- end
- end
-
- extend(self)
-
- private # ----------------------------------------------------------
-
- def for_matching_files(wildcard, dest_dir)
- FileList.glob(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
+fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " +
+ "Use 'FileUtils' instead."
View
21 lib/rake/doc/MIT-LICENSE
@@ -1,21 +0,0 @@
-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.
-
View
187 lib/rake/doc/README.rdoc
@@ -1,187 +0,0 @@
-= 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
-
-== 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[https://github.com/jimweirich/rake/blob/master/doc/command_line_usage.rdoc]
-* For details on writing Rakefiles, see
- doc/rakefile.rdoc[https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc].
-* For the original announcement of Rake, see
- doc/rational.rdoc[https://github.com/jimweirich/rake/blob/master/doc/rational.rdoc].
-* For a glossary of terms, see
- doc/glossary.rdoc[https://github.com/jimweirich/rake/blob/master/doc/glossary.rdoc].
-
-== 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 Bug Reports: https://github.com/jimweirich/rake/issues
-* Rake Continuous Build Server: https://travis-ci.org/#!/jimweirich/rake
-
-=== 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.
-
-[<b>Eric Hodel</b>] For aid in maintaining rake.
-
-== License
-
-Rake is available under an MIT-style license.
-
-See {MIT-LICENSE}[rdoc-ref:lib/rake/doc/MIT-LICENSE] for permissions.
-
-== 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-2011 by Jim Weirich.
- Released under an MIT-style license. See the MIT-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.
View
152 lib/rake/doc/command_line_usage.rdoc
@@ -1,152 +0,0 @@
-= Rake Command Line Usage
-
-Rake is invoked from the command line using:
-
- % rake [options ...] [VAR=VALUE ...] [targets ...]
-
-Options are:
-
-[<tt><em>name</em>=<em>value</em></tt>]
- Set the environment variable <em>name</em> to <em>value</em>
- during the execution of the <b>rake</b> command. You can access
- the value by using ENV['<em>name</em>'].
-
-[<tt>--all</tt> (-A)]
- Used in combination with the -T and -D options, will force
- those options to show all the tasks, even the ones without comments.
-
-[<tt>--backtrace</tt>{=_output_} (-n)]
- Enable a full backtrace (i.e. like --trace, but without the task
- tracing details). The _output_ parameter is optional, but if
- specified it controls where the backtrace output is sent. If
- _output_ is <tt>stdout</tt>, then backtrace output is directed to
- stardard output. If _output_ is <tt>stderr</tt>, or if it is
- missing, then the backtrace output is sent to standard error.
-
-[<tt>--comments</tt>]
- Used in combination with the -W options to force the output to
- contain commented options only. This is the reverse of
- <tt>--all</tt>.
-
-[<tt>--describe</tt> _pattern_ (-D)]
- Describe the tasks (matching optional PATTERN), then exit.
-
-[<tt>--dry-run</tt> (-n)]
- Do a dry run. Print the tasks invoked and executed, but do not
- actually execute any of the actions.
-
-[<tt>--execute</tt> _code_ (-e)]
- Execute some Ruby code and exit.
-
-[<tt>--execute-print</tt> _code_ (-p)]
- Execute some Ruby code, print the result, and exit.
-
-[<tt>--execute-continue</tt> _code_ (-E)]
- Execute some Ruby code, then continue with normal task processing.
-
-[<tt>--help</tt> (-H)]
- Display some help text and exit.
-
-[<tt>--jobs</tt> _number_ (-j)]
- Specifies the number of active concurrent tasks used. The
- suggested value is equal to the number of CPUs. The concurrent
- tasks are used to execute the <tt>multitask</tt> prerequisites.
- Also see the <tt>-m</tt> option which turns all tasks into
- multitasks.
-
- Sample values:
- (no -j) : unlimited concurrent tasks (standard rake behavior)
- -j : 2 concurrent tasks (exact number may change)
- -j 16 : 16 concurrent tasks
-
-[<tt>--job-stats</tt> _level_]
-
- Display job statistics at the completion of the run. By default,
- this will display the requested number of active tasks (from the
- -j options) and the maximum number of tasks in play at any given
- time.
-
- If the optional _level_ is <tt>history</tt>, then a complete trace
- of task history will be displayed on standard output.
-
-[<tt>--libdir</tt> _directory_ (-I)]
- Add _directory_ to the list of directories searched for require.
-
-[<tt>--multitask</tt> (-m)]
- Treat all tasks as multitasks. ('make/drake' semantics)
-
-[<tt>--nosearch</tt> (-N)]
- Do not search for a Rakefile in parent directories.
-
-[<tt>--prereqs</tt> (-P)]
- Display a list of all tasks and their immediate prerequisites.
-
-[<tt>--quiet</tt> (-q)]
- Do not echo commands from FileUtils.
-
-[<tt>--rakefile</tt> _filename_ (-f)]
- Use _filename_ as the name of the rakefile. The default rakefile
- names are +rakefile+ and +Rakefile+ (with +rakefile+ taking
- precedence). If the rakefile is not found in the current
- directory, +rake+ will search parent directories for a match. The
- directory where the Rakefile is found will become the current
- directory for the actions executed in the Rakefile.
-
-[<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
- Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
-
-[<tt>--require</tt> _name_ (-r)]
- Require _name_ before executing the Rakefile.
-
-[<tt>--rules</tt>]
- Trace the rules resolution.
-
-[<tt>--silent (-s)</tt>]
- Like --quiet, but also suppresses the 'in directory' announcement.
-
-[<tt>--suppress-backtrace _pattern_ </tt>]
- Line matching the regular expression _pattern_ will be removed
- from the backtrace output. Note that the --backtrace option is the
- full backtrace without these lines suppressed.
-
-[<tt>--system</tt> (-g)]
- Use the system wide (global) rakefiles. The project Rakefile is
- ignored. By default, the system wide rakefiles are used only if no
- project Rakefile is found. On Unix-like system, the system wide
- rake files are located in $HOME/.rake. On a windows system they
- are stored in $APPDATA/Rake.
-
-[<tt>--no-system</tt> (-G)]
- Use the project level Rakefile, ignoring the system-wide (global)
- rakefiles.
-
-[<tt>--tasks</tt> <em>pattern</em> (-T)]
- Display a list of the major tasks and their comments. Comments
- are defined using the "desc" command. If a pattern is given, then
- only tasks matching the pattern are displayed.
-
-[<tt>--trace</tt>{=_output_} (-t)]
- Turn on invoke/execute tracing. Also enable full backtrace on
- errors. The _output_ parameter is optional, but if specified it
- controls where the trace output is sent. If _output_ is
- <tt>stdout</tt>, then trace output is directed to stardard output.
- If _output_ is <tt>stderr</tt>, or if it is missing, then trace
- output is sent to standard error.
-
-[<tt>--verbose</tt> (-v)]
- Echo the Sys commands to standard output.
-
-[<tt>--version</tt> (-V)]
- Display the program version and exit.
-
-[<tt>--where</tt> <em>pattern</em> (-W)]
- Display tasks that match <em>pattern</em> and the file and line
- number where the task is defined. By default this option will
- display all tasks, not just the tasks that have descriptions.
-
-[<tt>--no-deprecation-warnings</tt> (-W)]
- Do not display the deprecation warnings.
-
-In addition, any command line option of the form
-<em>VAR</em>=<em>VALUE</em> will be added to the environment hash
-<tt>ENV</tt> and may be tested in the Rakefile.
View
51 lib/rake/doc/glossary.rdoc
@@ -1,51 +0,0 @@
-= Glossary
-
-[<b>action</b>]
- Code to be executed in order to perform a task. Actions in a
- rakefile are specified in a code block (usually delimited by
- +do+/+end+ pairs.
-
-[<b>execute</b>]
- When a task is executed, all of its actions are performed, in
- the order they were defined. Note that unlike
- <tt>invoke</tt>, <tt>execute</tt> always executes the actions
- (without invoking or executing the prerequisites).
-
-[<b>file task</b> (FileTask)]
- A file task is a task whose purpose is to create a file
- (which has the same name as the task). When invoked, a file
- task will only execute if one or more of the following
- conditions are true.
-
- 1. The associated file does not exist.
- 2. A prerequisite has a later time stamp than the existing file.
-
- Because normal Tasks always have the current time as
- timestamp, a FileTask that has a normal Task prerequisite
- will always execute.
-
-[<b>invoke</b>]
- When a task is invoked, first we check to see if it has been
- invoked before. if it has been, then nothing else is done.
- If this is the first time its been invoked, then we invoke
- each of its prerequisites. Finally, we check to see if we
- need to execute the actions of this task by calling
- <tt>needed?</tt>. Finally, if the task is needed, we execute
- its actions.
-
- NOTE: Currently prerequisites are invoked even if the task is
- not needed. This may change in the future.
-
-[<b>prerequisites</b>]
- Every task has a set (possibly empty) of prerequisites. A
- prerequisite P to Task T is itself a task that must be invoked
- before Task T.
-
-[<b>rule</b>]
- A rule is a recipe for synthesizing a task when no task is
- explicitly defined. Rules generally synthesize file tasks.
-
-[<b>task</b> (Task)]
- Basic unit of work in a rakefile. A task has a name, a set of
- prerequisites and a list of actions to be performed.
-
View
557 lib/rake/doc/rakefile.rdoc
@@ -1,557 +0,0 @@
-= Rakefile Format (as of version 0.8.7)
-
-First of all, there is no special format for a Rakefile. A Rakefile
-contains executable Ruby code. Anything legal in a ruby script is
-allowed in a Rakefile.
-
-Now that we understand there is no special syntax in a Rakefile, there
-are some conventions that are used in a Rakefile that are a little
-unusual in a typical Ruby program. Since a Rakefile is tailored to
-specifying tasks and actions, the idioms used in a Rakefile are
-designed to support that.
-
-So, what goes into a Rakefile?
-
-== Tasks
-
-Tasks are the main unit of work in a Rakefile. Tasks have a name
-(usually given as a symbol or a string), a list of prerequisites (more
-symbols or strings) and a list of actions (given as a block).
-
-=== Simple Tasks
-
-A task is declared by using the +task+ method. +task+ takes a single
-parameter that is the name of the task.
-
- task :name
-
-=== Tasks with Prerequisites
-
-Any prerequisites are given as a list (enclosed in square brackets)
-following the name and an arrow (=>).
-
- task :name => [:prereq1, :prereq2]
-
-<b>NOTE:</b> Although this syntax looks a little funky, it is legal
-Ruby. We are constructing a hash where the key is :name and the value
-for that key is the list of prerequisites. It is equivalent to the
-following ...
-
- hash = Hash.new
- hash[:name] = [:prereq1, :prereq2]
- task(hash)
-
-=== Tasks with Actions
-
-Actions are defined by passing a block to the +task+ method. Any Ruby
-code can be placed in the block. The block may reference the task
-object via the block parameter.
-
- task :name => [:prereq1, :prereq2] do |t|
- # actions (may reference t)
- end
-
-=== Multiple Definitions
-
-A task may be specified more than once. Each specification adds its
-prerequisites and actions to the existing definition. This allows one
-part of a rakefile to specify the actions and a different rakefile
-(perhaps separately generated) to specify the dependencies.
-
-For example, the following is equivalent to the single task
-specification given above.
-
- task :name
- task :name => [:prereq1]
- task :name => [:prereq2]
- task :name do |t|
- # actions
- end
-
-== File Tasks
-
-Some tasks are designed to create a file from one or more other files.
-Tasks that generate these files may be skipped if the file already
-exists. File tasks are used to specify file creation tasks.
-
-File tasks are declared using the +file+ method (instead of the +task+
-method). In addition, file tasks are usually named with a string
-rather than a symbol.
-
-The following file task creates a executable program (named +prog+)
-given two object files name <tt>a.o</tt> and <tt>b.o</tt>. The tasks
-for creating <tt>a.o</tt> and <tt>b.o</tt> are not shown.
-
- file "prog" => ["a.o", "b.o"] do |t|
- sh "cc -o #{t.name} #{t.prerequisites.join(' ')}"
- end
-
-== Directory Tasks
-
-It is common to need to create directories upon demand. The
-+directory+ convenience method is a short-hand for creating a FileTask
-that creates the directory. For example, the following declaration
-...
-
- directory "testdata/examples/doc"
-
-is equivalent to ...
-
- file "testdata" do |t| mkdir t.name end
- file "testdata/examples" do |t| mkdir t.name end
- file "testdata/examples/doc" do |t| mkdir t.name end
-
-The +directory+ method does not accept prerequisites or actions, but
-both prerequisites and actions can be added later. For example ...
-
- directory "testdata"
- file "testdata" => ["otherdata"]
- file "testdata" do
- cp Dir["standard_data/*.data"], "testdata"
- end
-
-== Tasks with Parallel Prerequisites
-
-Rake allows parallel execution of prerequisites using the following syntax:
-
- multitask :copy_files => [:copy_src, :copy_doc, :copy_bin] do
- puts "All Copies Complete"
- end
-
-In this example, +copy_files+ is a normal rake task. Its actions are
-executed whenever all of its prerequisites are done. The big
-difference is that the prerequisites (+copy_src+, +copy_bin+ and
-+copy_doc+) are executed in parallel. Each of the prerequisites are
-run in their own Ruby thread, possibly allowing faster overall runtime.
-
-=== Secondary Prerequisites
-
-If any of the primary prerequisites of a multitask have common secondary
-prerequisites, all of the primary/parallel prerequisites will wait
-until the common prerequisites have been run.
-
-For example, if the <tt>copy_<em>xxx</em></tt> tasks have the
-following prerequisites:
-
- task :copy_src => [:prep_for_copy]
- task :copy_bin => [:prep_for_copy]
- task :copy_doc => [:prep_for_copy]
-
-Then the +prep_for_copy+ task is run before starting all the copies in
-parallel. Once +prep_for_copy+ is complete, +copy_src+, +copy_bin+,
-and +copy_doc+ are all run in parallel. Note that +prep_for_copy+ is
-run only once, even though it is referenced in multiple threads.
-
-=== Thread Safety
-
-The Rake internal data structures are thread-safe with respect
-to the multitask parallel execution, so there is no need for the user
-to do extra synchronization for Rake's benefit. However, if there are
-user data structures shared between the parallel prerequisites, the
-user must do whatever is necessary to prevent race conditions.
-
-== Tasks with Arguments
-
-Prior to version 0.8.0, rake was only able to handle command line
-arguments of the form NAME=VALUE that were passed into Rake via the
-ENV hash. Many folks had asked for some kind of simple command line
-arguments, perhaps using "--" to separate regular task names from
-argument values on the command line. The problem is that there was no
-easy way to associate positional arguments on the command line with
-different tasks. Suppose both tasks :a and :b expect a command line
-argument: does the first value go with :a? What if :b is run first?
-Should it then get the first command line argument.
-
-Rake 0.8.0 solves this problem by explicitly passing values directly
-to the tasks that need them. For example, if I had a release task
-that required a version number, I could say:
-
- rake release[0.8.2]
-
-And the string "0.8.2" will be passed to the :release task. Multiple
-arguments can be passed by separating them with a comma, for example:
-
- rake name[john,doe]
-
-Just a few words of caution. The rake task name and its arguments
-need to be a single command line argument to rake. This generally
-means no spaces. If spaces are needed, then the entire rake +
-argument string should be quoted. Something like this:
-
- rake "name[billy bob, smith]"
-
-(Quoting rules vary between operating systems and shells, so make sure
-you consult the proper docs for your OS/shell).
-
-=== Tasks Arguments and the Environment
-
-Task argument values can also be picked up from the environment. For
-example, if the "release" task expected a parameter named
-"release_version", then either
-
- rake release[0.8.2]
-
-or
-
- RELEASE_VERSION=0.8.2 rake release
-
-will work. Environment variable names must either match the task
-parameter exactly, or match an all-uppercase version of the task
-parameter.
-
-=== Tasks that Expect Parameters
-
-Parameters are only given to tasks that are setup to expect them. In
-order to handle named parameters, the task declaration syntax for
-tasks has been extended slightly.
-
-For example, a task that needs a first name and last name might be
-declared as:
-
- task :name, [:first_name, :last_name]
-
-The first argument is still the name of the task (:name in this case).
-The next two arguments are the names of the parameters expected by
-:name in an array (:first_name and :last_name in the example).
-
-To access the values of the parameters, the block defining the task
-behaviour can now accept a second parameter:
-
- task :name, [:first_name, :last_name] do |t, args|
- puts "First name is #{args.first_name}"
- puts "Last name is #{args.last_name}"
- end
-
-The first argument of the block "t" is always bound to the current
-task object. The second argument "args" is an open-struct like object
-that allows access to the task arguments. Extra command line
-arguments to a task are ignored. Missing command line arguments are
-picked up from matching environment variables. If there are no
-matching environment variables, they are given the nil value.
-
-If you wish to specify default values for the arguments, you can use
-the with_defaults method in the task body. Here is the above example
-where we specify default values for the first and last names:
-
- task :name, [:first_name, :last_name] do |t, args|
- args.with_defaults(:first_name => "John", :last_name => "Dough")
- puts "First name is #{args.first_name}"
- puts "Last name is #{args.last_name}"
- end
-
-=== Tasks that Expect Parameters and Have Prerequisites
-
-Tasks that use parameters have a slightly different format for
-prerequisites. Use the arrow notation to indicate the prerequisites
-for tasks with arguments. For example:
-
- task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
- args.with_defaults(:first_name => "John", :last_name => "Dough")
- puts "First name is #{args.first_name}"
- puts "Last name is #{args.last_name}"
- end
-
-=== Deprecated Task Parameters Format
-
-There is an older format for declaring task parameters that omitted
-the task argument array and used the :needs keyword to introduce the
-dependencies. That format is still supported for compatibility, but
-is not recommended for use. The older format may be dropped in future
-versions of rake.
-
-== Accessing Task Programmatically
-
-Sometimes it is useful to manipulate tasks programmatically in a
-Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
-<tt>Rake::Task</tt>.
-
-=== Programmatic Task Example
-
-For example, the following Rakefile defines two tasks. The :doit task
-simply prints a simple "DONE" message. The :dont class will lookup
-the doit class and remove (clear) all of its prerequisites and
-actions.
-
- task :doit do
- puts "DONE"
- end
-
- task :dont do
- Rake::Task[:doit].clear
- end
-
-Running this example:
-
- $ rake doit
- (in /Users/jim/working/git/rake/x)
- DONE
- $ rake dont doit
- (in /Users/jim/working/git/rake/x)
- $
-
-The ability to programmatically manipulate tasks gives rake very
-powerful meta-programming capabilities w.r.t. task execution, but
-should be used with caution.
-
-== Rules
-
-When a file is named as a prerequisite, but does not have a file task
-defined for it, Rake will attempt to synthesize a task by looking at a
-list of rules supplied in the Rakefile.
-
-Suppose we were trying to invoke task "mycode.o", but no task is
-defined for it. But the rakefile has a rule that look like this ...
-
- rule '.o' => ['.c'] do |t|
- sh "cc #{t.source} -c -o #{t.name}"
- end
-
-This rule will synthesize any task that ends in ".o". It has a
-prerequisite a source file with an extension of ".c" must exist. If
-Rake is able to find a file named "mycode.c", it will automatically
-create a task that builds "mycode.o" from "mycode.c".
-
-If the file "mycode.c" does not exist, rake will attempt
-to recursively synthesize a rule for it.
-
-When a task is synthesized from a rule, the +source+ attribute of the
-task is set to the matching source file. This allows us to write
-rules with actions that reference the source file.
-
-=== Advanced Rules
-
-Any regular expression may be used as the rule pattern. Additionally,
-a proc may be used to calculate the name of the source file. This
-allows for complex patterns and sources.
-
-The following rule is equivalent to the example above.
-
- rule( /\.o$/ => [
- proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') }
- ]) do |t|
- sh "cc #{t.source} -c -o #{t.name}"
- end
-
-<b>NOTE:</b> Because of a _quirk_ in Ruby syntax, parenthesis are
-required on *rule* when the first argument is a regular expression.
-
-The following rule might be used for Java files ...
-
- rule '.class' => [
- proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') }
- ] do |t|
- java_compile(t.source, t.name)
- end
-
-<b>NOTE:</b> +java_compile+ is a hypothetical method that invokes the
-java compiler.
-
-== Importing Dependencies
-
-Any ruby file (including other rakefiles) can be included with a
-standard Ruby +require+ command. The rules and declarations in the
-required file are just added to the definitions already accumulated.
-
-Because the files are loaded _before_ the rake targets are evaluated,
-the loaded files must be "ready to go" when the rake command is
-invoked. This make generated dependency files difficult to use. By
-the time rake gets around to updating the dependencies file, it is too
-late to load it.
-
-The +Rake.import+ command addresses this by specifying a file to be
-loaded _after_ the main rakefile is loaded, but _before_ any targets
-on the command line are invoked. In addition, if the file name
-matches an explicit task, that task is invoked before loading the
-file. This allows dependency files to be generated and used in a
-single rake command invocation.
-
-<b>NOTE:</b> Starting in Rake version 0.9.0, the top level +import+
-command is deprecated and we recommend using the scoped
-"+Rake.import+" command mentioned above. Future versions of Rake will
-drop support for the top level +import+ command.
-
-=== Example:
-
- require 'rake/loaders/makefile'
-
- file ".depends.mf" => [SRC_LIST] do |t|
- sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
- end
-
- Rake.import ".depends.mf"
-
-If ".depends" does not exist, or is out of date w.r.t. the source
-files, a new ".depends" file is generated using +makedepend+ before
-loading.
-
-== Comments
-
-Standard Ruby comments (beginning with "#") can be used anywhere it is
-legal in Ruby source code, including comments for tasks and rules.
-However, if you wish a task to be described using the "-T" switch,
-then you need to use the +desc+ command to describe the task.
-
-=== Example:
-
- desc "Create a distribution package"
- task :package => [ ... ] do ... end
-
-The "-T" switch (or "--tasks" if you like to spell things out) will
-display a list of tasks that have a description. If you use +desc+ to
-describe your major tasks, you have a semi-automatic way of generating
-a summary of your Rake file.
-
- traken$ rake -T
- (in /home/.../rake)
- rake clean # Remove any temporary products.
- rake clobber # Remove any generated file.
- rake clobber_rdoc # Remove rdoc products
- rake contrib_test # Run tests for contrib_test
- rake default # Default Task
- rake install # Install the application
- rake lines # Count lines in the main rake file
- rake rdoc # Build the rdoc HTML Files
- rake rerdoc # Force a rebuild of the RDOC files
- rake test # Run tests
- rake testall # Run all test targets
-
-Only tasks with descriptions will be displayed with the "-T" switch.
-Use "-P" (or "--prereqs") to get a list of all tasks and their
-prerequisites.
-
-== Namespaces
-
-As projects grow (and along with it, the number of tasks), it is
-common for task names to begin to clash. For example, if you might
-have a main program and a set of sample programs built by a single
-Rakefile. By placing the tasks related to the main program in one
-namespace, and the tasks for building the sample programs in a
-different namespace, the task names will not will not interfere with
-each other.
-
-For example:
-
- namespace "main" do
- task :build do
- # Build the main program
- end
- end
-
- namespace "samples" do
- task :build do
- # Build the sample programs
- end
- end
-
- task :build => ["main:build", "samples:build"]
-
-Referencing a task in a separate namespace can be achieved by
-prefixing the task name with the namespace and a colon
-(e.g. "main:build" refers to the :build task in the +main+ namespace).
-Nested namespaces are supported, so
-
-Note that the name given in the +task+ command is always the unadorned
-task name without any namespace prefixes. The +task+ command always
-defines a task in the current namespace.
-
-=== FileTasks
-
-File task names are not scoped by the namespace command. Since the
-name of a file task is the name of an actual file in the file system,
-it makes little sense to include file task names in name space.
-Directory tasks (created by the +directory+ command) are a type of
-file task and are also not affected by namespaces.
-
-=== Name Resolution
-
-When looking up a task name, rake will start with the current
-namespace and attempt to find the name there. If it fails to find a
-name in the current namespace, it will search the parent namespaces
-until a match is found (or an error occurs if there is no match).
-
-The "rake" namespace is a special implicit namespace that refers to
-the toplevel names.
-
-If a task name begins with a "^" character, the name resolution will
-start in the parent namespace. Multiple "^" characters are allowed.
-
-Here is an example file with multiple :run tasks and how various names
-resolve in different locations.
-
- task :run
-
- namespace "one" do
- task :run
-
- namespace "two" do
- task :run
-
- # :run => "one:two:run"
- # "two:run" => "one:two:run"
- # "one:two:run" => "one:two:run"
- # "one:run" => "one:run"
- # "^run" => "one:run"
- # "^^run" => "rake:run" (the top level task)
- # "rake:run" => "rake:run" (the top level task)
- end
-
- # :run => "one:run"
- # "two:run" => "one:two:run"
- # "^run" => "rake:run"
- end
-
- # :run => "rake:run"
- # "one:run" => "one:run"
- # "one:two:run" => "one:two:run"
-
-== FileLists
-
-FileLists are the way Rake manages lists of files. You can treat a
-FileList as an array of strings for the most part, but FileLists
-support some additional operations.
-
-=== Creating a FileList
-
-Creating a file list is easy. Just give it the list of file names:
-
- fl = FileList['file1.rb', file2.rb']
-
-Or give it a glob pattern:
-
- fl = FileList['*.rb']
-
-== Odds and Ends
-
-=== do/end versus { }
-
-Blocks may be specified with either a +do+/+end+ pair, or with curly
-braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the
-actions for tasks and rules. Because the rakefile idiom tends to
-leave off parentheses on the task/file/rule methods, unusual
-ambiguities can arise when using curly braces.
-
-For example, suppose that the method +object_files+ returns a list of
-object files in a project. Now we use +object_files+ as the
-prerequisites in a rule specified with actions in curly braces.
-
- # DON'T DO THIS!
- file "prog" => object_files {
- # Actions are expected here (but it doesn't work)!
- }
-
-Because curly braces have a higher precedence than +do+/+end+, the
-block is associated with the +object_files+ method rather than the
-+file+ method.
-
-This is the proper way to specify the task ...
-
- # THIS IS FINE
- file "prog" => object_files do
- # Actions go here
- end
-
-----
-
-== See
-
-* README.rdoc -- Main documentation for Rake.
View
151 lib/rake/doc/rational.rdoc
@@ -1,151 +0,0 @@
-= Why rake?
-
-Ok, let me state from the beginning that I never intended to write this
-code. I'm not convinced it is useful, and I'm not convinced anyone
-would even be interested in it. All I can say is that Why's onion truck
-must by been passing through the Ohio valley.
-
-What am I talking about? ... A Ruby version of Make.
-
-See, I can sense you cringing already, and I agree. The world certainly
-doesn't need yet another reworking of the "make" program. I mean, we
-already have "ant". Isn't that enough?
-
-It started yesterday. I was helping a coworker fix a problem in one of
-the Makefiles we use in our project. Not a particularly tough problem,
-but during the course of the conversation I began lamenting some of the
-shortcomings of make. In particular, in one of my makefiles I wanted to
-determine the name of a file dynamically and had to resort to some
-simple scripting (in Ruby) to make it work. "Wouldn't it be nice if you
-could just use Ruby inside a Makefile" I said.
-
-My coworker (a recent convert to Ruby) agreed, but wondered what it
-would look like. So I sketched the following on the whiteboard...
-
- "What if you could specify the make tasks in Ruby, like this ..."
-
- task "build" do
- java_compile(...args, etc ...)
- end
-
- "The task function would register "build" as a target to be made,
- and the block would be the action executed whenever the build
- system determined that it was time to do the build target."
-
-We agreed that would be cool, but writing make from scratch would be WAY
-too much work. And that was the end of that!
-
-... Except I couldn't get the thought out of my head. What exactly
-would be needed to make the about syntax work as a make file? Hmmm, you
-would need to register the tasks, you need some way of specifying
-dependencies between tasks, and some way of kicking off the process.
-Hey! What if we did ... and fifteen minutes later I had a working
-prototype of Ruby make, complete with dependencies and actions.
-
-I showed the code to my coworker and we had a good laugh. It was just
-about a page worth of code that reproduced an amazing amount of the
-functionality of make. We were both truly stunned with the power of
-Ruby.
-
-But it didn't do everything make did. In particular, it didn't have
-timestamp based file dependencies (where a file is rebuilt if any of its
-prerequisite files have a later timestamp). Obviously THAT would be a
-pain to add and so Ruby Make would remain an interesting experiment.
-
-... Except as I walked back to my desk, I started thinking about what
-file based dependencies would really need. Rats! I was hooked again,
-and by adding a new class and two new methods, file/timestamp
-dependencies were implemented.
-
-Ok, now I was really hooked. Last night (during CSI!) I massaged the
-code and cleaned it up a bit. The result is a bare-bones replacement
-for make in exactly 100 lines of code.
-
-For the curious, you can see it at ...
-* doc/proto_rake.rdoc
-
-Oh, about the name. When I wrote the example Ruby Make task on my
-whiteboard, my coworker exclaimed "Oh! I have the perfect name: Rake ...
-Get it? Ruby-Make. Rake!" He said he envisioned the tasks as leaves
-and Rake would clean them up ... or something like that. Anyways, the
-name stuck.
-
-Some quick examples ...
-
-A simple task to delete backup files ...
-
- task :clean do
- Dir['*~'].each {|fn| rm fn rescue nil}
- end
-
-Note that task names are symbols (they are slightly easier to type
-than quoted strings ... but you may use quoted string if you would
-rather). Rake makes the methods of the FileUtils module directly
-available, so we take advantage of the <tt>rm</tt> command. Also note
-the use of "rescue nil" to trap and ignore errors in the <tt>rm</tt>
-command.
-
-To run it, just type "rake clean". Rake will automatically find a
-Rakefile in the current directory (or above!) and will invoke the
-targets named on the command line. If there are no targets explicitly
-named, rake will invoke the task "default".
-
-Here's another task with dependencies ...
-
- task :clobber => [:clean] do
- rm_r "tempdir"
- end
-
-Task :clobber depends upon task :clean, so :clean will be run before
-:clobber is executed.
-
-Files are specified by using the "file" command. It is similar to the
-task command, except that the task name represents a file, and the task
-will be run only if the file doesn't exist, or if its modification time
-is earlier than any of its prerequisites.
-
-Here is a file based dependency that will compile "hello.cc" to
-"hello.o".
-
- file "hello.cc"
- file "hello.o" => ["hello.cc"] do |t|
- srcfile = t.name.sub(/\.o$/, ".cc")
- sh %{g++ #{srcfile} -c -o #{t.name}}
- end
-
-I normally specify file tasks with string (rather than symbols). Some
-file names can't be represented by symbols. Plus it makes the
-distinction between them more clear to the casual reader.
-
-Currently writing a task for each and every file in the project would be
-tedious at best. I envision a set of libraries to make this job
-easier. For instance, perhaps something like this ...
-
- require 'rake/ctools'
- Dir['*.c'].each do |fn|
- c_source_file(fn)
- end
-
-where "c_source_file" will create all the tasks need to compile all the
-C source files in a directory. Any number of useful libraries could be
-created for rake.
-
-That's it. There's no documentation (other than whats in this
-message). Does this sound interesting to anyone? If so, I'll continue
-to clean it up and write it up and publish it on RAA. Otherwise, I'll
-leave it as an interesting exercise and a tribute to the power of Ruby.
-
-Why /might/ rake be interesting to Ruby programmers. I don't know,
-perhaps ...
-
-* No weird make syntax (only weird Ruby syntax :-)
-* No need to edit or read XML (a la ant)
-* Platform independent build scripts.
-* Will run anywhere Ruby exists, so no need to have "make" installed.
- If you stay away from the "sys" command and use things like
- 'ftools', you can have a perfectly platform independent
- build script. Also rake is only 100 lines of code, so it can
- easily be packaged along with the rest of your code.
-
-So ... Sorry for the long rambling message. Like I said, I never
-intended to write this code at all.
View
29 lib/rake/dsl_definition.rb
@@ -32,7 +32,6 @@ def task(*args, &block)
Rake::Task.define_task(*args, &block)
end
-
# Declare a file task.
#
# Example:
@@ -67,7 +66,7 @@ def directory(*args, &block)
dir, _ = *Rake.application.resolve_args(args)
Rake.each_dir_parent(dir) do |d|
file_create d do |t|
- mkdir_p t.name if ! File.exist?(t.name)
+ mkdir_p t.name unless File.exist?(t.name)
end
end
result
@@ -117,6 +116,7 @@ def rule(*args, &block)
end
# Describe the next rake task.
+ # Duplicate descriptions are discarded.
#
# Example:
# desc "Run the Unit Tests"
@@ -147,31 +147,7 @@ def import(*fns)
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 unless defined? Rake::REDUCE_COMPAT
-
extend FileUtilsExt
end
@@ -179,4 +155,3 @@ def #{name}(*args, &block)
# calls to task, etc. to work from a Rakefile without polluting the
# object inheritance tree.
self.extend Rake::DSL
-include Rake::DeprecatedObjectDSL unless defined? Rake::REDUCE_COMPAT
View
3  lib/rake/ext/core.rb
@@ -19,7 +19,8 @@ class Module
#
def rake_extension(method)
if method_defined?(method)
- $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
+ $stderr.puts "WARNING: Possible conflict with Rake extension: " +
+ "#{self}##{method} already exists"
else
yield
end
View
39 lib/rake/ext/module.rb
@@ -1,39 +0,0 @@
-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 unless defined? Rake::REDUCE_COMPAT
View
4 lib/rake/ext/string.rb
@@ -13,9 +13,7 @@ class String
# +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
+ newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != ''
self.chomp(File.extname(self)) << newext
end
end
View
42 lib/rake/file_list.rb
@@ -41,10 +41,11 @@ class FileList
# 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 }
+ 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 <=>]
+ MUST_DEFINE = %w[inspect <=>]
# List of methods that should not be delegated here (we define special
# versions of them explicitly below).
@@ -58,12 +59,13 @@ class FileList
+ - & |
]
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
+ map { |s| s.to_s }.sort.uniq
# Now do the delegation.
- DELEGATING_METHODS.each_with_index do |sym, i|
+ DELEGATING_METHODS.each do |sym|
if SPECIAL_RETURN.include?(sym)
- ln = __LINE__+1
+ ln = __LINE__ + 1
class_eval %{
def #{sym}(*args, &block)
resolve
@@ -72,7 +74,7 @@ def #{sym}(*args, &block)
end
}, __FILE__, ln
else
- ln = __LINE__+1
+ ln = __LINE__ + 1
class_eval %{
def #{sym}(*args, &block)
resolve
@@ -149,10 +151,8 @@ def exclude(*patterns, &bloc