Module: Rake

Extended by:
FileUtilsExt
Defined in:
lib/rake.rb,
lib/rake/task.rb,
lib/rake/clean.rb,
lib/rake/scope.rb,
lib/rake/win32.rb,
lib/rake/promise.rb,
lib/rake/tasklib.rb,
lib/rake/version.rb,
lib/rake/testtask.rb,
lib/rake/backtrace.rb,
lib/rake/cloneable.rb,
lib/rake/file_list.rb,
lib/rake/file_list.rb,
lib/rake/file_task.rb,
lib/rake/late_time.rb,
lib/rake/early_time.rb,
lib/rake/multi_task.rb,
lib/rake/application.rb,
lib/rake/cpu_counter.rb,
lib/rake/linked_list.rb,
lib/rake/packagetask.rb,
lib/rake/rake_module.rb,
lib/rake/thread_pool.rb,
lib/rake/task_manager.rb,
lib/rake/trace_output.rb,
lib/rake/pseudo_status.rb,
lib/rake/default_loader.rb,
lib/rake/dsl_definition.rb,
lib/rake/file_utils_ext.rb,
lib/rake/private_reader.rb,
lib/rake/task_arguments.rb,
lib/rake/invocation_chain.rb,
lib/rake/loaders/makefile.rb,
lib/rake/file_creation_task.rb,
lib/rake/task_argument_error.rb,
lib/rake/thread_history_display.rb,
lib/rake/invocation_exception_mixin.rb,
lib/rake/rule_recursion_overflow_error.rb

Overview

:stopdoc:

Defined Under Namespace

Modules: Backtrace, Cleaner, Cloneable, DSL, FileUtilsExt, InvocationExceptionMixin, PrivateReader, TaskManager, TraceOutput, Version, Win32 Classes: Application, CpuCounter, DefaultLoader, EarlyTime, FileCreationTask, FileList, FileTask, InvocationChain, LateTime, LinkedList, MakefileLoader, MultiTask, NameSpace, PackageTask, Promise, PseudoStatus, RuleRecursionOverflowError, Scope, Task, TaskArgumentError, TaskArguments, TaskLib, TestTask, ThreadHistoryDisplay, ThreadPool

Constant Summary collapse

VERSION =
"13.0.1"
LATE =
LateTime.instance
EARLY =
EarlyTime.instance
CommandLineOptionError =
Class.new(StandardError)
EMPTY_TASK_ARGS =

:nodoc:

TaskArguments.new([], [])

Constants included from FileUtilsExt

FileUtilsExt::DEFAULT

Constants included from FileUtils

FileUtils::LN_SUPPORTED, FileUtils::RUBY

Class Method Summary collapse

Methods included from FileUtilsExt

nowrite, rake_check_options, rake_output_message, verbose, when_writing

Methods included from FileUtils

#ruby, #safe_ln, #sh, #split_all

Class Method Details

.add_rakelib(*files) ⇒ Object

Add files to the rakelib list


33
34
35
36
# File 'lib/rake/rake_module.rb', line 33

def add_rakelib(*files)
  application.options.rakelib ||= []
  application.options.rakelib.concat(files)
end

.applicationObject

Current Rake Application


8
9
10
# File 'lib/rake/rake_module.rb', line 8

def application
  @application ||= Rake::Application.new
end

.application=(app) ⇒ Object

Set the current Rake application object.


13
14
15
# File 'lib/rake/rake_module.rb', line 13

def application=(app)
  @application = app
end

.each_dir_parent(dir) ⇒ Object

Yield each file or directory component.


418
419
420
421
422
423
424
425
# File 'lib/rake/file_list.rb', line 418

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

.from_pathname(path) ⇒ Object

Convert Pathname and Pathname-like objects to strings; leave everything else alone


429
430
431
432
433
# File 'lib/rake/file_list.rb', line 429

def from_pathname(path)    # :nodoc:
  path = path.to_path if path.respond_to?(:to_path)
  path = path.to_str if path.respond_to?(:to_str)
  path
end

.load_rakefile(path) ⇒ Object

Load a rakefile.


28
29
30
# File 'lib/rake/rake_module.rb', line 28

def load_rakefile(path)
  load(path)
end

.original_dirObject

Return the original directory where the Rake application was started.


23
24
25
# File 'lib/rake/rake_module.rb', line 23

def original_dir
  application.original_dir
end

.suggested_thread_countObject

:nodoc:


17
18
19
20
# File 'lib/rake/rake_module.rb', line 17

def suggested_thread_count # :nodoc:
  @cpu_count ||= Rake::CpuCounter.count
  @cpu_count + 4
end

.with_application(block_application = Rake::Application.new) ⇒ Object

Make block_application the default rake application inside a block so you can load rakefiles into a different application.

This is useful when you want to run rake tasks inside a library without running rake in a sub-shell.

Example:

Dir.chdir 'other/directory'

other_rake = Rake.with_application do |rake|
  rake.load_rakefile
end

puts other_rake.tasks

54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rake/rake_module.rb', line 54

def with_application(block_application = Rake::Application.new)
  orig_application = Rake.application

  Rake.application = block_application

  yield block_application

  block_application
ensure
  Rake.application = orig_application
end