Class: WSOC::Runner
- Inherits:
-
Object
- Object
- WSOC::Runner
- Defined in:
- lib/wsoc/runner.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Host to run the WSOC server on.
-
#port ⇒ Object
readonly
Port to run the WSOC server on.
Class Method Summary collapse
-
.start(args = ARGV) ⇒ Object
Starts the runner.
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
Creates a new runner.
-
#optparse(*args) ⇒ Object
protected
Parses the given arguments.
-
#run(*args) ⇒ Object
Runs the runner.
Constructor Details
#initialize ⇒ Runner
Creates a new runner.
40 41 42 43 44 |
# File 'lib/wsoc/runner.rb', line 40 def initialize @host = Config::DEFAULT_HOST @port = Config::DEFAULT_PORT @handler = nil end |
Instance Attribute Details
#host ⇒ Object (readonly)
Host to run the WSOC server on
30 31 32 |
# File 'lib/wsoc/runner.rb', line 30 def host @host end |
#port ⇒ Object (readonly)
Port to run the WSOC server on
33 34 35 |
# File 'lib/wsoc/runner.rb', line 33 def port @port end |
Class Method Details
.start(args = ARGV) ⇒ Object
Starts the runner.
54 55 56 57 |
# File 'lib/wsoc/runner.rb', line 54 def Runner.start(args=ARGV) runner = self.new() runner.run(*args) end |
Instance Method Details
#optparse(*args) ⇒ Object (protected)
Parses the given arguments.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/wsoc/runner.rb', line 91 def optparse(*args) opts = OptionParser.new opts. = "usage: #{$0} [options]" opts.on('-H','--host HOST',"The host to run the server on","Default: #{@host}") do |host| @host = host end opts.on('-p','--port PORT',"The port to run the server on","Default: #{@port}") do |port| @port = port.to_i end opts.on('--s','--server NAME','Rack handler to run the server under') do |handler| @handler = handler end opts.on('-h','--help','Display the help output') do puts opts exit end begin opts.parse!(args) rescue OptionParser::InvalidOption => e STDERR.puts e. STDERR.puts opts exit -1 end end |
#run(*args) ⇒ Object
Runs the runner.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/wsoc/runner.rb', line 67 def run(*args) optparse(*args) = { :env => :production, :host => @host, :port => @port } .merge!(:server => @handler) if @handler App.run!() end |