Class: Integrity::Project
- Includes:
- DataMapper::Resource
- Defined in:
- lib/integrity/project.rb
Instance Method Summary collapse
- #build(commit_identifier = "HEAD") ⇒ Object
- #building? ⇒ Boolean
- #config_for(notifier) ⇒ Object
- #enable_notifiers(*args) ⇒ Object
- #last_build ⇒ Object
- #notifies?(notifier) ⇒ Boolean
- #previous_builds ⇒ Object
- #public=(flag) ⇒ Object
- #status ⇒ Object
Instance Method Details
#build(commit_identifier = "HEAD") ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/integrity/project.rb', line 26 def build(commit_identifier="HEAD") return if building? update_attributes(:started_build_at => Time.now) update_attributes(:current_commit_identifier => "unknown commit id") update_attributes(:shortened_current_commit_msg => "unknown msg") Thread.new(self) do |project| begin Builder.new(project).build(commit_identifier) ensure project.update_attributes(:started_build_at => nil) project.send_notifications end end end |
#building? ⇒ Boolean
41 42 43 |
# File 'lib/integrity/project.rb', line 41 def building? !started_build_at.nil? end |
#config_for(notifier) ⇒ Object
63 64 65 66 |
# File 'lib/integrity/project.rb', line 63 def config_for(notifier) notifier = notifiers.first(:name => notifier.to_s.split(/::/).last) notifier.blank? ? {} : notifier.config end |
#enable_notifiers(*args) ⇒ Object
72 73 74 |
# File 'lib/integrity/project.rb', line 72 def enable_notifiers(*args) Notifier.enable_notifiers(id, *args) end |
#last_build ⇒ Object
45 46 47 |
# File 'lib/integrity/project.rb', line 45 def last_build builds.last end |
#notifies?(notifier) ⇒ Boolean
68 69 70 |
# File 'lib/integrity/project.rb', line 68 def notifies?(notifier) !notifiers.first(:name => notifier.to_s.split(/::/).last).blank? end |
#previous_builds ⇒ Object
49 50 51 52 53 |
# File 'lib/integrity/project.rb', line 49 def previous_builds builds.all(:order => [:created_at.desc]).tap do |builds| builds.shift end end |
#public=(flag) ⇒ Object
59 60 61 |
# File 'lib/integrity/project.rb', line 59 def public=(flag) attribute_set(:public, !!flag) end |
#status ⇒ Object
55 56 57 |
# File 'lib/integrity/project.rb', line 55 def status last_build && last_build.status end |