Class: Juici::Build
- Inherits:
-
Object
- Object
- Juici::Build
- Includes:
- BuildLogic, Mongoid::Document
- Defined in:
- lib/juici/models/build.rb
Instance Method Summary collapse
- #build! ⇒ Object
- #display_title ⇒ Object
- #failure! ⇒ Object
- #finish ⇒ Object
- #get_output ⇒ Object
-
#heading_color ⇒ Object
View helpers.
- #process_callbacks ⇒ Object
- #set_status(value) ⇒ Object
- #start! ⇒ Object
- #success! ⇒ Object
- #to_callback_json ⇒ Object
- #warn!(msg) ⇒ Object
- #worktree ⇒ Object
Methods included from BuildLogic
Instance Method Details
#build! ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/juici/models/build.rb', line 62 def build! case pid = spawn_build when Fixnum start! Juici.dbgp "#{pid} away!" self[:pid] = pid self[:buffer] = @buffer.path save! return pid when :enoent warn! "No such command" failure! when :invalidcommand warn! "Invalid command" failure! end nil end |
#display_title ⇒ Object
107 108 109 110 |
# File 'lib/juici/models/build.rb', line 107 def display_title # Catch old builds which didn't have a title self[:title] || self[:create_time] end |
#failure! ⇒ Object
50 51 52 53 54 |
# File 'lib/juici/models/build.rb', line 50 def failure! finish set_status :failed process_callbacks end |
#finish ⇒ Object
56 57 58 59 60 |
# File 'lib/juici/models/build.rb', line 56 def finish self[:end_time] = Time.now self[:output] = get_output $build_queue.purge(:pid, self) end |
#get_output ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/juici/models/build.rb', line 99 def get_output return "" unless self[:buffer] File.open(self[:buffer], 'r') do |f| f.rewind f.read end end |
#heading_color ⇒ Object
View helpers
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/juici/models/build.rb', line 86 def heading_color case status when :waiting "build-heading-pending" when :failed "build-heading-failed" when :success "build-heading-success" when :started "build-heading-started" end end |
#process_callbacks ⇒ Object
117 118 119 120 121 |
# File 'lib/juici/models/build.rb', line 117 def process_callbacks self[:callbacks].each do |callback_url| Callback.new(self, callback_url).process! end end |
#set_status(value) ⇒ Object
34 35 36 37 |
# File 'lib/juici/models/build.rb', line 34 def set_status(value) self[:status] = value save! end |
#start! ⇒ Object
39 40 41 42 |
# File 'lib/juici/models/build.rb', line 39 def start! self[:start_time] = Time.now set_status :started end |
#success! ⇒ Object
44 45 46 47 48 |
# File 'lib/juici/models/build.rb', line 44 def success! finish set_status :success process_callbacks end |
#to_callback_json ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/juici/models/build.rb', line 124 def to_callback_json { "project" => self[:parent], "status" => self[:status], "url" => build_url_for(self) }.to_json end |
#warn!(msg) ⇒ Object
112 113 114 115 |
# File 'lib/juici/models/build.rb', line 112 def warn!(msg) warnings << msg save! end |