summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-15 12:04:30 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-15 12:04:30 -0500
commitec71e05a162ec299982b90707cc16231c608997b (patch)
treec16376f369f5ad880b17f47888c9cea33a9008bb /lib/puppet/network
parent31384fea2263d9ee0e65312b4a0b956436022e63 (diff)
downloadpuppet-ec71e05a162ec299982b90707cc16231c608997b.tar.gz
puppet-ec71e05a162ec299982b90707cc16231c608997b.tar.xz
puppet-ec71e05a162ec299982b90707cc16231c608997b.zip
More unit specs for mongrel and webrick; more code to make them work, yo.
Diffstat (limited to 'lib/puppet/network')
-rw-r--r--lib/puppet/network/http.rb4
-rw-r--r--lib/puppet/network/http/mongrel.rb19
-rw-r--r--lib/puppet/network/http/webrick.rb21
3 files changed, 41 insertions, 3 deletions
diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb
index 86784e50e..5dddad848 100644
--- a/lib/puppet/network/http.rb
+++ b/lib/puppet/network/http.rb
@@ -1,7 +1,7 @@
class Puppet::Network::HTTP
def self.server_class_by_type(kind)
- return Puppet::Network::HTTP::WEBRick if kind == :webrick
- return Puppet::Network::HTTP::Mongrel if kind == :mongrel
+ return Puppet::Network::HTTP::WEBRick if kind.to_sym == :webrick
+ return Puppet::Network::HTTP::Mongrel if kind.to_sym == :mongrel
raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
end
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb
index dda3c1751..dbdd72d42 100644
--- a/lib/puppet/network/http/mongrel.rb
+++ b/lib/puppet/network/http/mongrel.rb
@@ -1,2 +1,21 @@
+require 'mongrel'
+
class Puppet::Network::HTTP::Mongrel
+ def initialize(args = {})
+ @listening = false
+ end
+
+ def listen(args = {})
+ raise ArgumentError if args.keys.empty?
+ raise "Mongrel server is already listening" if @listening
+ @server = Mongrel::HttpServer.new("0.0.0.0", "3000")
+ @server.run
+ @listening = true
+ end
+
+ def unlisten
+ raise "Mongrel server is not listening" unless @listening
+ @server.graceful_shutdown
+ @listening = false
+ end
end
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index ad15261f6..77e55a224 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -1,2 +1,21 @@
-class Puppet::Network::HTTP::WEBRick
+require 'webrick'
+require 'webrick/https'
+
+class Puppet::Network::HTTP::WEBRick < WEBrick::HTTPServer
+ def initialize(args = {})
+ @listening = false
+ end
+
+ def listen(args = {})
+ raise ArgumentError if args.keys.empty?
+ raise "WEBRick server is already listening" if @listening
+ # TODO / FIXME: this should be moved out of the wacky Puppet global namespace!
+ Puppet.start
+ @listening = true
+ end
+
+ def unlisten
+ raise "WEBRick server is not listening" unless @listening
+ shutdown
+ end
end