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, BuildTool::Commands::Modules::MyShell, BuildTool::Commands::Modules::Status, 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?, #quiet, #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.
500 501 502 503 504 505 506 |
# File 'lib/build-tool/commands.rb', line 500 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.
660 661 662 |
# File 'lib/build-tool/commands.rb', line 660 def clean( mod ) ModuleActions::Clean.new( self, mod ).do end |
#clone(mod) ⇒ Object
Call the #clone method of the module.
667 668 669 |
# File 'lib/build-tool/commands.rb', line 667 def clone( mod ) ModuleActions::Clone.new( self, mod ).do end |
#configure(mod) ⇒ Object
Call the #configure method of the module.
674 675 676 |
# File 'lib/build-tool/commands.rb', line 674 def configure( mod ) ModuleActions::Configure.new( self, mod ).do end |
#do_execute(args) ⇒ Object
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 636 637 638 639 640 641 642 643 644 |
# File 'lib/build-tool/commands.rb', line 540 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| # :FIXME: what if arg is invalid? 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( "" ) quiet( "#### 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.
681 682 683 |
# File 'lib/build-tool/commands.rb', line 681 def fetch( mod, verbose = false ) ModuleActions::Fetch.new( self, mod, verbose ).do end |
#initialize_options ⇒ Object
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/build-tool/commands.rb', line 508 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.
688 689 690 |
# File 'lib/build-tool/commands.rb', line 688 def install( mod, *args ) ModuleActions::Install.new( self, mod, *args ).do end |
#is_module_ready?(mod) ⇒ Boolean
532 533 534 |
# File 'lib/build-tool/commands.rb', line 532 def is_module_ready?( mod ) true end |
#make(mod, *args) ⇒ Object
Call the #make method of the module.
695 696 697 |
# File 'lib/build-tool/commands.rb', line 695 def make( mod, *args ) ModuleActions::Make.new( self, mod, *args ).do end |
#prepare_module(mod) ⇒ Object
536 537 538 |
# File 'lib/build-tool/commands.rb', line 536 def prepare_module( mod ) true end |
#rebase(mod, verbose = false) ⇒ Object
Call the #rebase method of the module.
702 703 704 |
# File 'lib/build-tool/commands.rb', line 702 def rebase( mod, verbose = false ) ModuleActions::Rebase.new( self, mod, verbose ).do end |
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
709 710 711 |
# File 'lib/build-tool/commands.rb', line 709 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.
716 717 718 |
# File 'lib/build-tool/commands.rb', line 716 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.
723 724 725 |
# File 'lib/build-tool/commands.rb', line 723 def remove_source_directory( mod, force = false ) ModuleActions::RemoveSourceDirectory.new( self, mod, force ).do end |
#summarize ⇒ Object
646 647 648 649 650 651 652 653 654 |
# File 'lib/build-tool/commands.rb', line 646 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 |