Class: Ruku::Clients::Web
- Inherits:
-
Object
- Object
- Ruku::Clients::Web
- Defined in:
- lib/ruku/clients/web.rb
Defined Under Namespace
Classes: AjaxServlet
Constant Summary collapse
- DEFAULT_PORT =
3030
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#handle_options ⇒ Object
Parse and handle command line options.
-
#initialize(opts = {}) ⇒ Web
constructor
A new instance of Web.
- #start ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Web
Returns a new instance of Web.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruku/clients/web.rb', line 15 def initialize(opts={}) @options = OpenStruct.new(opts) if .install require File.join(File.dirname(__FILE__), 'web', 'installer') WebInstaller.install(.port || DEFAULT_PORT) exit end = { :Port => .port || DEFAULT_PORT, :DocumentRoot => File.join(File.dirname(__FILE__), 'web', 'static') } @server = HTTPServer.new() ['INT', 'TERM'].each do |signal| trap(signal) { @server.shutdown } end @server.mount("/ajax", AjaxServlet) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/ruku/clients/web.rb', line 13 def @options end |
Instance Method Details
#handle_options ⇒ Object
Parse and handle command line options
43 44 45 46 47 48 49 |
# File 'lib/ruku/clients/web.rb', line 43 def OptionParser.new do |opts| opts.on('-p', '--port PORT') {|p| .port = p.to_i } opts.on('--install') { .install = true } opts.on('--web') { } # ignore end.parse! end |
#start ⇒ Object
38 39 40 |
# File 'lib/ruku/clients/web.rb', line 38 def start @server.start end |