Class: BuildTool::Commands::ModuleBasedCommand
- Defined in:
- lib/build-tool/commands.rb
Overview
class ModuleProgress
Direct Known Subclasses
Build, Configure, Ctags, Fetch, Gc, Install, BuildTool::Commands::Modules::Cleanup, BuildTool::Commands::Modules::Disable, BuildTool::Commands::Modules::Enable, BuildTool::Commands::Modules::Info, Rebase
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#clean(mod) ⇒ Object
Call the #clean method of the module.
-
#clone(mod) ⇒ Object
Call the #clone method of the module.
-
#configure(mod) ⇒ Object
Call the #configure method of the module.
- #do_execute(args) ⇒ Object
-
#fetch(mod, verbose = false) ⇒ Object
Call the #fetch method of the module.
-
#initialize(*args) ⇒ ModuleBasedCommand
constructor
A new instance of ModuleBasedCommand.
- #initialize_options ⇒ Object
-
#install(mod, *args) ⇒ Object
Call the #install method of the module.
- #is_module_ready?(mod) ⇒ Boolean
-
#make(mod, *args) ⇒ Object
Call the #make method of the module.
- #prepare_module(mod) ⇒ Object
-
#rebase(mod, verbose = false) ⇒ Object
Call the #rebase method of the module.
-
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
-
#remove_build_directory(mod, force = false) ⇒ Object
Call the #remove_build_directory method of the module.
-
#remove_source_directory(mod, force = false) ⇒ Object
Call the #remove_source_directory method of the module.
- #summarize ⇒ Object
Methods inherited from Standard
#complete_module, #complete_modules, #log_directory, #while_logging_to
Methods inherited from Base
#<=>, #applicable?, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #each_option, #error, #execute, #fullname, #info, #log?, #setup_command, #setup_options, #show_help, #skip_command, #teardown_command, #trace, #usage, #verbose, #warn
Methods included from HelpText
#cmdalias, #description, included, #long_description, #name
Constructor Details
#initialize(*args) ⇒ ModuleBasedCommand
Returns a new instance of ModuleBasedCommand.
492 493 494 495 496 497 498 |
# File 'lib/build-tool/commands.rb', line 492 def initialize( *args ) super( *args ) @failed_modules = [] @resume_from = nil @resume_after = nil @stop_on_error = false end |
Instance Method Details
#clean(mod) ⇒ Object
Call the #clean method of the module.
651 652 653 |
# File 'lib/build-tool/commands.rb', line 651 def clean( mod ) ModuleActions::Clean.new( self, mod ).do end |
#clone(mod) ⇒ Object
Call the #clone method of the module.
658 659 660 |
# File 'lib/build-tool/commands.rb', line 658 def clone( mod ) ModuleActions::Clone.new( self, mod ).do end |
#configure(mod) ⇒ Object
Call the #configure method of the module.
665 666 667 |
# File 'lib/build-tool/commands.rb', line 665 def configure( mod ) ModuleActions::Configure.new( self, mod ).do end |
#do_execute(args) ⇒ Object
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 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/build-tool/commands.rb', line 532 def do_execute( args ) if args.length == 0 # *TODO* print better message return usage( "Not enough arguments." ) end # 1. Resolve the modules modules = [] args.each do |arg| complete_modules( arg ).each do |mod| modules << mod end end # 2. Check if the modules are ready info( '#### Checking for obstacles' ) isready = true ModuleProgressbar.new( 'Modules', modules ) do |mod| begin isready &= is_module_ready?( mod ) rescue Interrupt => e info( "User Interrupt" ) return -1 rescue BuildTool::Error => e error( '%s: %s' % [ mod.name, e. ] ) verbose( e.backtrace.join("\n") ) raise rescue Exception => e error( '%s:%s: %s' % [ mod.name, e.class, e. ] ) verbose( e.backtrace.join("\n") ) raise end end if !isready error( "There were some problems detected. Exiting." ) return -1 end # 2. Prepare the modules for access. Interactive stuff here. modules.each do |mod| begin isready &= prepare_module( mod ) rescue Interrupt => e info( "User Interrupt" ) return -1 rescue BuildTool::Error => e error( e. ) verbose( e.backtrace.join("\n") ) raise rescue Exception => e error( "#{e.class}:#{e.}" ) verbose( e.backtrace.join("\n") ) raise end end if !isready error( "Unexpected problems encountered. Exiting." ) return -1 end rc = 0 # Our return code. @failed_modules = [] while_logging_to nil, 'build-status', :info do begin modules.each_with_index do |mod, index| begin info( "" ) info( "#### Module #{mod.name} (#{index+1}/#{modules.size})" ) do_execute_module( mod ) rescue Interrupt => e raise e rescue BuildTool::Error => e error( e. ) verbose( e.backtrace.join("\n") ) @failed_modules << mod.name rc = -1 break if @stop_on_error rescue Exception => e error( "#{e.class}:#{e.}" ) verbose( e.backtrace.join("\n") ) @failed_modules << mod.name rc = -1 break if @stop_on_error ensure info( "#### Module #{mod.name} finished" ) end end end end return rc; end |
#fetch(mod, verbose = false) ⇒ Object
Call the #fetch method of the module.
672 673 674 |
# File 'lib/build-tool/commands.rb', line 672 def fetch( mod, verbose = false ) ModuleActions::Fetch.new( self, mod, verbose ).do end |
#initialize_options ⇒ Object
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/build-tool/commands.rb', line 500 def .on( "--resume-from MODULE", "Skip all module before module." ) { |t| begin @resume_from = complete_module( t ) rescue UsageError => e raise UsageError, "--resume-from: #{e}" end raise UsageError, "Both --resume-from and --resume-after specified!" if @resume_after } .on( "--resume-after MODULE", "Skip all module before and including module." ) { |t| begin @resume_after = complete_module( t ) rescue UsageError => e raise UsageError, "--resume-after: #{e}" end raise UsageError, "Both --resume-from and --resume-after specified!" if @resume_from } .on( "--[no-]stop-on-error", "Break on the first error." ) { |t| @stop_on_error = t } super end |
#install(mod, *args) ⇒ Object
Call the #install method of the module.
679 680 681 |
# File 'lib/build-tool/commands.rb', line 679 def install( mod, *args ) ModuleActions::Install.new( self, mod, *args ).do end |
#is_module_ready?(mod) ⇒ Boolean
524 525 526 |
# File 'lib/build-tool/commands.rb', line 524 def is_module_ready?( mod ) true end |
#make(mod, *args) ⇒ Object
Call the #make method of the module.
686 687 688 |
# File 'lib/build-tool/commands.rb', line 686 def make( mod, *args ) ModuleActions::Make.new( self, mod, *args ).do end |
#prepare_module(mod) ⇒ Object
528 529 530 |
# File 'lib/build-tool/commands.rb', line 528 def prepare_module( mod ) true end |
#rebase(mod, verbose = false) ⇒ Object
Call the #rebase method of the module.
693 694 695 |
# File 'lib/build-tool/commands.rb', line 693 def rebase( mod, verbose = false ) ModuleActions::Rebase.new( self, mod, verbose ).do end |
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
700 701 702 |
# File 'lib/build-tool/commands.rb', line 700 def reconfigure( mod ) ModuleActions::Reconfigure.new( self, mod ).do end |
#remove_build_directory(mod, force = false) ⇒ Object
Call the #remove_build_directory method of the module.
707 708 709 |
# File 'lib/build-tool/commands.rb', line 707 def remove_build_directory( mod, force = false ) ModuleActions::RemoveBuildDirectory.new( self, mod, force ).do end |
#remove_source_directory(mod, force = false) ⇒ Object
Call the #remove_source_directory method of the module.
714 715 716 |
# File 'lib/build-tool/commands.rb', line 714 def remove_source_directory( mod, force = false ) ModuleActions::RemoveSourceDirectory.new( self, mod, force ).do end |
#summarize ⇒ Object
637 638 639 640 641 642 643 644 645 |
# File 'lib/build-tool/commands.rb', line 637 def summarize info( "" ) if !@failed_modules.empty? info( "#### Finished with errors" ) info( "Failed modules:\n\t#{ @failed_modules.join( "\n\t" ) }" ) else info( "#### Finished without errors" ) end end |