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

#options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_modules, #initialize_log_directory, #initialize_options, #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, #initialize, #initialize_options, #say, #show_help, #skip_command, #usage

Methods included from HelpText

#cmdalias, #description, included, #name

Constructor Details

This class inherits a constructor from BuildTool::Commands::Base

Instance Method Details

#do_execute(args) ⇒ Object



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/build-tool/commands.rb', line 351

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

    # 3. Let's go
    initialize_log_directory

    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

#is_module_ready?(mod) ⇒ Boolean

Returns:



347
348
349
# File 'lib/build-tool/commands.rb', line 347

def is_module_ready?( mod )
    true
end