Class: Bob::Builder

Inherits:
Object show all
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, commit_id) ⇒ Builder

Returns a new instance of Builder.



7
8
9
10
# File 'lib/bob/builder.rb', line 7

def initialize(buildable, commit_id)
  @buildable = buildable
  @commit_id = commit_id
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

#commit_idObject (readonly)

Returns the value of attribute commit_id.



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

def commit_id
  @commit_id
end

Instance Method Details

#buildObject

This is where the magic happens:

  1. Check out the repo to the appropriate commit.

  2. Notify the buildable that the build is starting.

  3. Run the build script on it in the background.

  4. Reports the build back to the buildable.



18
19
20
21
22
23
24
25
26
27
# File 'lib/bob/builder.rb', line 18

def build
  Bob.logger.info "Building #{commit_id} of the #{buildable.kind} repo at #{buildable.uri}"
  in_background do
    scm.with_commit(commit_id) do
      buildable.start_building(commit_id, scm.info(commit_id))
      build_status, build_output = run_build_script
      buildable.finish_building(commit_id, build_status, build_output)
    end
  end
end