Class: MSpec::Opal::Index

Inherits:
Object show all
Defined in:
opal/lib/mspec/opal/rake_task.rb

Constant Summary

HTML =
<<-HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Opal Specs</title>
  </head>
  <body>
    <script src="/mspec/opal/main.js"></script>
    <script>Opal.load('mspec/opal/main');</script>
  </body>
</html>
HTML

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Index

Returns a new instance of Index



234
235
236
# File 'opal/lib/mspec/opal/rake_task.rb', line 234

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



238
239
240
241
242
243
244
# File 'opal/lib/mspec/opal/rake_task.rb', line 238

def call(env)
  if %w[/ /index.html].include? env['PATH_INFO']
    [200, { 'Content-Type' => 'text/html' }, [HTML]]
  else
    @app.call env
  end
end