strelka 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.rdoc +24 -0
  5. data/IDEAS.rdoc +0 -1
  6. data/README.rdoc +12 -6
  7. data/Rakefile +4 -94
  8. data/lib/strelka.rb +1 -1
  9. data/lib/strelka/app.rb +2 -3
  10. data/lib/strelka/app/parameters.rb +3 -12
  11. data/lib/strelka/app/restresources.rb +0 -3
  12. data/lib/strelka/cookie.rb +1 -1
  13. data/lib/strelka/mixins.rb +1 -1
  14. data/lib/strelka/multirunner.rb +34 -11
  15. data/lib/strelka/paramvalidator.rb +22 -45
  16. data/lib/strelka/session/default.rb +1 -1
  17. data/spec/strelka/app/parameters_spec.rb +1 -27
  18. data/spec/strelka/app_spec.rb +0 -12
  19. data/spec/strelka/mixins_spec.rb +0 -10
  20. data/spec/strelka/paramvalidator_spec.rb +4 -54
  21. metadata +51 -143
  22. metadata.gz.sig +0 -0
  23. data/.gemtest +0 -0
  24. data/ChangeLog +0 -3824
  25. data/MILESTONES.rdoc +0 -24
  26. data/Manifest.txt +0 -144
  27. data/contrib/hoetemplate/History.rdoc.erb +0 -4
  28. data/contrib/hoetemplate/Manifest.txt.erb +0 -8
  29. data/contrib/hoetemplate/README.rdoc.erb +0 -35
  30. data/contrib/hoetemplate/Rakefile.erb +0 -24
  31. data/contrib/hoetemplate/data/project/apps/file_name_app +0 -37
  32. data/contrib/hoetemplate/data/project/templates/layout.tmpl.erb +0 -13
  33. data/contrib/hoetemplate/data/project/templates/top.tmpl.erb +0 -8
  34. data/contrib/hoetemplate/lib/file_name.rb.erb +0 -15
  35. data/contrib/hoetemplate/spec/file_name_spec.rb.erb +0 -21
  36. data/contrib/strelka-dogs/doggie6.svg +0 -271
  37. data/contrib/strelka-dogs/doggie7.svg +0 -49
  38. data/examples/Procfile +0 -9
  39. data/examples/apps/auth-demo +0 -29
  40. data/examples/apps/auth-demo2 +0 -37
  41. data/examples/apps/hello-world +0 -30
  42. data/examples/apps/sessions-demo +0 -42
  43. data/examples/apps/upload-demo +0 -74
  44. data/examples/apps/ws-chat +0 -69
  45. data/examples/apps/ws-echo +0 -61
  46. data/examples/config.yml +0 -33
  47. data/examples/gen-config.rb +0 -52
  48. data/examples/static/examples.css +0 -4
  49. data/examples/static/examples.html +0 -33
  50. data/examples/strelka.conf.example +0 -51
  51. data/examples/templates/auth-form.tmpl +0 -14
  52. data/examples/templates/auth-success.tmpl +0 -5
  53. data/examples/templates/layout.tmpl +0 -31
  54. data/examples/templates/upload-form.tmpl +0 -17
  55. data/examples/templates/upload-success.tmpl +0 -13
@@ -1,49 +0,0 @@
1
- <?xml version="1.1" encoding="UTF-8" standalone="no"?>
2
- <svg width="500px" height="869px" xmlns="http://www.w3.org/2000/svg" version="1.1">
3
- <title>Стрелке (Strelka)</title>
4
- <description>Artist: Naia Smith</description>
5
- <title>Doggie 7</title>
6
- <description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
7
- <defs></defs>
8
- <g fill="none" id="Main Page">
9
- <g fill="none" id="Doggie">
10
- <g fill="none" id="Body">
11
- <path id="Forequarters" d="M222,310 C222,310 303,270 328,265 C353,259 354,259 354,259 C354,259 377,256 394,256 C411,256 432,263 438,277 C444,291 435,307 419,319 C403,330 336,377 336,377 C336,377 314,417 314,463 C314,508 314,501 321,532 C328,562 329,589 329,611 C329,632 324,694 320,714 C310,737 326,756 314,780 C309,789 296,776 300,779 C303,781 289,783 277,776 C266,769 250,771 256,707 C263,643 261,634 261,611" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
12
- <path id="Forequarters decoration" d="" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
13
- <path id="Hindquarters" d="M195,639 C201,653 218,686 218,719 C222,743 251,719 258,770 C251,786 212,770 126,729 C90,716 72,720 50,703 C0,658 2,554 16,523 C31,492 9,631 73,642 C73,615 142,518 200,493 C209,486 223,455 233,434 C246,404 254,381 251,366 C247,342 259,426 195,470 C181,477 205,399 212,387 C227,366 201,327 223,309" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
14
- <path id="Hindquarters decoration" d="" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
15
- <path id="Haunch" d="M118,627 C134,622 177,598 222,675" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
16
- <path id="Haunch decoration" d="" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
17
- <path id="Second Leg" d="M300,776 C295,783 313,771 289,742 C305,709 312,643 312,626 C320,596 312,569 320,529" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
18
- <path id="Second Leg decoration" d="" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
19
- <path id="Nose" d="M422,296 C432,296 441,290 441,283 C441,275 432,270 422,270 C412,270 404,275 404,283 C404,290 412,296 422,296" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(28,28,28)"></path>
20
- <path id="Nose decoration" d="" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(28,28,28)"></path>
21
- <path id="Eye" d="M308,329 C305,330 310,326 310,321 C302,318 306,317 300,313 C294,308 300,320 303,320 C305,320 305,327 305,327 C305,327 310,328 308,329" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(19,19,19)"></path>
22
- <path id="Eye decoration" d="" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(19,19,19)"></path>
23
- </g>
24
- <path id="Collar" d="M202,491 C202,491 231,506 274,506 C318,506 317,512 317,512 L314,475 C314,475 240,478 216,468 C211,478 202,491 202,491" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(183,14,1)"></path>
25
- <path id="Collar decoration" d="" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(183,14,1)"></path>
26
- <g fill="none" id="Helmet">
27
- <path id="Tipguard" d="M213,22 C216,22 219,19 219,16 C219,12 216,10 213,10 C209,10 207,12 207,16 C207,19 209,22 213,22" stroke="rgb(0,0,0)" stroke-width="1" fill="none"></path>
28
- <path id="Tipguard decoration" d="" stroke="rgb(0,0,0)" stroke-width="1" fill="none"></path>
29
- <path id="A Ring 1" d="M255,92 C263,88 267,82 263,79 C259,75 250,75 241,80 C233,84 229,90 233,93 C237,97 246,96 255,92" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
30
- <path id="A Ring 1 decoration" d="" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
31
- <path id="A Ring 4" d="M254,106 C260,103 263,98 261,94 C259,89 253,89 247,91 C241,94 238,100 240,104 C242,108 249,109 254,106" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
32
- <path id="A Ring 4 decoration" d="" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
33
- <path id="A Ring 3" d="M247,80 C253,77 256,71 253,68 C250,65 243,65 236,68 C230,72 227,77 230,80 C233,83 240,83 247,80" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
34
- <path id="A Ring 3 decoration" d="" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
35
- <path id="A Ring 2" d="M236,65 C242,63 245,57 243,53 C242,49 235,48 230,50 C224,53 220,58 222,62 C224,66 230,68 236,65" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
36
- <path id="A Ring 2 decoration" d="" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
37
- <path id="A Ring 1" d="M225,43 C231,41 234,35 233,31 C231,27 225,26 219,28 C213,31 210,36 211,40 C213,44 219,46 225,43" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
38
- <path id="A Ring 1 decoration" d="" stroke="rgb(0,0,0)" stroke-width="2" fill="none"></path>
39
- <path id="Antenna Port" d="M283,189 C294,186 301,178 299,171 C296,164 286,160 274,163 C263,165 256,173 258,180 C261,188 271,191 283,189" stroke="rgb(151,204,210)" stroke-width="1" fill="none"></path>
40
- <path id="Antenna Port decoration" d="" stroke="rgb(151,204,210)" stroke-width="1" fill="none"></path>
41
- <path id="Antenna" d="M214,16 C224,41 271,114 277,188" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
42
- <path id="Antenna decoration" d="" stroke="rgb(0,0,0)" stroke-width="3" fill="none"></path>
43
- <path id="Glass" d="M133,341 C133,336 116,240 250,170 C413,113 442,173 469,201 C478,210 520,285 469,379 C420,476 334,476 300,476 C265,476 186,486 171,469 C141,457 133,364 133,341" stroke="rgb(0,0,0)" stroke-width="1" fill="rgba(58,159,170,0.2)"></path>
44
- <path id="Glass decoration" d="" stroke="rgb(0,0,0)" stroke-width="1" fill="rgb(58,159,170)"></path>
45
- </g>
46
- </g>
47
- <text x="517" y="827" font-family="M+ 1p black" font-size="64" fill="rgb(0,0,0)" id="Стрелке">Стрелке</text>
48
- </g>
49
- </svg>
@@ -1,9 +0,0 @@
1
- # Foreman procfile
2
- mongrel: m2sh.rb -c mongrel2.sqlite start
3
- helloworld: ../bin/strelka -D . -l warn -c config.yml start hello-world
4
- auth: ../bin/strelka -D . -l warn -c config.yml start auth-demo
5
- auth2: ../bin/strelka -D . -l warn -c config.yml start auth-demo2
6
- sessions: ../bin/strelka -D . -l debug -c config.yml start sessions-demo
7
- upload: ../bin/strelka -D . -l debug -c config.yml start upload-demo
8
- # ws: ../bin/strelka -l info -c config.yml start ws-echo
9
-
@@ -1,29 +0,0 @@
1
- # -*- ruby -*-
2
- # vim: set nosta noet ts=4 sw=4:
3
- # frozen-string-literal: true
4
- require 'strelka'
5
-
6
- class AuthDemo < Strelka::App
7
-
8
- # The Mongrel2 appid of this app
9
- ID = 'auth-demo'
10
-
11
- plugins :auth, :routing
12
-
13
- ### Handle any (authenticated) HTTP request
14
- get do |req|
15
- res = req.response
16
- res.content_type = 'text/plain'
17
- res.status = HTTP::OK
18
-
19
- self.log.debug "Authenticated user is: %p" % [ req.authenticated_user ]
20
- res.puts "You authenticated successfully (as %p)." % [ req.authenticated_user ]
21
-
22
- return res
23
- end
24
-
25
-
26
- end # class AuthDemo
27
-
28
- AuthDemo.run if __FILE__ == $0
29
-
@@ -1,37 +0,0 @@
1
- # -*- ruby -*-
2
- # vim: set nosta noet ts=4 sw=4:
3
- # frozen-string-literal: true
4
- require 'strelka'
5
-
6
- # Another demo of the :auth plugin, this time implemented as form-based session
7
- # auth.
8
-
9
- class AuthDemo2 < Strelka::App
10
-
11
- # The Mongrel2 appid of this app
12
- ID = 'auth-demo2'
13
-
14
- plugins :auth, :errors, :templating, :routing
15
-
16
- default_type 'text/html'
17
-
18
- layout 'templates/layout.tmpl'
19
- templates \
20
- form: 'templates/auth-form.tmpl',
21
- success: 'templates/auth-success.tmpl'
22
-
23
- on_status HTTP::AUTH_REQUIRED, :form
24
-
25
-
26
- ### Handle any (authenticated) HTTP request
27
- get do |req|
28
- return :success
29
- end
30
-
31
-
32
- end # class AuthDemo2
33
-
34
-
35
- AuthDemo2.run if __FILE__ == $0
36
-
37
-
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'strelka'
4
-
5
- # The Strelka admin web console.
6
- class HelloWorldApp < Strelka::App
7
-
8
- # The route appid that will configure this app if no appid is specified
9
- ID = 'hello-world'
10
-
11
-
12
- # Use Sinatra-like routing
13
- plugins :routing
14
-
15
- # Set responses to plaintext if they don't specify differently
16
- default_type 'text/plain'
17
-
18
- # Handle all GET requests the same way
19
- get do |req|
20
- res = req.response
21
- res.puts 'Hello, world!'
22
- return res
23
- end
24
-
25
- end # class HelloWorldApp
26
-
27
-
28
- # Run the app
29
- Encoding.default_internal = Encoding::UTF_8
30
- HelloWorldApp.run if __FILE__ == $0
@@ -1,42 +0,0 @@
1
- # -*- ruby -*-
2
- # vim: set nosta noet ts=4 sw=4:
3
- # frozen-string-literal: true
4
- require 'strelka'
5
-
6
- class SessionsDemo < Strelka::App
7
-
8
- # The Mongrel2 appid of this app
9
- ID = 'sessions-demo'
10
-
11
- plugins :sessions
12
-
13
- ### Set up the run counter
14
- def initialize( * )
15
- @runcount = 0
16
- super
17
- end
18
-
19
-
20
- ### Handle any HTTP request
21
- def handle_request( req )
22
- res = req.response
23
- res.content_type = 'text/plain'
24
- res.status = HTTP::OK
25
-
26
- @runcount += 1
27
- req.session.counter ||= 0
28
- req.session.counter += 1
29
-
30
- self.log.debug "Request session is: %p" % [ req.session ]
31
- res.puts "Session [%s]: session counter: %d, run counter: %d" %
32
- [ req.session.session_id, req.session.counter, @runcount ]
33
-
34
- return res
35
- end
36
-
37
-
38
- end # class SessionsDemo
39
-
40
-
41
- SessionsDemo.run if __FILE__ == $0
42
-
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'strelka'
4
-
5
- # An example of a file upload handler.
6
- class UploadDemo < Strelka::App
7
-
8
- # The route appid that will configure this app if no appid is specified
9
- ID = 'upload-demo'
10
-
11
-
12
- plugins :templating, :routing, :parameters
13
-
14
- default_type 'text/html'
15
-
16
- layout 'templates/layout.tmpl'
17
- templates \
18
- form: 'templates/upload-form.tmpl',
19
- success: 'templates/upload-success.tmpl'
20
-
21
-
22
- ### Show the form for any GET
23
- get do |req|
24
- return :form
25
- end
26
-
27
-
28
- ### Show the upload for POST requests
29
- post do |req|
30
- req.params.add( :description, :string )
31
- req.params.add( :uploadfile ) do |input|
32
- if input.respond_to?( :filename ) && input.respond_to?( :content_type )
33
- input
34
- else
35
- nil
36
- end
37
- end
38
-
39
- unless req.content_type.start_with?( 'multipart/form-data' )
40
- self.log.error "Not a multipart/form-data request?!"
41
- finish_with HTTP::BAD_REQUEST,
42
- "Expecting a mutlipart/form-data request, got: %p" % [ req.content_type ]
43
- end
44
-
45
- unless req.params.okay?
46
- self.log.error "Parameter validation error: %s" %
47
- [ req.params.error_messages.join(', ') ]
48
- finish_with HTTP::BAD_REQUEST,
49
- "Form errors: %s" % [ req.params.error_messages.join(', ') ]
50
- end
51
-
52
- self.log.debug "Successful upload of file %s." % [ req.params[:uploadfile].filename ]
53
-
54
- tmpl = template :success
55
- tmpl.upload = req.params[:uploadfile]
56
- tmpl.description = req.params[:description]
57
-
58
- return tmpl
59
- end
60
-
61
-
62
- ### Override the upload-started notification to allow spooled (asynchronous)
63
- ### uploads.
64
- def handle_async_upload_start( request )
65
- self.log.info "Asynchronous upload notice. Spooling entity body to %p" %
66
- [ request.headers.x_mongrel_upload_start ]
67
- return nil
68
- end
69
-
70
- end # class UploadDemo
71
-
72
-
73
- # Run the app
74
- UploadDemo.run if __FILE__ == $0
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'strelka/websocketserver'
5
-
6
-
7
- # An example of a Strelka WebSocketServer that echoes back whatever (non-control) frames you send
8
- # it.
9
- class WebSocketChatServer < Strelka::WebSocketServer
10
- include Mongrel2::WebSocket::Constants
11
-
12
-
13
- ### Set up the user registry.
14
- def initialize( * )
15
- super
16
- @users = {}
17
- end
18
-
19
-
20
- #
21
- # Heartbeat plugin
22
- #
23
- plugin :heartbeat
24
-
25
- heartbeat_rate 5.0
26
- idle_timeout 15.0
27
-
28
-
29
- # Make a new user slot for sockets when they start up.
30
- on_handshake do |frame|
31
- super
32
- @users[ frame.socket_id ] = nil
33
- end
34
-
35
-
36
- # When a text frame comes in (or is assembled from :continuation frames), parse it as JSON
37
- # and decide what to do based on its contents.
38
- on_text do |frame|
39
-
40
- end
41
-
42
-
43
-
44
- # Handle close frames
45
- on_close do |frame|
46
-
47
- username = self.users.delete( frame.socket_id )
48
- self.broadcast_notice( "#{username} disconnected." ) if username
49
-
50
- # There will still be a connection slot if this close originated with
51
- # the client. In that case, reply with the ACK CLOSE frame
52
- self.conn.reply( frame.response(:close) ) if
53
- self.connections.delete( [frame.sender_id, frame.conn_id] )
54
-
55
- self.conn.reply_close( frame )
56
- return nil
57
- end
58
-
59
-
60
- end # class RequestDumper
61
-
62
- Loggability.level = $DEBUG||$VERBOSE ? :debug : :info
63
- Loggability.format_as( :color ) if $stdin.tty?
64
-
65
- # Point to the config database, which will cause the handler to use
66
- # its ID to look up its own socket info.
67
- Mongrel2::Config.configure( :configdb => 'examples.sqlite' )
68
- WebSocketEchoServer.run( 'ws-echo' )
69
-
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'strelka/websocketserver'
5
-
6
-
7
- # An example of a Strelka WebSocketServer that echoes back whatever (non-control) frames you send
8
- # it.
9
- class WebSocketEchoServer < Strelka::WebSocketServer
10
-
11
- # Application ID
12
- ID = 'ws-echo'
13
-
14
- #
15
- # Heartbeat plugin
16
- #
17
- # plugin :heartbeat
18
- #
19
- # heartbeat_rate 5.0
20
- # idle_timeout 15.0
21
-
22
-
23
- #
24
- # Routing
25
- #
26
-
27
- plugin :routing
28
-
29
- # Handle TEXT, BINARY, and CONTINUATION frames by replying with an echo of the
30
- # same data. Fragmented frames get echoed back as-is without any reassembly.
31
- on_text do |frame|
32
- self.log.info "Echoing data frame: %p" % [ frame ]
33
-
34
- # Make the response frame
35
- response = frame.response
36
- response.fin = frame.fin?
37
- IO.copy_stream( frame.payload, response.payload )
38
-
39
- return response
40
- end
41
- alias_method :handle_binary_frame, :on_text_frame
42
- alias_method :handle_continuation_frame, :on_text_frame
43
-
44
-
45
- # Handle close frames
46
- on_close do |frame|
47
-
48
- # There will still be a connection slot if this close originated with
49
- # the client. In that case, reply with the ACK CLOSE frame
50
- self.conn.reply( frame.response(:close) ) if
51
- self.connections.delete( [frame.sender_id, frame.conn_id] )
52
-
53
- self.conn.reply_close( frame )
54
- return nil
55
- end
56
-
57
-
58
- end # class RequestDumper
59
-
60
- Encoding.default_internal = Encoding::UTF_8
61
- WebSocketEchoServer.run if __FILE__ == $0
@@ -1,33 +0,0 @@
1
- mongrel2:
2
- configdb: amalgalite://mongrel2.sqlite
3
-
4
- auth:
5
- provider: basic
6
-
7
- basicauth:
8
- realm: Examples
9
- users:
10
- ged: "dn44fsIrKF6KmBw0im4GIJktSpM="
11
- jblack: "1pAnQNSVtpL1z88QwXV4sG8NMP8="
12
- kmurgen: "MZj9+VhZ8C9+aJhmwp+kWBL76Vs="
13
-
14
- sessions:
15
- type: default
16
-
17
- defaultsession:
18
- cookie_name: "session-demo"
19
- cookie_options:
20
- expires: +5m
21
-
22
- templates:
23
- template_paths:
24
- - templates
25
-
26
- logging:
27
- strelka: debug (color)
28
- inversion: info (color)
29
- configurability: debug (color)
30
- mongrel2: debug (color)
31
-
32
-
33
-
@@ -1,52 +0,0 @@
1
- # -*- ruby -*-
2
- # vim: set nosta noet ts=4 sw=4:
3
- # frozen-string-literal: true
4
- # The Mongrel config used by the examples. Load it with:
5
- #
6
- # m2sh.rb -c examples/mongrel2.sqlite load examples/gen-config.rb
7
- #
8
-
9
- require 'mongrel2'
10
- require 'mongrel2/config/dsl'
11
-
12
-
13
- # samples server
14
- server 'examples' do
15
-
16
- name 'Strelka Examples'
17
- default_host 'localhost'
18
-
19
- access_log 'logs/access.log'
20
- error_log 'logs/error.log'
21
- pid_file 'run/mongrel2.pid'
22
-
23
- chroot ''
24
- bind_addr '0.0.0.0'
25
- port 8113
26
-
27
- host 'localhost' do
28
-
29
- route '/', directory( 'static/', 'examples.html', 'text/html' )
30
-
31
- # Handlers
32
- route '/hello', handler( 'tcp://127.0.0.1:9900', 'hello-world' )
33
- route '/sessions', handler( 'tcp://127.0.0.1:9905', 'sessions-demo' )
34
- route '/auth', handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
35
- route '/formauth', handler( 'tcp://127.0.0.1:9915', 'auth-demo2' )
36
- route '/upload', handler( 'tcp://127.0.0.1:9925', 'upload-demo' )
37
- route '/ws', handler( 'tcp://127.0.0.1:9920', 'ws-echo' )
38
-
39
- end
40
-
41
- end
42
-
43
- setting "zeromq.threads", 1
44
-
45
- setting 'limits.content_length', 8096
46
- setting 'upload.temp_store', 'var/uploads/mongrel2.upload.XXXXXX'
47
- setting 'server.daemonize', false
48
-
49
- mkdir_p 'var/uploads'
50
- mkdir_p 'run'
51
- mkdir_p 'logs'
52
-