Class: Integrity::Project

Inherits:
Object show all
Includes:
DataMapper::Resource
Defined in:
lib/integrity/project.rb

Instance Method Summary collapse

Instance Method Details

#build(commit_identifier = "HEAD") ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/integrity/project.rb', line 24

def build(commit_identifier="HEAD")
  return if building?
  update_attributes(:building => true)
  Builder.new(self).build(commit_identifier)
ensure
  update_attributes(:building => false)
  send_notifications
end

#config_for(notifier) ⇒ Object



51
52
53
54
# File 'lib/integrity/project.rb', line 51

def config_for(notifier)
  notifier = notifiers.first(:name => notifier.to_s.split(/::/).last)
  notifier.blank? ? {} : notifier.config
end

#enable_notifiers(*args) ⇒ Object



60
61
62
# File 'lib/integrity/project.rb', line 60

def enable_notifiers(*args)
  Notifier.enable_notifiers(id, *args)
end

#last_buildObject



33
34
35
# File 'lib/integrity/project.rb', line 33

def last_build
  builds.last
end

#notifies?(notifier) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/integrity/project.rb', line 56

def notifies?(notifier)
  !notifiers.first(:name => notifier.to_s.split(/::/).last).blank?
end

#previous_buildsObject



37
38
39
40
41
# File 'lib/integrity/project.rb', line 37

def previous_builds
  builds.all(:order => [:created_at.desc]).tap do |builds|
    builds.shift
  end
end

#public=(flag) ⇒ Object



47
48
49
# File 'lib/integrity/project.rb', line 47

def public=(flag)
  attribute_set(:public, !!flag)
end

#statusObject



43
44
45
# File 'lib/integrity/project.rb', line 43

def status
  last_build && last_build.status
end