Class: BuildTool::Commands::ModuleBasedCommand

Inherits:
Standard
  • Object
show all
Defined in:
lib/build-tool/commands.rb

Overview

class Standard

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_modules, #initialize_options, #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, #initialize_options, #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.



479
480
481
482
# File 'lib/build-tool/commands.rb', line 479

def initialize( *args )
    super( *args )
    @failed_modules = []
end

Instance Method Details

#clean(mod, *args) ⇒ Object

Call the #clean method of the module.

Parameters:

  • mod (Object)

    The module to use



567
568
569
# File 'lib/build-tool/commands.rb', line 567

def clean( mod, *args )
    ModuleActions::Clean.new( self, mod, *args ).do
end

#clone(mod) ⇒ Object

Call the #clone method of the module.

Parameters:

  • mod (Object)

    The module to use



574
575
576
# File 'lib/build-tool/commands.rb', line 574

def clone( mod )
    ModuleActions::Clone.new( self, mod ).do
end

#configure(mod) ⇒ Object

Call the #configure method of the module.

Parameters:

  • mod (Object)

    The module to use



581
582
583
# File 'lib/build-tool/commands.rb', line 581

def configure( mod )
    ModuleActions::Configure.new( self, mod ).do
end

#do_execute(args) ⇒ Object



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
# File 'lib/build-tool/commands.rb', line 488

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|

                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.message
                    logger.verbose e.backtrace.join("\n")
                    @failed_modules << mod.name
                    rc = -1
                rescue Exception => e
                    logger.error   "#{e.class}:#{e.message}"
                    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.

Parameters:

  • mod (Object)

    The module to use



588
589
590
# File 'lib/build-tool/commands.rb', line 588

def fetch( mod )
    ModuleActions::Fetch.new( self, mod ).do
end

#install(mod, *args) ⇒ Object

Call the #install method of the module.

Parameters:

  • mod (Object)

    The module to use



595
596
597
# File 'lib/build-tool/commands.rb', line 595

def install( mod, *args )
    ModuleActions::Install.new( self, mod, *args ).do
end

#is_module_ready?(mod) ⇒ Boolean

Returns:

  • (Boolean)


484
485
486
# File 'lib/build-tool/commands.rb', line 484

def is_module_ready?( mod )
    true
end

#make(mod, *args) ⇒ Object

Call the #make method of the module.

Parameters:

  • mod (Object)

    The module to use



602
603
604
# File 'lib/build-tool/commands.rb', line 602

def make( mod, *args )
    ModuleActions::Make.new( self, mod, *args ).do
end

#rebase(mod) ⇒ Object

Call the #rebase method of the module.

Parameters:

  • mod (Object)

    The module to use



609
610
611
# File 'lib/build-tool/commands.rb', line 609

def rebase( mod )
    ModuleActions::Rebase.new( self, mod ).do
end

#reconfigure(mod) ⇒ Object

Call the #reconfigure method of the module.

Parameters:

  • mod (Object)

    The module to use



616
617
618
# File 'lib/build-tool/commands.rb', line 616

def reconfigure( mod )
    ModuleActions::Reconfigure.new( self, mod ).do
end

#summarizeObject



553
554
555
556
557
558
559
560
561
# File 'lib/build-tool/commands.rb', line 553

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