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::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) ⇒ 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) ⇒ Object
Call the #rebase method of the module.
-
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
-
#remove_build_directory(mod) ⇒ Object
Call the #clear_build_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, #complete_arguments, #complete_readline_1_8, #complete_readline_1_9, #configuration, #do_complete_1_8, #do_complete_1_9, #each_option, #execute, #fullname, #log?, #say, #setup_command, #show_help, #skip_command, #teardown_command, #usage
Methods included from HelpText
#cmdalias, #description, included, #long_description, #name
Constructor Details
#initialize(*args) ⇒ ModuleBasedCommand
Returns a new instance of ModuleBasedCommand.
539 540 541 542 543 544 545 |
# File 'lib/build-tool/commands.rb', line 539 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.
677 678 679 |
# File 'lib/build-tool/commands.rb', line 677 def clean( mod ) ModuleActions::Clean.new( self, mod ).do end |
#clone(mod) ⇒ Object
Call the #clone method of the module.
684 685 686 |
# File 'lib/build-tool/commands.rb', line 684 def clone( mod ) ModuleActions::Clone.new( self, mod ).do end |
#configure(mod) ⇒ Object
Call the #configure method of the module.
691 692 693 |
# File 'lib/build-tool/commands.rb', line 691 def configure( mod ) ModuleActions::Configure.new( self, mod ).do end |
#do_execute(args) ⇒ Object
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 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
# File 'lib/build-tool/commands.rb', line 579 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 logger.info( '#### Checking for obstacles' ) isready = true ModuleProgressbar.new( 'Modules', modules ) do |mod| isready &= is_module_ready?( mod ) end if !isready logger.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 logger.info( "User Interrupt" ) return -1 end end if !isready logger.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 logger.info "" logger.info "#### Module #{mod.name} (#{index+1}/#{modules.size})" do_execute_module( mod ) rescue Interrupt => e raise e rescue BuildTool::Error => e logger.error e. logger.verbose e.backtrace.join("\n") @failed_modules << mod.name rc = -1 break if @stop_on_error rescue Exception => e logger.error "#{e.class}:#{e.}" logger.verbose e.backtrace.join("\n") @failed_modules << mod.name rc = -1 break if @stop_on_error ensure logger.info "#### Module #{mod.name} finished" end end end end return rc; end |
#fetch(mod) ⇒ Object
Call the #fetch method of the module.
698 699 700 |
# File 'lib/build-tool/commands.rb', line 698 def fetch( mod ) ModuleActions::Fetch.new( self, mod ).do end |
#initialize_options ⇒ Object
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/build-tool/commands.rb', line 547 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.
705 706 707 |
# File 'lib/build-tool/commands.rb', line 705 def install( mod, *args ) ModuleActions::Install.new( self, mod, *args ).do end |
#is_module_ready?(mod) ⇒ Boolean
571 572 573 |
# File 'lib/build-tool/commands.rb', line 571 def is_module_ready?( mod ) true end |
#make(mod, *args) ⇒ Object
Call the #make method of the module.
712 713 714 |
# File 'lib/build-tool/commands.rb', line 712 def make( mod, *args ) ModuleActions::Make.new( self, mod, *args ).do end |
#prepare_module(mod) ⇒ Object
575 576 577 |
# File 'lib/build-tool/commands.rb', line 575 def prepare_module( mod ) true end |
#rebase(mod) ⇒ Object
Call the #rebase method of the module.
719 720 721 |
# File 'lib/build-tool/commands.rb', line 719 def rebase( mod ) ModuleActions::Rebase.new( self, mod ).do end |
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
726 727 728 |
# File 'lib/build-tool/commands.rb', line 726 def reconfigure( mod ) ModuleActions::Reconfigure.new( self, mod ).do end |
#remove_build_directory(mod) ⇒ Object
Call the #clear_build_directory method of the module.
733 734 735 |
# File 'lib/build-tool/commands.rb', line 733 def remove_build_directory( mod ) ModuleActions::RemoveBuildDirectory.new( self, mod ).do end |
#summarize ⇒ Object
663 664 665 666 667 668 669 670 671 |
# File 'lib/build-tool/commands.rb', line 663 def summarize logger.info "" if !@failed_modules.empty? logger.info "#### Finished with errors" logger.info "Failed modules:\n\t#{ @failed_modules.join( "\n\t" ) }" else logger.info "#### Finished without errors" end end |