Class: Heidi::Integrator
- Inherits:
-
Object
- Object
- Heidi::Integrator
- Defined in:
- lib/heidi/integrator.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #failure ⇒ Object
-
#initialize(project) ⇒ Integrator
constructor
A new instance of Integrator.
- #integrate ⇒ Object
- #run_hooks(where) ⇒ Object
- #success ⇒ Object
Constructor Details
#initialize(project) ⇒ Integrator
Returns a new instance of Integrator.
10 11 12 13 14 15 |
# File 'lib/heidi/integrator.rb', line 10 def initialize(project) @project = project @build = Heidi::Build.new(project) @failed = false @hooks_ran = [] end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
8 9 10 |
# File 'lib/heidi/integrator.rb', line 8 def build @build end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/heidi/integrator.rb', line 8 def project @project end |
Instance Method Details
#failure ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/heidi/integrator.rb', line 17 def failure @failed = true run_hooks(:failure) build.log :info, ("Integration failed after: %.2fs" % (Time.now - @start)) build.record(:failure) return false end |
#integrate ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/heidi/integrator.rb', line 35 def integrate build.load_hooks return "no test hooks!" if build.hooks[:tests].empty? build.lock @start = Time.now build.clean return failure if !run_hooks(:before) # have a builder build the build dir builder = Heidi::Builder.new(build) return failure if !builder.build! return failure if !run_hooks(:build) # have a tester test the build tester = Heidi::Tester.new(self) return failure if !tester.test! # and run the success hooks return failure if !run_hooks(:success) # create a tarball builder.create_tar_ball return success rescue Exception => e build.log(:error, e.) build.log(:error, e.backtrace.join("\n")) return e. ensure run_hooks(:failure) if @failed == true run_hooks(:after) # always unlock the build root, no matter what build.unlock end |
#run_hooks(where) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/heidi/integrator.rb', line 78 def run_hooks(where) build.load_hooks if build.hooks.nil? || build.hooks.empty? return true if @hooks_ran.include?(where) return true if build.hooks[where].nil? || build.hooks[where].empty? hooks_failed = false build.hooks[where].each do |hook| start = Time.now build.log :info, "Running #{hook.name} :" hook.perform if hook.failed? build.log :info, "\tfailed. See heidi.error" build.log :error, "--- #{hook.name}: failed ---" build.log :error, hook., true hooks_failed = true break else build.log :info, "#{hook.output.lines.collect { |l| "\t#{l}" }.join("")}", true end build.log(:info, ("Took %.2fs" % (Time.now-start))) end @hooks_ran << where return hooks_failed == true ? false : true end |
#success ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/heidi/integrator.rb', line 27 def success # record the new succesful build.record(:success) build.log :info, ("Integration took: %.2fs" % (Time.now - @start)) return true end |