Class: Integrity::ProjectBuilder
- Extended by:
- Forwardable
- Defined in:
- lib/integrity/project_builder.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
Returns the value of attribute project.
-
#scm ⇒ Object
Returns the value of attribute scm.
Class Method Summary collapse
Instance Method Summary collapse
- #build(commit) ⇒ Object
- #delete_code ⇒ Object
-
#initialize(project) ⇒ ProjectBuilder
constructor
A new instance of ProjectBuilder.
Constructor Details
#initialize(project) ⇒ ProjectBuilder
Returns a new instance of ProjectBuilder.
18 19 20 21 |
# File 'lib/integrity/project_builder.rb', line 18 def initialize(project) @project = project @scm = SCM.new(uri, branch, export_directory) end |
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/integrity/project_builder.rb', line 7 def project @project end |
#scm ⇒ Object
Returns the value of attribute scm.
7 8 9 |
# File 'lib/integrity/project_builder.rb', line 7 def scm @scm end |
Class Method Details
.build(commit) ⇒ Object
10 11 12 |
# File 'lib/integrity/project_builder.rb', line 10 def self.build(commit) new(commit.project).build(commit) end |
.delete_working_directory(project) ⇒ Object
14 15 16 |
# File 'lib/integrity/project_builder.rb', line 14 def self.delete_working_directory(project) new(project).delete_code end |
Instance Method Details
#build(commit) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/integrity/project_builder.rb', line 23 def build(commit) build = commit.build build.start! Integrity.log "Building #{commit.identifier} (#{branch}) of #{name} in" + "#{export_directory} using #{scm.name}" scm.with_revision(commit.identifier) do Integrity.log "Running `#{command}` in #{scm.working_directory}" IO.popen("(cd #{scm.working_directory} && #{command}) 2>&1", "r") { |output| build.output = output.read } build.successful = $?.success? end build ensure build.complete! commit.update_attributes(scm.info(commit.identifier) || {}) project.enabled_notifiers.each { |notifier| notifier.notify_of_build(build) } end |
#delete_code ⇒ Object
45 46 47 48 49 |
# File 'lib/integrity/project_builder.rb', line 45 def delete_code FileUtils.rm_r export_directory rescue Errno::ENOENT nil end |