Class: Rack::OpalCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/opal/compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ OpalCompiler

Returns a new instance of OpalCompiler.



10
11
12
13
14
15
16
# File 'lib/rack/opal/compiler.rb', line 10

def initialize(app, options = {})
  @app = app
  @source_dir = options[:source_dir]
  @build_dir = options[:build_dir]
  @files = Dir["#{@source_dir}/**/*.rb"]
  @app_name = options[:app_name]
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rack/opal/compiler.rb', line 18

def call(env)
  status, headers, response = @app.call(env)
  if !headers['Content-Type'].nil? && headers['Content-Type'].match('text/html') then
    build
  end
  [status, headers, response]
end