Class: Rake::Application
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
TaskManager
|
|
Inherits: | Object |
Defined in: | lib/rake/application.rb |
Overview
::Rake main application object. When invoking rake
from the command line, a Application
object is created and run.
Constant Summary
-
DEFAULT_RAKEFILES =
# File 'lib/rake/application.rb', line 38[ 'rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb' ].freeze
Class Method Summary
-
.new ⇒ Application
constructor
Initialize a
Application
object.
Instance Attribute Summary
-
#terminal_columns
rw
Number of columns on the terminal.
-
#name
readonly
The name of the application (typically 'rake').
-
#original_dir
readonly
The original directory where rake was invoked.
-
#rakefile
readonly
Name of the actual rakefile used.
-
#top_level_tasks
readonly
List of the top level task names (task names from the command line).
TaskManager - Included
#last_description | Track the last comment made in the Rakefile. |
#last_comment | Alias for TaskManager#last_description. |
Instance Method Summary
-
#add_loader(ext, loader)
Add a loader to handle imported files ending in the extension
ext
. -
#init(app_name = 'rake')
Initialize the command line parameters and app name.
-
#load_rakefile
Find the rakefile and then load it and any pending imports.
-
#options
Application
options from the command line. -
#run
Run the ::Rake application.
-
#run_with_threads
Run the given block with the thread startup and shutdown.
-
#top_level
Run the top level tasks of a ::Rake application.
TaskManager - Included
#[] | Find a matching task for |
#clear | Clear all tasks in this application. |
#current_scope | Return the list of scope names currently active in the task manager. |
#enhance_with_matching_rule | If a rule can be found that matches the task name, enhance the task with the prerequisites and actions from the rule. |
#in_namespace | Evaluate the block in a nested namespace named #name. |
#intern | Lookup a task. |
#lookup | Lookup a task, using scope and the scope hints in the task name. |
#resolve_args | Resolve the arguments for a task/rule. |
#tasks | List of all defined tasks in this application. |
#tasks_in_scope | List of all the tasks defined in the given scope (and its sub-scopes). |
#add_location | Add a location to the locations field of the given task. |
#attempt_rule | Attempt to create a rule given the list of prerequisites. |
#find_location | Find the location that called into the dsl layer. |
#generate_name | Generate an anonymous namespace name. |
#get_description | Return the current description, clearing it in the process. |
#lookup_in_scope | Lookup the task name. |
#make_sources | Make a list of sources from the list of file name extensions / translation procs. |
#resolve_args_without_dependencies | Resolve task arguments for a task or rule when there are no dependencies declared. |
Constructor Details
.new ⇒ Application
Initialize a Application
object.
# File 'lib/rake/application.rb', line 46
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
Instance Attribute Details
#name (readonly)
The name of the application (typically 'rake')
# File 'lib/rake/application.rb', line 24
attr_reader :name
#original_dir (readonly)
The original directory where rake was invoked.
# File 'lib/rake/application.rb', line 27
attr_reader :original_dir
#rakefile (readonly)
Name of the actual rakefile used.
# File 'lib/rake/application.rb', line 30
attr_reader :rakefile
#terminal_columns (rw)
Number of columns on the terminal
# File 'lib/rake/application.rb', line 33
attr_accessor :terminal_columns
#top_level_tasks (readonly)
List of the top level task names (task names from the command line).
# File 'lib/rake/application.rb', line 36
attr_reader :top_level_tasks
Instance Method Details
#add_loader(ext, loader)
Add a loader to handle imported files ending in the extension ext
.
# File 'lib/rake/application.rb', line 129
def add_loader(ext, loader) ext = ".#{ext}" unless ext =~ /^\./ @loaders[ext] = loader end
#init(app_name = 'rake')
Initialize the command line parameters and app name.
# File 'lib/rake/application.rb', line 83
def init(app_name='rake') standard_exception_handling do @name = app_name args = collect_command_line_tasks(args) end end
#load_rakefile
Find the rakefile and then load it and any pending imports.
# File 'lib/rake/application.rb', line 92
def load_rakefile standard_exception_handling do raw_load_rakefile end end
#options
Application
options from the command line
# File 'lib/rake/application.rb', line 135
def @options ||= OpenStruct.new end
#run
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 (#top_level).
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.
# File 'lib/rake/application.rb', line 74
def run standard_exception_handling do init load_rakefile top_level end end
#run_with_threads
Run the given block with the thread startup and shutdown.
# File 'lib/rake/application.rb', line 112
def run_with_threads thread_pool.gather_history if .job_stats == :history yield thread_pool.join if .job_stats stats = thread_pool.statistics puts "Maximum active threads: #{stats[:max_active_threads]} + main" puts "Total threads in play: #{stats[:total_threads_in_play]} + main" end ThreadHistoryDisplay.new(thread_pool.history).show if .job_stats == :history end
#top_level
Run the top level tasks of a ::Rake application.
# File 'lib/rake/application.rb', line 99
def top_level run_with_threads do if .show_tasks display_tasks_and_comments elsif .show_prereqs display_prerequisites else top_level_tasks.each { |task_name| invoke_task(task_name) } end end end