Class: XCB
- Inherits:
-
Object
- Object
- XCB
- Defined in:
- lib/xcb_command.rb
Instance Method Summary collapse
- #build ⇒ Object
- #clean ⇒ Object
-
#initialize(config) ⇒ XCB
constructor
A new instance of XCB.
- #start_building ⇒ Object
- #stop_building ⇒ Object
Constructor Details
#initialize(config) ⇒ XCB
Returns a new instance of XCB.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/xcb_command.rb', line 6 def initialize(config) @app_root = config[:app_root] || "." @poller_pid_file = config[:task] || ".xcb_poller.pid" @build = ExtremeContinuousBuilder::Build.new( :task_name => config[:task] || 'test', :application_root => @app_root ) @project_name = config[:app_name] || if File.basename(Dir.pwd) == "trunk" File.basename(File.dirname(Dir.pwd)) else File.basename(Dir.pwd) end @text_output_path = config[:text_file_path] || "build_result.txt" = { :application_name => @project_name, :growl_host => config[:growl_host] || "localhost", :growl_password => config[:growl_password], :text_file_path => @text_output_path, } ExtremeContinuousBuilder.notifiers.each do |notifier| notifier.setup() end end |
Instance Method Details
#build ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/xcb_command.rb', line 64 def build status = @build.run if [:failed, :revived, :broken, :succesful].include? status ExtremeContinuousBuilder.notifiers.each do |notifier| notifier.send(status, @build) if notifier.respond_to? status end status else raise "Unexpected build result: #{status.inspect}" end end |
#clean ⇒ Object
77 78 79 |
# File 'lib/xcb_command.rb', line 77 def clean @build.clean end |
#start_building ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xcb_command.rb', line 36 def start_building @monitor = DirectoryMonitor.new(@app_root, :ignore => @text_output_path) daemonize! File.open(@poller_pid_file, "w") {|f| f.write Process.pid } while pid_file_is_me? if @monitor.has_changes? build sleep 10 else sleep 1 end end end |
#stop_building ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/xcb_command.rb', line 53 def stop_building if read_pid_file.nil? :not_running else pid = read_pid_file Process.kill("TERM", pid) if pid delete_pid_file :stopped end end |