nyny 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +18 -3
- data/Performance.md +34 -63
- data/README.md +130 -76
- data/benchmark.rb +95 -0
- data/lib/nyny.rb +17 -1
- data/lib/nyny/app.rb +7 -3
- data/lib/nyny/core-ext/runner.rb +2 -1
- data/lib/nyny/{route_signature.rb → route.rb} +13 -8
- data/lib/nyny/router.rb +10 -18
- data/lib/nyny/version.rb +1 -1
- data/nyny.gemspec +1 -1
- data/spec/app_spec.rb +28 -3
- data/spec/nyny_spec.rb +11 -0
- data/spec/runner_spec.rb +6 -0
- data/spec/spec_helper.rb +1 -0
- metadata +6 -36
- data/benchmarks/filters/nyny.rb +0 -18
- data/benchmarks/filters/sinatra.rb +0 -17
- data/benchmarks/helpers/nyny.rb +0 -19
- data/benchmarks/helpers/sinatra.rb +0 -18
- data/benchmarks/simple/nyny.rb +0 -10
- data/benchmarks/simple/sinatra.rb +0 -9
- data/benchmarks/url_pattern/nyny.rb +0 -10
- data/benchmarks/url_pattern/sinatra.rb +0 -8
- data/examples/active_record/.gitignore +0 -1
- data/examples/active_record/Gemfile +0 -15
- data/examples/active_record/Rakefile +0 -51
- data/examples/active_record/config/database.yml +0 -0
- data/examples/active_record/database.rb +0 -13
- data/examples/active_record/db/migrate/20130606133756_add_shouts.rb +0 -12
- data/examples/active_record/models/shout.rb +0 -3
- data/examples/active_record/server.rb +0 -43
- data/examples/data_mapper/Gemfile +0 -7
- data/examples/data_mapper/database.rb +0 -7
- data/examples/data_mapper/db/.gitignore +0 -1
- data/examples/data_mapper/models/shout.rb +0 -7
- data/examples/data_mapper/server.rb +0 -41
- data/examples/json_api.rb +0 -21
- data/examples/templates/server.rb +0 -28
- data/examples/templates/views/index.haml +0 -1
- data/examples/web_sockets/Gemfile +0 -4
- data/examples/web_sockets/public/FABridge.js +0 -604
- data/examples/web_sockets/public/WebSocketMain.swf +0 -0
- data/examples/web_sockets/public/index.html +0 -76
- data/examples/web_sockets/public/swfobject.js +0 -4
- data/examples/web_sockets/public/web_socket.js +0 -388
- data/examples/web_sockets/server.rb +0 -60
- data/spec/route_signature_spec.rb +0 -9
@@ -1,60 +0,0 @@
|
|
1
|
-
#!ruby -I ../../lib -I lib
|
2
|
-
require 'nyny'
|
3
|
-
require 'faye/websocket'
|
4
|
-
|
5
|
-
#
|
6
|
-
# Open localhost:9000/public/index.html in the browser
|
7
|
-
#
|
8
|
-
|
9
|
-
Faye::WebSocket.load_adapter('thin')
|
10
|
-
|
11
|
-
class WebSockets
|
12
|
-
def initialize app=nil, opts={}, &blk
|
13
|
-
@app = app
|
14
|
-
@path = opts.fetch :path, '/'
|
15
|
-
@blk = blk
|
16
|
-
end
|
17
|
-
|
18
|
-
def call env
|
19
|
-
return @app.call(env) unless env['PATH_INFO'] == @path
|
20
|
-
|
21
|
-
if Faye::WebSocket.websocket?(env)
|
22
|
-
ws = Faye::WebSocket.new(env)
|
23
|
-
|
24
|
-
if @blk
|
25
|
-
Proc.new(&@blk).call ws
|
26
|
-
else
|
27
|
-
handle ws
|
28
|
-
end
|
29
|
-
|
30
|
-
ws.rack_response
|
31
|
-
else
|
32
|
-
@app.call(env)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def handle ws
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class App < NYNY::App
|
41
|
-
#Serve static assets from public folder
|
42
|
-
use Rack::Static, :urls => ["/public"]
|
43
|
-
|
44
|
-
use WebSockets, :path => '/websocket' do |ws|
|
45
|
-
ws.on :message do |event|
|
46
|
-
ws.send(event.data)
|
47
|
-
end
|
48
|
-
|
49
|
-
ws.on :close do |event|
|
50
|
-
p [:close, event.code, event.reason]
|
51
|
-
ws = nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
get '/nyny' do
|
56
|
-
'yep, you can still use nyny'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
App.run! 9000
|