Class: Rake::Application
- Inherits:
-
Object
- Object
- Rake::Application
- Includes:
- TaskManager, TraceOutput
- Defined in:
- lib/rake/application.rb
Overview
Rake main application object. When invoking rake
from the command line, a Rake::Application object is created and run.
Constant Summary collapse
- DEFAULT_RAKEFILES =
[ 'rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb' ].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the application (typically ‘rake’).
-
#original_dir ⇒ Object
readonly
The original directory where rake was invoked.
-
#rakefile ⇒ Object
readonly
Name of the actual rakefile used.
-
#terminal_columns ⇒ Object
Number of columns on the terminal.
-
#top_level_tasks ⇒ Object
readonly
List of the top level task names (task names from the command line).
Attributes included from TaskManager
Instance Method Summary collapse
-
#add_import(fn) ⇒ Object
Add a file to the list of files to be imported.
-
#add_loader(ext, loader) ⇒ Object
Add a loader to handle imported files ending in the extension
ext
. -
#collect_command_line_tasks ⇒ Object
Collect the list of tasks on the command line.
-
#default_task_name ⇒ Object
Default task name (“default”).
-
#deprecate(old_usage, new_usage, call_site) ⇒ Object
Warn about deprecated usage.
-
#display_error_message(ex) ⇒ Object
Display the error message that caused the exception.
-
#display_exception_backtrace(ex) ⇒ Object
:nodoc:.
-
#display_exception_details(ex) ⇒ Object
:nodoc:.
-
#display_exception_message_details(ex) ⇒ Object
:nodoc:.
-
#display_prerequisites ⇒ Object
Display the tasks and prerequisites.
-
#display_tasks_and_comments ⇒ Object
Display the tasks and comments.
-
#dynamic_width ⇒ Object
Calculate the dynamic width of the.
-
#dynamic_width_stty ⇒ Object
:nodoc:.
-
#dynamic_width_tput ⇒ Object
:nodoc:.
-
#exit_because_of_exception(ex) ⇒ Object
Exit the program because of an unhandle exception.
-
#find_rakefile_location ⇒ Object
:nodoc:.
-
#handle_options ⇒ Object
Read and handle the command line options.
-
#has_cause?(ex) ⇒ Boolean
:nodoc:.
-
#have_rakefile ⇒ Object
True if one of the files in RAKEFILES is in the current directory.
-
#init(app_name = 'rake') ⇒ Object
Initialize the command line parameters and app name.
-
#initialize ⇒ Application
constructor
Initialize a Rake::Application object.
-
#invoke_task(task_string) ⇒ Object
Invokes a task with arguments that are extracted from
task_string
. -
#load_imports ⇒ Object
Load the pending list of imported files.
-
#load_rakefile ⇒ Object
Find the rakefile and then load it and any pending imports.
-
#options ⇒ Object
Application options from the command line.
-
#parse_task_string(string) ⇒ Object
:nodoc:.
-
#print_rakefile_directory(location) ⇒ Object
:nodoc:.
-
#rake_require(file_name, paths = $LOAD_PATH, loaded = $") ⇒ Object
Similar to the regular Ruby
require
command, but will check for *.rake files in addition to *.rb files. -
#rakefile_location(backtrace = caller) ⇒ Object
:nodoc:.
-
#raw_load_rakefile ⇒ Object
:nodoc:.
-
#run ⇒ Object
Run the Rake application.
-
#run_with_threads ⇒ Object
Run the given block with the thread startup and shutdown.
-
#standard_exception_handling ⇒ Object
Provide standard exception handling for the given block.
-
#standard_rake_options ⇒ Object
A list of all the standard options used in rake, suitable for passing to OptionParser.
-
#system_dir ⇒ Object
The directory path containing the system wide rakefiles.
-
#terminal_width ⇒ Object
:nodoc:.
-
#thread_pool ⇒ Object
Return the thread pool used for multithreaded processing.
-
#top_level ⇒ Object
Run the top level tasks of a Rake application.
-
#trace(*strings) ⇒ Object
:nodoc:.
-
#truncate(string, width) ⇒ Object
:nodoc:.
-
#truncate_output? ⇒ Boolean
We will truncate output if we are outputting to a TTY or if we’ve been given an explicit column width to honor.
-
#tty_output=(tty_output_state) ⇒ Object
Override the detected TTY output state (mostly for testing).
-
#tty_output? ⇒ Boolean
True if we are outputting to TTY, false otherwise.
-
#unix? ⇒ Boolean
:nodoc:.
-
#windows? ⇒ Boolean
:nodoc:.
Methods included from TraceOutput
Methods included from TaskManager
#[], #clear, #create_rule, #current_scope, #define_task, #enhance_with_matching_rule, #in_namespace, #intern, #lookup, #resolve_args, #synthesize_file_task, #tasks, #tasks_in_scope
Constructor Details
#initialize ⇒ Application
Initialize a Rake::Application object.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 ⇒ Object (readonly)
The name of the application (typically ‘rake’)
24 25 26 |
# File 'lib/rake/application.rb', line 24 def name @name end |
#original_dir ⇒ Object (readonly)
The original directory where rake was invoked.
27 28 29 |
# File 'lib/rake/application.rb', line 27 def original_dir @original_dir end |
#rakefile ⇒ Object (readonly)
Name of the actual rakefile used.
30 31 32 |
# File 'lib/rake/application.rb', line 30 def rakefile @rakefile end |
#terminal_columns ⇒ Object
Number of columns on the terminal
33 34 35 |
# File 'lib/rake/application.rb', line 33 def terminal_columns @terminal_columns end |
#top_level_tasks ⇒ Object (readonly)
List of the top level task names (task names from the command line).
36 37 38 |
# File 'lib/rake/application.rb', line 36 def top_level_tasks @top_level_tasks end |
Instance Method Details
#add_import(fn) ⇒ Object
Add a file to the list of files to be imported.
749 750 751 |
# File 'lib/rake/application.rb', line 749 def add_import(fn) # :nodoc: @pending_imports << fn end |
#add_loader(ext, loader) ⇒ Object
Add a loader to handle imported files ending in the extension ext
.
129 130 131 132 |
# File 'lib/rake/application.rb', line 129 def add_loader(ext, loader) ext = ".#{ext}" unless ext =~ /^\./ @loaders[ext] = loader end |
#collect_command_line_tasks ⇒ Object
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.
730 731 732 733 734 735 736 737 738 739 740 |
# File 'lib/rake/application.rb', line 730 def collect_command_line_tasks # :nodoc: @top_level_tasks = [] ARGV.each do |arg| if arg =~ /^(\w+)=(.*)$/m ENV[$1] = $2 else @top_level_tasks << arg unless arg =~ /^-/ end end @top_level_tasks.push(default_task_name) if @top_level_tasks.empty? end |
#default_task_name ⇒ Object
Default task name (“default”). (May be overridden by subclasses)
744 745 746 |
# File 'lib/rake/application.rb', line 744 def default_task_name # :nodoc: "default" end |
#deprecate(old_usage, new_usage, call_site) ⇒ Object
Warn about deprecated usage.
Example:
Rake.application.deprecate("import", "Rake.import", caller.first)
239 240 241 242 243 244 245 |
# File 'lib/rake/application.rb', line 239 def deprecate(old_usage, new_usage, call_site) # :nodoc: unless .ignore_deprecate $stderr.puts "WARNING: '#{old_usage}' is deprecated. " + "Please use '#{new_usage}' instead.\n" + " at #{call_site}" end end |
#display_error_message(ex) ⇒ Object
Display the error message that caused the exception.
196 197 198 199 200 201 202 |
# File 'lib/rake/application.rb', line 196 def (ex) # :nodoc: trace "#{name} aborted!" display_exception_details(ex) trace "Tasks: #{ex.chain}" if has_chain?(ex) trace "(See full trace by running task with --trace)" unless .backtrace end |
#display_exception_backtrace(ex) ⇒ Object
:nodoc:
226 227 228 229 230 231 232 |
# File 'lib/rake/application.rb', line 226 def display_exception_backtrace(ex) # :nodoc: if .backtrace trace ex.backtrace.join("\n") else trace Backtrace.collapse(ex.backtrace).join("\n") end end |
#display_exception_details(ex) ⇒ Object
:nodoc:
204 205 206 207 208 209 210 211 212 |
# File 'lib/rake/application.rb', line 204 def display_exception_details(ex) # :nodoc: seen = Thread.current[:rake_display_exception_details_seen] ||= [] return if seen.include? ex seen << ex (ex) display_exception_backtrace(ex) display_exception_details(ex.cause) if has_cause?(ex) end |
#display_exception_message_details(ex) ⇒ Object
:nodoc:
218 219 220 221 222 223 224 |
# File 'lib/rake/application.rb', line 218 def (ex) # :nodoc: if ex.instance_of?(RuntimeError) trace ex. else trace "#{ex.class.name}: #{ex.}" end end |
#display_prerequisites ⇒ Object
Display the tasks and prerequisites
367 368 369 370 371 372 |
# File 'lib/rake/application.rb', line 367 def display_prerequisites # :nodoc: tasks.each do |t| puts "#{name} #{t.name}" t.prerequisites.each { |pre| puts " #{pre}" } end end |
#display_tasks_and_comments ⇒ Object
Display the tasks and comments.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/rake/application.rb', line 284 def display_tasks_and_comments # :nodoc: displayable_tasks = tasks.select { |t| (.show_all_tasks || t.comment) && t.name =~ .show_task_pattern } case .show_tasks when :tasks 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) end when :describe displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" comment = t.full_comment || "" 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: '#{.show_tasks}'" end end |
#dynamic_width ⇒ Object
Calculate the dynamic width of the
335 336 337 |
# File 'lib/rake/application.rb', line 335 def dynamic_width # :nodoc: @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) end |
#dynamic_width_stty ⇒ Object
:nodoc:
339 340 341 |
# File 'lib/rake/application.rb', line 339 def dynamic_width_stty # :nodoc: %x{stty size 2>/dev/null}.split[1].to_i end |
#dynamic_width_tput ⇒ Object
:nodoc:
343 344 345 |
# File 'lib/rake/application.rb', line 343 def dynamic_width_tput # :nodoc: %x{tput cols 2>/dev/null}.to_i end |
#exit_because_of_exception(ex) ⇒ Object
Exit the program because of an unhandle exception. (may be overridden by subclasses)
191 192 193 |
# File 'lib/rake/application.rb', line 191 def exit_because_of_exception(ex) # :nodoc: exit(false) end |
#find_rakefile_location ⇒ Object
:nodoc:
655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/rake/application.rb', line 655 def find_rakefile_location # :nodoc: here = Dir.pwd until (fn = have_rakefile) Dir.chdir("..") return nil if Dir.pwd == here || .nosearch here = Dir.pwd end [fn, here] ensure Dir.chdir(Rake.original_dir) end |
#handle_options ⇒ Object
Read and handle the command line options.
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
# File 'lib/rake/application.rb', line 620 def # :nodoc: .rakelib = ['rakelib'] .trace_output = $stderr OptionParser.new do |opts| opts. = "#{Rake.application.name} [-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 .each { |args| opts.on(*args) } opts.environment('RAKEOPT') end.parse! end |
#has_cause?(ex) ⇒ Boolean
:nodoc:
214 215 216 |
# File 'lib/rake/application.rb', line 214 def has_cause?(ex) # :nodoc: ex.respond_to?(:cause) && ex.cause end |
#have_rakefile ⇒ Object
True if one of the files in RAKEFILES is in the current directory. If a match is found, it is copied into @rakefile.
255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/rake/application.rb', line 255 def have_rakefile # :nodoc: @rakefiles.each do |fn| if File.exist?(fn) others = FileList.glob(fn, File::FNM_CASEFOLD) return others.size == 1 ? others.first : fn elsif fn == '' return fn end end return nil end |
#init(app_name = 'rake') ⇒ Object
Initialize the command line parameters and app name.
83 84 85 86 87 88 89 |
# File 'lib/rake/application.rb', line 83 def init(app_name='rake') standard_exception_handling do @name = app_name collect_command_line_tasks end end |
#invoke_task(task_string) ⇒ Object
Invokes a task with arguments that are extracted from task_string
147 148 149 150 151 |
# File 'lib/rake/application.rb', line 147 def invoke_task(task_string) # :nodoc: name, args = parse_task_string(task_string) t = self[name] t.invoke(*args) end |
#load_imports ⇒ Object
Load the pending list of imported files.
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
# File 'lib/rake/application.rb', line 754 def load_imports # :nodoc: while fn = @pending_imports.shift next if @imported.member?(fn) fn_task = lookup(fn) and fn_task.invoke ext = File.extname(fn) loader = @loaders[ext] || @default_loader loader.load(fn) if fn_task = lookup(fn) and fn_task.needed? fn_task.reenable fn_task.invoke loader.load(fn) end @imported << fn end end |
#load_rakefile ⇒ Object
Find the rakefile and then load it and any pending imports.
92 93 94 95 96 |
# File 'lib/rake/application.rb', line 92 def load_rakefile standard_exception_handling do raw_load_rakefile end end |
#options ⇒ Object
Application options from the command line
135 136 137 |
# File 'lib/rake/application.rb', line 135 def @options ||= OpenStruct.new end |
#parse_task_string(string) ⇒ Object
:nodoc:
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/rake/application.rb', line 153 def parse_task_string(string) # :nodoc: /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s name = $1 remaining_args = $2 return string, [] unless name return name, [] if remaining_args.empty? args = [] begin /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args remaining_args = $2 args << $1.gsub(/\\(.)/, '\1') end while remaining_args return name, args end |
#print_rakefile_directory(location) ⇒ Object
:nodoc:
667 668 669 670 |
# File 'lib/rake/application.rb', line 667 def print_rakefile_directory(location) # :nodoc: $stderr.puts "(in #{Dir.pwd})" unless .silent or original_dir == location end |
#rake_require(file_name, paths = $LOAD_PATH, loaded = $") ⇒ Object
Similar to the regular Ruby require
command, but will check for *.rake files in addition to *.rb files.
641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/rake/application.rb', line 641 def rake_require(file_name, paths=$LOAD_PATH, loaded=$") # :nodoc: 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 |
#rakefile_location(backtrace = caller) ⇒ Object
:nodoc:
770 771 772 773 774 775 776 777 |
# File 'lib/rake/application.rb', line 770 def rakefile_location(backtrace=caller) # :nodoc: backtrace.map { |t| t[/([^:]+):/, 1] } re = /^#{@rakefile}$/ re = /#{re.source}/i if windows? backtrace.find { |str| str =~ re } || '' end |
#raw_load_rakefile ⇒ Object
:nodoc:
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
# File 'lib/rake/application.rb', line 672 def raw_load_rakefile # :nodoc: rakefile, location = find_rakefile_location if (! .ignore_system) && (.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) Rake.load_rakefile(File.(@rakefile)) if @rakefile && @rakefile != '' .rakelib.each do |rlib| glob("#{rlib}/*.rake") do |name| add_import name end end end load_imports end |
#run ⇒ Object
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.
74 75 76 77 78 79 80 |
# File 'lib/rake/application.rb', line 74 def run standard_exception_handling do init load_rakefile top_level end end |
#run_with_threads ⇒ Object
Run the given block with the thread startup and shutdown.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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 |
#standard_exception_handling ⇒ Object
Provide standard exception handling for the given block.
175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/rake/application.rb', line 175 def standard_exception_handling # :nodoc: yield rescue SystemExit # Exit silently with current status raise rescue OptionParser::InvalidOption => ex $stderr.puts ex. exit(false) rescue Exception => ex # Exit with error message (ex) exit_because_of_exception(ex) end |
#standard_rake_options ⇒ Object
A list of all the standard options used in rake, suitable for passing to OptionParser.
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/rake/application.rb', line 388 def # :nodoc: ( [ ['--all', '-A', "Show all tasks, even uncommented ones (in combination with -T or -D)", lambda { |value| .show_all_tasks = value } ], ['--backtrace=[OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.", lambda { |value| .backtrace = true select_trace_output(, 'backtrace', value) } ], ['--build-all', '-B', "Build all prerequisites, including those which are up-to-date.", lambda { |value| .build_all = true } ], ['--comments', "Show commented tasks only", lambda { |value| .show_all_tasks = !value } ], ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.", lambda { |value| select_tasks_to_show(, :describe, value) } ], ['--dry-run', '-n', "Do a dry run without executing actions.", lambda { |value| Rake.verbose(true) Rake.nowrite(true) .dryrun = true .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) } ], ['--jobs', '-j [NUMBER]', "Specifies the maximum number of tasks to execute in parallel. " + "(default is number of CPU cores + 4)", lambda { |value| if value.nil? || value == '' value = FIXNUM_MAX elsif value =~ /^\d+$/ value = value.to_i else value = Rake.suggested_thread_count end value = 1 if value < 1 .thread_pool_size = value - 1 } ], ['--job-stats [LEVEL]', "Display job statistics. " + "LEVEL=history displays a complete job list", lambda { |value| if value =~ /^history/i .job_stats = :history else .job_stats = true end } ], ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.", lambda { |value| $:.push(value) } ], ['--multitask', '-m', "Treat all tasks as multitasks.", lambda { |value| .always_multitask = true } ], ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.", lambda { |value| .nosearch = true } ], ['--prereqs', '-P', "Display the tasks and dependencies, then exit.", lambda { |value| .show_prereqs = true } ], ['--quiet', '-q', "Do not log messages to standard output.", lambda { |value| Rake.verbose(false) } ], ['--rakefile', '-f [FILENAME]', "Use FILENAME as the rakefile to search for.", lambda { |value| value ||= '' @rakefiles.clear @rakefiles << value } ], ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', "Auto-import any .rake files in RAKELIBDIR. " + "(default is 'rakelib')", lambda { |value| .rakelib = value.split(File::PATH_SEPARATOR) } ], ['--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| .trace_rules = true } ], ['--silent', '-s', "Like --quiet, but also suppresses the " + "'in directory' announcement.", lambda { |value| Rake.verbose(false) .silent = true } ], ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. " + "Ignored if --trace is on.", lambda { |value| .suppress_backtrace_pattern = Regexp.new(value) } ], ['--system', '-g', "Using system wide (global) rakefiles " + "(usually '~/.rake/*.rake').", lambda { |value| .load_system = true } ], ['--no-system', '--nosystem', '-G', "Use standard project Rakefile search paths, " + "ignore system wide rakefiles.", lambda { |value| .ignore_system = true } ], ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) " + "with descriptions, then exit.", lambda { |value| select_tasks_to_show(, :tasks, value) } ], ['--trace=[OUT]', '-t', "Turn on invoke/execute tracing, enable full backtrace. " + "OUT can be stderr (default) or stdout.", lambda { |value| .trace = true .backtrace = true select_trace_output(, 'trace', value) 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| select_tasks_to_show(, :lines, value) .show_all_tasks = true } ], ['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.", lambda { |value| .ignore_deprecate = true } ], ]) end |
#system_dir ⇒ Object
The directory path containing the system wide rakefiles.
704 705 706 707 708 709 710 711 712 713 |
# File 'lib/rake/application.rb', line 704 def system_dir # :nodoc: @system_dir ||= begin if ENV['RAKE_SYSTEM'] ENV['RAKE_SYSTEM'] else standard_system_dir end end end |
#terminal_width ⇒ Object
:nodoc:
323 324 325 326 327 328 329 330 331 332 |
# File 'lib/rake/application.rb', line 323 def terminal_width # :nodoc: if @terminal_columns.nonzero? result = @terminal_columns else result = unix? ? dynamic_width : 80 end (result < 10) ? 80 : result rescue 80 end |
#thread_pool ⇒ Object
Return the thread pool used for multithreaded processing.
140 141 142 |
# File 'lib/rake/application.rb', line 140 def thread_pool # :nodoc: @thread_pool ||= ThreadPool.new(.thread_pool_size || Rake.suggested_thread_count-1) end |
#top_level ⇒ Object
Run the top level tasks of a Rake application.
99 100 101 102 103 104 105 106 107 108 109 |
# 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 |
#trace(*strings) ⇒ Object
:nodoc:
374 375 376 377 |
# File 'lib/rake/application.rb', line 374 def trace(*strings) # :nodoc: .trace_output ||= $stderr trace_on(.trace_output, *strings) end |
#truncate(string, width) ⇒ Object
:nodoc:
356 357 358 359 360 361 362 363 364 |
# File 'lib/rake/application.rb', line 356 def truncate(string, width) # :nodoc: if string.nil? "" elsif string.length <= width string else (string[0, width - 3] || "") + "..." end end |
#truncate_output? ⇒ Boolean
We will truncate output if we are outputting to a TTY or if we’ve been given an explicit column width to honor
279 280 281 |
# File 'lib/rake/application.rb', line 279 def truncate_output? # :nodoc: tty_output? || @terminal_columns.nonzero? end |
#tty_output=(tty_output_state) ⇒ Object
Override the detected TTY output state (mostly for testing)
273 274 275 |
# File 'lib/rake/application.rb', line 273 def tty_output=(tty_output_state) # :nodoc: @tty_output = tty_output_state end |
#tty_output? ⇒ Boolean
True if we are outputting to TTY, false otherwise
268 269 270 |
# File 'lib/rake/application.rb', line 268 def tty_output? # :nodoc: @tty_output end |
#unix? ⇒ Boolean
:nodoc:
347 348 349 350 |
# File 'lib/rake/application.rb', line 347 def unix? # :nodoc: RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end |