Permalink
Browse files

Add an unregister command.

* Optimize the register and unregister calls to only shell out once instead of
  for every application configured.
  • Loading branch information...
1 parent f8c38b8 commit 5a379a3432d34002336d8c13b5512fd3d2ca7d3e @Manfred Manfred committed Aug 25, 2011
Showing with 35 additions and 6 deletions.
  1. +6 −0 .kick
  2. +16 −3 lib/passenger_pane/runner.rb
  3. +13 −3 test/ppane/runner_test.rb
View
6 .kick
@@ -19,6 +19,12 @@ process do |files|
case file
when %r{^test/ppane/test_helper/add_allow_switch.rb$}
'test/ppane/test_helper/add_allow_switch_test.rb'
+ when %r{^lib/(.*).rb$}
+ testfile = "test/ppane/#{File.basename($1)}_test.rb"
+ if File.exist?(testfile)
+ files.delete(file)
+ testfile
+ end
end
end)
@@ -95,18 +95,29 @@ def restart(host)
end
end
- def register
- @configuration.applications.each do |app|
- app.register
+ def _all_hosts
+ @configuration.applications.inject([]) do |hosts, application|
+ hosts.concat application.to_hash['hosts']
end
end
+ def register
+ PassengerPane::DirectoryServices.register(_all_hosts)
+ PassengerPane::DirectoryServices.write_to_hosts_file_if_broken
+ end
+
+ def unregister
+ PassengerPane::DirectoryServices.unregister(_all_hosts)
+ PassengerPane::DirectoryServices.write_to_hosts_file_if_broken
+ end
+
def self.usage
puts "Usage: #{File.basename($0)} <command> [options] [attributes]"
puts
puts "Commands:"
puts " list List all configured applications"
puts " register Register all configured hostnames with Directory Services*"
+ puts " unregister Unregister all configured hostnames with Directory Services*"
puts " info Show information about the system"
puts " configure Configure Apache for use with the Passenger Pane*"
puts " add <directory> Add an application in a directory*"
@@ -163,6 +174,8 @@ def self.run(flags, args)
new(options).list
when 'register'
new(options).register
+ when 'unregister'
+ new(options).unregister
else
path = trust(File.expand_path(command))
if File.exist?(path)
View
@@ -25,14 +25,24 @@
end
it "registers all configured hostnames" do
- @conf.applications.each do |app|
- PassengerPane::DirectoryServices.expects(:register).with(app.to_hash['hosts'])
- end
+ all_hosts = %w(assets.skit.local skit.local weblog.local)
+ PassengerPane::Runner.any_instance.stubs(:_all_hosts).returns(all_hosts)
+ PassengerPane::DirectoryServices.expects(:register).with(all_hosts)
capture_stdout do
PassengerPane::Runner.run({}, %w(register))
end
end
+ it "unregisters all configured hostnames" do
+
+ all_hosts = %w(assets.skit.local skit.local weblog.local)
+ PassengerPane::Runner.any_instance.stubs(:_all_hosts).returns(all_hosts)
+ PassengerPane::DirectoryServices.expects(:unregister).with(all_hosts)
+ capture_stdout do
+ PassengerPane::Runner.run({}, %w(unregister))
+ end
+ end
+
it "shows information about the system" do
@conf.httpd.stubs(:passenger_module_installed?).returns(true)
PassengerPane::DirectoryServices.stubs(:registered_hosts).returns(%w(assets.skit.local skit.local weblog.local))

0 comments on commit 5a379a3

Please sign in to comment.