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?, #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, #show_help, #skip_command, #usage

Methods included from HelpText

#cmdalias, #description, included, #long_description, #name

Constructor Details

#initialize(*args) ⇒ ModuleBasedCommand

Returns a new instance of ModuleBasedCommand.



439
440
441
# File 'lib/build-tool/commands.rb', line 439

def initialize( *args )
    super( *args )
end

Instance Method Details

#clean(mod, *args) ⇒ Object

Call the #clean method of the module.

Parameters:

  • mod (Object)

    The module to use



506
507
508
# File 'lib/build-tool/commands.rb', line 506

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



513
514
515
# File 'lib/build-tool/commands.rb', line 513

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



520
521
522
# File 'lib/build-tool/commands.rb', line 520

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

#do_execute(args) ⇒ Object



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/build-tool/commands.rb', line 447

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.

    while_logging_to nil, 'build-status', :info do

        modules.each do |mod|

            begin
                logger.info ""
                logger.info "#### Module #{mod.name}"
                do_execute_module( mod )
            rescue Interrupt => e
                raise e
            rescue BuildTool::Error => e
                logger.error   e.message
                logger.verbose e.backtrace.join("\n")
                rc = -1
            rescue Exception => e
                logger.error   "#{e.class}:#{e.message}"
                logger.verbose e.backtrace.join("\n")
                rc = -1
            ensure
                logger.info "#### Module #{mod.name} finished"
            end
        end

    end

    return rc;
end

#fetch(mod) ⇒ Object

Call the #fetch method of the module.

Parameters:

  • mod (Object)

    The module to use



527
528
529
# File 'lib/build-tool/commands.rb', line 527

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



534
535
536
# File 'lib/build-tool/commands.rb', line 534

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

#is_module_ready?(mod) ⇒ Boolean

Returns:

  • (Boolean)


443
444
445
# File 'lib/build-tool/commands.rb', line 443

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



541
542
543
# File 'lib/build-tool/commands.rb', line 541

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



548
549
550
# File 'lib/build-tool/commands.rb', line 548

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



555
556
557
# File 'lib/build-tool/commands.rb', line 555

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