Class: Integrity::Project
- Includes:
- DataMapper::Resource
- Defined in:
- lib/integrity/project.rb
Instance Method Summary collapse
- #build(commit_identifier = "HEAD") ⇒ Object
- #config_for(notifier) ⇒ Object
- #enable_notifiers(*args) ⇒ Object
- #last_build ⇒ Object
- #notifies?(notifier) ⇒ Boolean
- #previous_builds ⇒ Object
- #public=(flag) ⇒ Object
- #send_notifications ⇒ Object
- #status ⇒ Object
Instance Method Details
#build(commit_identifier = "HEAD") ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/integrity/project.rb', line 24 def build(commit_identifier="HEAD") return if building? update_attributes(:building => true) Thread.new(self) do |project| begin Builder.new(project).build(commit_identifier) ensure project.update_attributes(:building => false) project.send_notifications end end end |
#config_for(notifier) ⇒ Object
54 55 56 57 |
# File 'lib/integrity/project.rb', line 54 def config_for(notifier) notifier = notifiers.first(:name => notifier.to_s.split(/::/).last) notifier.blank? ? {} : notifier.config end |
#enable_notifiers(*args) ⇒ Object
63 64 65 |
# File 'lib/integrity/project.rb', line 63 def enable_notifiers(*args) Notifier.enable_notifiers(id, *args) end |
#last_build ⇒ Object
37 38 39 |
# File 'lib/integrity/project.rb', line 37 def last_build builds.last end |
#notifies?(notifier) ⇒ Boolean
59 60 61 |
# File 'lib/integrity/project.rb', line 59 def notifies?(notifier) !notifiers.first(:name => notifier.to_s.split(/::/).last).blank? end |
#previous_builds ⇒ Object
41 42 43 44 |
# File 'lib/integrity/project.rb', line 41 def previous_builds return [] if builds.count <= 1 builds.all(:order => [:created_at.desc], :offset => 1, :limit => builds.count - 1) end |
#public=(flag) ⇒ Object
50 51 52 |
# File 'lib/integrity/project.rb', line 50 def public=(flag) attribute_set(:public, !!flag) end |
#send_notifications ⇒ Object
67 68 69 70 71 |
# File 'lib/integrity/project.rb', line 67 def send_notifications notifiers.each do |notifier| notifier.notify_of_build last_build end end |
#status ⇒ Object
46 47 48 |
# File 'lib/integrity/project.rb', line 46 def status last_build && last_build.status end |