Class: Yeah::Web::Server
- Inherits:
-
Object
- Object
- Yeah::Web::Server
- Defined in:
- lib/yeah/web/server.rb
Overview
The Web::Server serves a game over the web. To serve a game, enter ‘yeah serve` in a command-line within a game project.
Defined Under Namespace
Classes: Runner
Instance Method Summary collapse
-
#serve(port = 1234) ⇒ nil
Serve game in working directory.
Instance Method Details
#serve(port = 1234) ⇒ nil
Serve game in working directory.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/yeah/web/server.rb', line 15 def serve(port = 1234) runner = Runner.new assets = Opal::Environment.new # Append standard library code paths. $LOAD_PATH.each { |p| assets.append_path(p) } # Append gem code paths. assets.append_path gem_path.join('lib') assets.append_path gem_path.join('opal') # Append game code and asset paths. assets.append_path 'assets' assets.append_path 'code' application = Rack::Builder.new do use Rack::Deflater map '/' do run runner end map '/assets' do run assets end end Rack::Server.start(app: application, Port: port) end |