Sha256: 4d180b1e86b1dada2e1767d2ffcd6c59c42cab4047180782067168eb61237728

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

module Sinatra::WebSocketIO

  helpers do
    def websocketio_js
      "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['SCRIPT_NAME']}/websocketio/websocketio.js"
    end

    def websocketio_url
      "ws://#{env['SERVER_NAME']}:#{WebSocketIO.port}"
    end
  end

  get '/websocketio/websocketio.js' do
    content_type 'application/javascript'
    @js ||= (
             js = ''
             Dir.glob(File.expand_path '../js/*.js', File.dirname(__FILE__)).each do |i|
               File.open(i) do |f|
                 js += f.read
               end
             end
             ERB.new(js).result(binding)
             )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-websocketio-0.0.1 lib/sinatra-websocketio/application.rb