Class: BuildTool::Commands::ModuleBasedCommand
- Defined in:
- lib/build-tool/commands.rb
Overview
class Standard
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, *args) ⇒ 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.
-
#rebase(mod) ⇒ Object
Call the #rebase method of the module.
-
#reconfigure(mod) ⇒ Object
Call the #reconfigure 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.
488 489 490 491 492 |
# File 'lib/build-tool/commands.rb', line 488 def initialize( *args ) super( *args ) @failed_modules = [] @resume_from = nil end |
Instance Method Details
#clean(mod, *args) ⇒ Object
Call the #clean method of the module.
595 596 597 |
# File 'lib/build-tool/commands.rb', line 595 def clean( mod, *args ) ModuleActions::Clean.new( self, mod, *args ).do end |
#clone(mod) ⇒ Object
Call the #clone method of the module.
602 603 604 |
# File 'lib/build-tool/commands.rb', line 602 def clone( mod ) ModuleActions::Clone.new( self, mod ).do end |
#configure(mod) ⇒ Object
Call the #configure method of the module.
609 610 611 |
# File 'lib/build-tool/commands.rb', line 609 def configure( mod ) ModuleActions::Configure.new( self, mod ).do end |
#do_execute(args) ⇒ Object
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 |
# File 'lib/build-tool/commands.rb', line 506 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 prerequisites isready = true modules.each do |mod| isready &= is_module_ready?( mod ) end if !isready logger.error "Found problems. 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| if not @resume_from.nil? if mod.name == @resume_from.name @resume_from = nil else logger.info "Skipping module #{mod.name} (#{index+1}/#{modules.size})" next end end 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 rescue Exception => e logger.error "#{e.class}:#{e.}" logger.verbose e.backtrace.join("\n") @failed_modules << mod.name rc = -1 ensure logger.info "#### Module #{mod.name} finished" end end end end return rc; end |
#fetch(mod) ⇒ Object
Call the #fetch method of the module.
616 617 618 |
# File 'lib/build-tool/commands.rb', line 616 def fetch( mod ) ModuleActions::Fetch.new( self, mod ).do end |
#initialize_options ⇒ Object
494 495 496 497 498 499 500 |
# File 'lib/build-tool/commands.rb', line 494 def .on( "--resume-from [module]", "Skip all module before module." ) { |t| @resume_from = complete_module( t ) } super end |
#install(mod, *args) ⇒ Object
Call the #install method of the module.
623 624 625 |
# File 'lib/build-tool/commands.rb', line 623 def install( mod, *args ) ModuleActions::Install.new( self, mod, *args ).do end |
#is_module_ready?(mod) ⇒ Boolean
502 503 504 |
# File 'lib/build-tool/commands.rb', line 502 def is_module_ready?( mod ) true end |
#make(mod, *args) ⇒ Object
Call the #make method of the module.
630 631 632 |
# File 'lib/build-tool/commands.rb', line 630 def make( mod, *args ) ModuleActions::Make.new( self, mod, *args ).do end |
#rebase(mod) ⇒ Object
Call the #rebase method of the module.
637 638 639 |
# File 'lib/build-tool/commands.rb', line 637 def rebase( mod ) ModuleActions::Rebase.new( self, mod ).do end |
#reconfigure(mod) ⇒ Object
Call the #reconfigure method of the module.
644 645 646 |
# File 'lib/build-tool/commands.rb', line 644 def reconfigure( mod ) ModuleActions::Reconfigure.new( self, mod ).do end |
#summarize ⇒ Object
581 582 583 584 585 586 587 588 589 |
# File 'lib/build-tool/commands.rb', line 581 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 |