Class: Bob::Builder

Inherits:
Object
  • Object
show all
Includes:
Ninja
Defined in:
lib/bob/builder.rb

Overview

A Builder will take care of building a buildable (wow, you didn’t see that coming, right?).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buildable) ⇒ Builder

Instantiate the Builder, passing an object that understands the Buildable interface.



11
12
13
# File 'lib/bob/builder.rb', line 11

def initialize(buildable)
  @buildable = buildable
end

Instance Attribute Details

#buildableObject (readonly)

Returns the value of attribute buildable.



5
6
7
# File 'lib/bob/builder.rb', line 5

def buildable
  @buildable
end

Instance Method Details

#buildObject

This is where the magic happens:

  1. Notify the buildable that the build is starting.

  2. Check out the repo to the appropriate commit.

  3. Run the build script on it.

  4. Reports the build back to the buildable.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bob/builder.rb', line 21

def build
  Bob.logger.info "Building #{buildable.commit} of the #{buildable.scm} repo at #{buildable.uri}"

  in_background do
    buildable.start_building if buildable.respond_to?(:start_building)

    scm.with_commit(buildable.commit) { |commit_info|
      buildable.finish_building(commit_info, *run_build_script)
    }
  end
end