summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/http
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/http
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/http')
-rw-r--r--lib/puppet/network/http/mongrel.rb19
-rw-r--r--lib/puppet/network/http/webrick.rb21
2 files changed, 39 insertions, 1 deletions
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