Sha256: fd38df38ca6427272d47e41298682715b419e9ad2f0a04675b0c24c166a2d3bf

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

module Inesita
  class Server
    def initialize(*args, &block)
      require 'rack/rewrite'
      server = server(*args, &block)
      @rack = Rack::Builder.new do
        use Rack::Static, urls: [Inesita::Config::STATIC_DIR]
        run server
      end

      Opal.append_path 'app'
      Inesita.assets_code = assets_code
    end

    def call(*args)
      @rack.call(*args)
    end

    def assets_code(path = 'application')
      @server.javascript_include_tag(path)
    end

    def server(*args, &block)
      @server = if block_given?
                  Opal::SimpleServer.new(*args, &block)
                else
                  Opal::SimpleServer.new(*args) do |server|
                    server.main = ::Inesita::Config::SERVER_MAIN
                    server.index_path = ::Inesita::Config::SERVER_INDEX_PATH
                  end
                end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inesita-1.0.pre.3 lib/inesita/server.rb
inesita-1.0.pre.2 lib/inesita/server.rb
inesita-1.0.pre.1 lib/inesita/server.rb