Class: Opal::Server
Defined Under Namespace
Classes: Index
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#index_path ⇒ Object
Returns the value of attribute index_path.
-
#main ⇒ Object
Returns the value of attribute main.
-
#public_root ⇒ Object
Returns the value of attribute public_root.
-
#public_urls ⇒ Object
Returns the value of attribute public_urls.
-
#sprockets ⇒ Object
Returns the value of attribute sprockets.
-
#use_index ⇒ Object
Returns the value of attribute use_index.
Instance Method Summary collapse
- #append_path(path) ⇒ Object
- #call(env) ⇒ Object
- #create_app ⇒ Object
-
#initialize(debug_or_options = {}) {|_self| ... } ⇒ Server
constructor
A new instance of Server.
- #public_dir=(dir) ⇒ Object
- #source_map=(enabled) ⇒ Object
- #source_map_enabled ⇒ Object
- #source_maps ⇒ Object
- #use_gem(gem_name) ⇒ Object
Constructor Details
#initialize(debug_or_options = {}) {|_self| ... } ⇒ Server
Returns a new instance of Server
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'opal/lib/opal/sprockets/server.rb', line 48 def initialize = {} unless Hash === warn "passing a boolean to control debug is deprecated.\n"+ "Please pass an Hash instead: Server.new(debug: true)" = {:debug => } else = end @use_index = true @public_root = nil @public_urls = ['/'] @sprockets = Environment.new @debug = .fetch(:debug, true) yield self if block_given? create_app end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def debug @debug end |
#index_path ⇒ Object
Returns the value of attribute index_path
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def index_path @index_path end |
#main ⇒ Object
Returns the value of attribute main
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def main @main end |
#public_root ⇒ Object
Returns the value of attribute public_root
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def public_root @public_root end |
#public_urls ⇒ Object
Returns the value of attribute public_urls
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def public_urls @public_urls end |
#sprockets ⇒ Object
Returns the value of attribute sprockets
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def sprockets @sprockets end |
#use_index ⇒ Object
Returns the value of attribute use_index
46 47 48 |
# File 'opal/lib/opal/sprockets/server.rb', line 46 def use_index @use_index end |
Instance Method Details
#append_path(path) ⇒ Object
80 81 82 |
# File 'opal/lib/opal/sprockets/server.rb', line 80 def append_path path @sprockets.append_path path end |
#call(env) ⇒ Object
107 108 109 |
# File 'opal/lib/opal/sprockets/server.rb', line 107 def call(env) @app.call env end |
#create_app ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'opal/lib/opal/sprockets/server.rb', line 88 def create_app server, sprockets = self, @sprockets @app = Rack::Builder.app do not_found = lambda { |env| [404, {}, []] } use Rack::Deflater use Rack::ShowExceptions map('/assets') { run sprockets } map(server.source_maps.prefix) { run server.source_maps } if server.source_map_enabled use Index, server if server.use_index run Rack::Static.new(not_found, :root => server.public_root, :urls => server.public_urls) end end |
#public_dir=(dir) ⇒ Object
67 68 69 70 |
# File 'opal/lib/opal/sprockets/server.rb', line 67 def public_dir=(dir) @public_root = dir @public_urls = ["/"] end |
#source_map=(enabled) ⇒ Object
72 73 74 |
# File 'opal/lib/opal/sprockets/server.rb', line 72 def source_map=(enabled) Opal::Processor.source_map_enabled = enabled end |
#source_map_enabled ⇒ Object
76 77 78 |
# File 'opal/lib/opal/sprockets/server.rb', line 76 def source_map_enabled Opal::Processor.source_map_enabled end |
#source_maps ⇒ Object
103 104 105 |
# File 'opal/lib/opal/sprockets/server.rb', line 103 def source_maps @source_maps ||= SourceMapServer.new(@sprockets) end |
#use_gem(gem_name) ⇒ Object
84 85 86 |
# File 'opal/lib/opal/sprockets/server.rb', line 84 def use_gem gem_name @sprockets.use_gem gem_name end |