Class: Omnibus::Builder::BuildCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/omnibus/builder.rb

Overview

This is an internal wrapper around a command executed on the system. The block could contain a Ruby command (such as FileUtils.rm_rf(‘/’)), or it could contain a call to shell out to the system.

Public API collapse

Public API collapse

Constructor Details

#initialize(description, &block) ⇒ BuildCommand

Create a new BuildCommand object.

Parameters:

  • description (String)

    a unique identifier for this build command - it will be used for logging and timing labels

  • block (Proc)

    the block to capture



1086
1087
1088
# File 'lib/omnibus/builder.rb', line 1086

def initialize(description, &block)
  @description, @block = description, block
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



1075
1076
1077
# File 'lib/omnibus/builder.rb', line 1075

def description
  @description
end

Instance Method Details

#run(builder) ⇒ Object

Execute the build command against the given object. Because BuildCommand objects could reference internal DSL methods, this method requires you pass in an object against which to instance_eval the block. Otherwise, you would be severly restricted in the commands avaiable to you via the DSL.

Parameters:

  • builder (Builder)

    the builder to instance_eval against



1100
1101
1102
# File 'lib/omnibus/builder.rb', line 1100

def run(builder)
  builder.instance_eval(&@block)
end