Class: Superbara::Web
- Inherits:
-
Object
- Object
- Superbara::Web
- Defined in:
- lib/superbara/web.rb
Instance Method Summary collapse
-
#initialize(access_log: true, server_bind: '127.0.0.1', port: 4567) ⇒ Web
constructor
A new instance of Web.
- #run! ⇒ Object
- #run_async! ⇒ Object
Constructor Details
#initialize(access_log: true, server_bind: '127.0.0.1', port: 4567) ⇒ Web
Returns a new instance of Web.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/superbara/web.rb', line 4 def initialize(access_log: true, server_bind: '127.0.0.1', port: 4567) @webapp = Sinatra.new do root_path = File.join(File.dirname(__FILE__), "..", "..", "web") unless access_log set :server_settings, :AccessLog=>[] end set :bind, server_bind set :root, root_path set :port, port get '/' do File.read(File.join(root_path,"public", "index.html")) end get '/__superbara/:feature' do erb params[:feature].to_sym end end end |
Instance Method Details
#run! ⇒ Object
26 27 28 |
# File 'lib/superbara/web.rb', line 26 def run! @webapp.run! end |
#run_async! ⇒ Object
30 31 32 33 34 |
# File 'lib/superbara/web.rb', line 30 def run_async! Thread.new do self.run! end end |