Class: Integrity::Builder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Builder

Returns a new instance of Builder.



7
8
9
10
11
12
13
14
# File 'lib/integrity/builder.rb', line 7

def initialize(project)
  @uri = project.uri
  @build_script = project.command
  @branch = project.branch
  @scm = SCM.new(@uri, @branch, export_directory)
  @build = Build.new(:project => project)
  @project = project
end

Instance Attribute Details

#build_scriptObject (readonly)

Returns the value of attribute build_script.



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

def build_script
  @build_script
end

Instance Method Details

#build(commit) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/integrity/builder.rb', line 16

def build(commit)
  Integrity.log "Building #{commit} (#{@branch}) of #{@build.project.name} in #{export_directory} using #{scm_name}"
  @scm.with_revision(commit) { 
    @project.update_attributes(:shortened_current_commit_msg => @scm.(commit)[:message][0..40])
    @project.update_attributes(:current_commit_identifier => @scm.commit_identifier(commit)[0..6])
    
    run_build_script
  }
  @build
ensure
  @build.commit_identifier = @scm.commit_identifier(commit)
  @build. = @scm.(commit)
  @build.save
end

#delete_codeObject



31
32
33
34
35
# File 'lib/integrity/builder.rb', line 31

def delete_code
  FileUtils.rm_r export_directory
rescue Errno::ENOENT
  nil
end