This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project#notify raises an exception if you try to notify plugins of an…
… event that hasn't been documented in BuilderPlugin. Not coincidentally, BuilderPlugin now provides documentation and an interface for all event callbacks.
- Loading branch information
Showing
4 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,91 @@ | ||
# BuilderPlugin is the superclass of all CC.rb plugins. It does not provide any functionality | ||
# except a basic initializer that accepts as an argument the current project. | ||
# | ||
# CC.rb plugins offer a rich notification system for tracking every aspect of the build lifecycle. In rough order, | ||
# they are: | ||
# | ||
# * polling_source_control | ||
# * no_new_revisions_detected OR new_revisions_detected(revisions) | ||
# * build_requested | ||
# * queued | ||
# * timed_out | ||
# * build_initiated | ||
# * configuration_modified | ||
# * build_started | ||
# * build_finished | ||
# * build_broken OR build_fixed | ||
# * build_loop_failed | ||
# * sleeping | ||
class BuilderPlugin | ||
attr_reader :project | ||
|
||
def initialize(project) | ||
@project = project | ||
end | ||
|
||
class << self | ||
def known_event?(event_name) | ||
self.instance_methods(false).include? event_name.to_s | ||
end | ||
end | ||
|
||
# Called by ChangeInSourceControlTrigger to indicate that it is about to poll source control. | ||
def polling_source_control | ||
end | ||
|
||
# Called by ChangeInSourceControlTrigger to indicate that no new revisions have been detected. | ||
def no_new_revisions_detected | ||
end | ||
|
||
# Called by ChangeInSourceControlTrigger to indicate that new revisions were detected. | ||
def new_revisions_detected(revisions) | ||
end | ||
|
||
# Called by Project to indicate that a build has explicitly been requested by the user. | ||
def build_requested | ||
end | ||
|
||
# Called by BuildSerializer if it another build is still running and it cannot acquire the build serialization lock. | ||
# It will retry until it times out. Occurs only if build serialization is enabled in your CC.rb configuration. | ||
def queued | ||
end | ||
|
||
# Called by BuildSerializer if it times out attempting to acquire the build serialization lock due to another build | ||
# still running. Occurs only if build serialization is enabled in your CC.rb configuration. | ||
def timed_out | ||
end | ||
|
||
# Called by Project at the start of a new build before any other build events. | ||
def build_initiated | ||
end | ||
|
||
# Called by Project at the start of a new build to indicate that the configuration has been modified, | ||
# after which the build is aborted. | ||
def configuration_modified | ||
end | ||
|
||
# Called by Project after some basic logging and the configuration_modified check and just before the build begins running, | ||
def build_started(build) | ||
end | ||
|
||
# Called by Project immediately after the build has finished running. | ||
def build_finished(build) | ||
end | ||
|
||
# Called by Project after the completion of a build if the previous build was successful and this one is a failure. | ||
def build_broken(build, previous_build) | ||
end | ||
|
||
# Called by Project after the completion of a build if the previous build was a failure and this one was successful. | ||
def build_fixed(build, previous_build) | ||
end | ||
|
||
# Called by Project if the build fails internally with a CC.rb exception. | ||
def build_loop_failed(exception) | ||
end | ||
|
||
# Called by Project at the end of a build to indicate that the build loop is once again sleeping. | ||
def sleeping | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper') | ||
|
||
class BuilderPluginTest < Test::Unit::TestCase | ||
|
||
def test_builder_plugin_should_maintain_list_of_known_events | ||
assert BuilderPlugin.known_event? :build_requested | ||
assert_false BuilderPlugin.known_event? :some_random_event | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters