Class: Pieces::Server
- Inherits:
-
Rack::Server
- Object
- Rack::Server
- Pieces::Server
- Defined in:
- lib/pieces/server.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #app ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
8 9 10 11 |
# File 'lib/pieces/server.rb', line 8 def initialize( = {}) @path = [:path] || Dir.pwd super end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/pieces/server.rb', line 6 def path @path end |
Instance Method Details
#app ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pieces/server.rb', line 18 def app files = files_to_serve(path) build_path = "#{path}/build" Rack::Builder.app do use Rack::Reloader use Rack::Static, urls: files, root: build_path, index: 'index.html' run Proc.new { |env| [404, {}, ['Not found']] } end end |