Class: Integrity::Project
- Inherits:
-
Object
show all
- Includes:
- Bob::Buildable, DataMapper::Resource, Notifiers, Push
- Defined in:
- lib/integrity/project.rb,
lib/integrity/project/push.rb,
lib/integrity/project/notifiers.rb
Defined Under Namespace
Modules: Notifiers, Push
Instance Method Summary
collapse
Methods included from Notifiers
#config_for, #enabled_notifiers, #notifies?, #update_notifiers
Methods included from Push
#push
Instance Method Details
#building? ⇒ Boolean
62
63
64
|
# File 'lib/integrity/project.rb', line 62
def building?
commits.any? { |c| c.building? }
end
|
#finish_building(commit_id, status, output) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/integrity/project.rb', line 46
def finish_building(commit_id, status, output)
@build.update_attributes(
:successful => status, :output => output,
:completed_at => Time.now) if @build
enabled_notifiers.each { |notifier| notifier.notify_of_build(@build) }
end
|
#human_readable_status ⇒ Object
70
71
72
|
# File 'lib/integrity/project.rb', line 70
def human_readable_status
last_commit && last_commit.human_readable_status
end
|
33
34
35
|
# File 'lib/integrity/project.rb', line 33
def kind
:git
end
|
#last_commit ⇒ Object
53
54
55
|
# File 'lib/integrity/project.rb', line 53
def last_commit
commits.first(:project_id => id, :order => [:committed_at.desc])
end
|
#previous_commits ⇒ Object
57
58
59
60
|
# File 'lib/integrity/project.rb', line 57
def previous_commits
commits.all(:project_id => id, :order => [:committed_at.desc]).
tap {|commits| commits.shift }
end
|
#public=(flag) ⇒ Object
74
75
76
77
78
79
|
# File 'lib/integrity/project.rb', line 74
def public=(flag)
attribute_set(:public, case flag
when "1", "0" then flag == "1"
else !!flag
end)
end
|
#start_building(commit_id, commit_info) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/integrity/project.rb', line 39
def start_building(commit_id, commit_info)
@commit = commits.first_or_create({:identifier => commit_id},
commit_info.update(:project_id => id))
@build = Build.new(:started_at => Time.now)
@commit.update_attributes(:build => @build)
end
|
66
67
68
|
# File 'lib/integrity/project.rb', line 66
def status
last_commit ? last_commit.status : :blank
end
|