Class: Wedge::Opal::Server
Defined Under Namespace
Classes: Headers
Instance Attribute Summary collapse
-
#gzip ⇒ Object
Returns the value of attribute gzip.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #create_app ⇒ Object
-
#initialize(debug_or_options = {}) {|_self| ... } ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(debug_or_options = {}) {|_self| ... } ⇒ Server
Returns a new instance of Server.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wedge/opal.rb', line 14 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 @headers = {} @gzip = false @use_index = true @public_root = nil @public_urls = ['/'] @sprockets = .fetch(:sprockets, ::Sprockets::Environment.new) @debug = .fetch(:debug, true) @prefix = .fetch(:prefix, '/assets') Opal.paths.each { |p| @sprockets.append_path(p) } yield self if block_given? create_app end |
Instance Attribute Details
#gzip ⇒ Object
Returns the value of attribute gzip.
12 13 14 |
# File 'lib/wedge/opal.rb', line 12 def gzip @gzip end |
#headers ⇒ Object
Returns the value of attribute headers.
12 13 14 |
# File 'lib/wedge/opal.rb', line 12 def headers @headers end |
Instance Method Details
#create_app ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wedge/opal.rb', line 38 def create_app server, sprockets, prefix, headers = self, @sprockets, self.prefix, @headers sprockets.logger.level ||= Logger::DEBUG source_map_enabled = self.source_map_enabled if source_map_enabled maps_prefix = SOURCE_MAPS_PREFIX_PATH maps_app = SourceMapServer.new(sprockets, maps_prefix) ::Opal::Sprockets::SourceMapHeaderPatch.inject!(maps_prefix) end @app = Rack::Builder.app do not_found = lambda { |env| [404, {}, []] } use Rack::Deflater use Rack::ShowExceptions use Index, server if server.use_index use Headers, server if source_map_enabled map(maps_prefix) do require 'rack/conditionalget' require 'rack/etag' use Rack::ConditionalGet use Rack::ETag run maps_app end end map(prefix) { run sprockets } run Rack::Static.new(not_found, root: server.public_root, urls: server.public_urls) end end |