nyny 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +18 -3
  3. data/Performance.md +34 -63
  4. data/README.md +130 -76
  5. data/benchmark.rb +95 -0
  6. data/lib/nyny.rb +17 -1
  7. data/lib/nyny/app.rb +7 -3
  8. data/lib/nyny/core-ext/runner.rb +2 -1
  9. data/lib/nyny/{route_signature.rb → route.rb} +13 -8
  10. data/lib/nyny/router.rb +10 -18
  11. data/lib/nyny/version.rb +1 -1
  12. data/nyny.gemspec +1 -1
  13. data/spec/app_spec.rb +28 -3
  14. data/spec/nyny_spec.rb +11 -0
  15. data/spec/runner_spec.rb +6 -0
  16. data/spec/spec_helper.rb +1 -0
  17. metadata +6 -36
  18. data/benchmarks/filters/nyny.rb +0 -18
  19. data/benchmarks/filters/sinatra.rb +0 -17
  20. data/benchmarks/helpers/nyny.rb +0 -19
  21. data/benchmarks/helpers/sinatra.rb +0 -18
  22. data/benchmarks/simple/nyny.rb +0 -10
  23. data/benchmarks/simple/sinatra.rb +0 -9
  24. data/benchmarks/url_pattern/nyny.rb +0 -10
  25. data/benchmarks/url_pattern/sinatra.rb +0 -8
  26. data/examples/active_record/.gitignore +0 -1
  27. data/examples/active_record/Gemfile +0 -15
  28. data/examples/active_record/Rakefile +0 -51
  29. data/examples/active_record/config/database.yml +0 -0
  30. data/examples/active_record/database.rb +0 -13
  31. data/examples/active_record/db/migrate/20130606133756_add_shouts.rb +0 -12
  32. data/examples/active_record/models/shout.rb +0 -3
  33. data/examples/active_record/server.rb +0 -43
  34. data/examples/data_mapper/Gemfile +0 -7
  35. data/examples/data_mapper/database.rb +0 -7
  36. data/examples/data_mapper/db/.gitignore +0 -1
  37. data/examples/data_mapper/models/shout.rb +0 -7
  38. data/examples/data_mapper/server.rb +0 -41
  39. data/examples/json_api.rb +0 -21
  40. data/examples/templates/server.rb +0 -28
  41. data/examples/templates/views/index.haml +0 -1
  42. data/examples/web_sockets/Gemfile +0 -4
  43. data/examples/web_sockets/public/FABridge.js +0 -604
  44. data/examples/web_sockets/public/WebSocketMain.swf +0 -0
  45. data/examples/web_sockets/public/index.html +0 -76
  46. data/examples/web_sockets/public/swfobject.js +0 -4
  47. data/examples/web_sockets/public/web_socket.js +0 -388
  48. data/examples/web_sockets/server.rb +0 -60
  49. 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
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RouteSignature do
4
- it 'should have the initial regexp as the pattern' do
5
- exp = /[w+]/
6
- sig = RouteSignature.new exp
7
- sig.pattern.should == exp
8
- end
9
- end