Class: Adsf::Server
- Inherits:
-
Object
- Object
- Adsf::Server
- Defined in:
- lib/adsf/server.rb
Instance Method Summary collapse
-
#initialize(root:, live: false, host: '127.0.0.1', port: 3000, index_filenames: ['index.html'], auto_extensions: [], handler: nil) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(root:, live: false, host: '127.0.0.1', port: 3000, index_filenames: ['index.html'], auto_extensions: [], handler: nil) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/adsf/server.rb', line 5 def initialize( root:, live: false, host: '127.0.0.1', port: 3000, index_filenames: ['index.html'], auto_extensions: [], handler: nil ) @root = root @live = live @index_filenames = index_filenames @auto_extensions = auto_extensions @host = host @port = port @handler = handler @q = SizedQueue.new(1) end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/adsf/server.rb', line 25 def run handler = build_handler app = build_app( root: @root, index_filenames: @index_filenames, auto_extensions: @auto_extensions, ) start_watcher if @live url = "http://#{@host}:#{@port}/" puts "View the site at #{url}" handler.run(app, Host: @host, Port: @port) do |server| wait_for_stop_async(server) end end |
#stop ⇒ Object
42 43 44 |
# File 'lib/adsf/server.rb', line 42 def stop @q << true end |