Class: Integrity::Project
- Includes:
- DataMapper::Resource
- Defined in:
- lib/integrity/project.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build(commit_identifier = "HEAD") ⇒ Object
- #config_for(notifier) ⇒ Object
- #enable_notifiers(*args) ⇒ Object
- #human_readable_status ⇒ Object
- #last_build ⇒ Object
- #last_commit ⇒ Object
- #notifies?(notifier) ⇒ Boolean
- #previous_builds ⇒ Object
- #previous_commits ⇒ Object
- #public=(flag) ⇒ Object
- #push(payload) ⇒ Object
- #status ⇒ Object
Class Method Details
.only_public_unless(condition) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/integrity/project.rb', line 24 def self.only_public_unless(condition) if condition all else all(:public => true) end end |
Instance Method Details
#build(commit_identifier = "HEAD") ⇒ Object
32 33 34 35 36 |
# File 'lib/integrity/project.rb', line 32 def build(commit_identifier="HEAD") commit_identifier = head_of_remote_repo if commit_identifier == "HEAD" commit = find_or_create_commit_with_identifier(commit_identifier) commit.queue_build end |
#config_for(notifier) ⇒ Object
88 89 90 91 |
# File 'lib/integrity/project.rb', line 88 def config_for(notifier) notifier = notifiers.first(:name => notifier.to_s.split(/::/).last, :project_id => id) notifier.blank? ? {} : notifier.config end |
#enable_notifiers(*args) ⇒ Object
97 98 99 |
# File 'lib/integrity/project.rb', line 97 def enable_notifiers(*args) Notifier.enable_notifiers(id, *args) end |
#human_readable_status ⇒ Object
77 78 79 |
# File 'lib/integrity/project.rb', line 77 def human_readable_status last_commit && last_commit.human_readable_status end |
#last_build ⇒ Object
59 60 61 62 |
# File 'lib/integrity/project.rb', line 59 def last_build warn "Project#last_build is deprecated, use Project#last_commit" last_commit end |
#last_commit ⇒ Object
55 56 57 |
# File 'lib/integrity/project.rb', line 55 def last_commit commits.first(:project_id => id, :order => [:committed_at.desc]) end |
#notifies?(notifier) ⇒ Boolean
93 94 95 |
# File 'lib/integrity/project.rb', line 93 def notifies?(notifier) !notifiers.first(:name => notifier.to_s.split(/::/).last, :project_id => id).blank? end |
#previous_builds ⇒ Object
68 69 70 71 |
# File 'lib/integrity/project.rb', line 68 def previous_builds warn "Project#previous_builds is deprecated, use Project#previous_commits" previous_commits end |
#previous_commits ⇒ Object
64 65 66 |
# File 'lib/integrity/project.rb', line 64 def previous_commits commits.all(:project_id => id, :order => [:committed_at.desc]).tap {|commits| commits.shift } end |
#public=(flag) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/integrity/project.rb', line 81 def public=(flag) attribute_set(:public, case flag when "1", "0" then flag == "1" else !!flag end) end |
#push(payload) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/integrity/project.rb', line 38 def push(payload) payload = parse_payload(payload) raise ArgumentError unless valid_payload?(payload) commits = if Integrity.config[:build_all_commits] payload["commits"] else [ payload["commits"].first ] end commits.each do |commit_data| create_commit_from(commit_data) build(commit_data["id"]) end end |
#status ⇒ Object
73 74 75 |
# File 'lib/integrity/project.rb', line 73 def status last_commit && last_commit.status end |