class Notes::Server

Constants

SERVER_DEFAULTS

Public Class Methods

new(argv) click to toggle source
# File lib/notes-cli/server.rb, line 12
def initialize(argv)
  @options = SERVER_DEFAULTS.merge(parse_options(argv))
end

Public Instance Methods

parse_options(args) click to toggle source
# File lib/notes-cli/server.rb, line 16
def parse_options(args)
  options = {}
  OptionParser.new do |opts|
    opts.on('-p', '--port [PORT]', 'The port to run on') do |port|
      options[:Port] = port
    end
  end.parse!(args)

  options
end
start() click to toggle source
# File lib/notes-cli/server.rb, line 27
def start
  Rack::Handler::WEBrick.run(Notes::Web, @options) do |server|
      [:INT, :TERM].each { |sig| trap(sig) { server.stop } }
  end
end