[macruby-changes] [4541] MacRuby/trunk/sample-macruby/Scripts/webrick.rb
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 27 04:39:06 PDT 2010
Revision: 4541
http://trac.macosforge.org/projects/ruby/changeset/4541
Author: watson1978 at gmail.com
Date: 2010-09-27 04:39:02 -0700 (Mon, 27 Sep 2010)
Log Message:
-----------
Added the exsample that use WEBrick and Bonjour.
Added Paths:
-----------
MacRuby/trunk/sample-macruby/Scripts/webrick.rb
Added: MacRuby/trunk/sample-macruby/Scripts/webrick.rb
===================================================================
--- MacRuby/trunk/sample-macruby/Scripts/webrick.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/Scripts/webrick.rb 2010-09-27 11:39:02 UTC (rev 4541)
@@ -0,0 +1,22 @@
+#!/usr/local/bin/macruby
+# -*- coding: utf-8 -*-
+# This script is sample of WEBrick and Bonjour.
+# You could look for this server using Bonjour on Safari.
+framework "Foundation"
+require "webrick"
+
+DOC_ROOT = "."
+SERVER_PORT = 8000
+SERVER_NAME = "webrick"
+
+s = WEBrick::HTTPServer.new(
+ :Port => SERVER_PORT,
+ :DocumentRoot => File.join(Dir::pwd, DOC_ROOT)
+)
+trap("INT") { s.shutdown }
+
+# Bonjour
+netservice = NSNetService.alloc.initWithDomain("", type:"_http._tcp", name:SERVER_NAME, port:SERVER_PORT)
+netservice.publish()
+
+s.start
Property changes on: MacRuby/trunk/sample-macruby/Scripts/webrick.rb
___________________________________________________________________
Added: svn:executable
+ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100927/cbd658b5/attachment-0001.html>
More information about the macruby-changes
mailing list