strelka 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ChangeLog +156 -9
  4. data/History.rdoc +15 -0
  5. data/IDEAS.rdoc +17 -1
  6. data/MILESTONES.rdoc +1 -1
  7. data/Manifest.txt +10 -2
  8. data/Plugins.rdoc +4 -4
  9. data/README.rdoc +3 -3
  10. data/Rakefile +5 -4
  11. data/bin/strelka +19 -10
  12. data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
  13. data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
  14. data/examples/apps/hello-world +1 -0
  15. data/examples/apps/ws-chat +69 -0
  16. data/examples/apps/ws-echo +61 -0
  17. data/examples/gen-config.rb +6 -5
  18. data/lib/strelka/app/auth.rb +2 -2
  19. data/lib/strelka/app/errors.rb +1 -1
  20. data/lib/strelka/app/filters.rb +3 -2
  21. data/lib/strelka/app/negotiation.rb +2 -2
  22. data/lib/strelka/app/parameters.rb +1 -2
  23. data/lib/strelka/app/restresources.rb +3 -2
  24. data/lib/strelka/app/routing.rb +1 -1
  25. data/lib/strelka/app/sessions.rb +2 -2
  26. data/lib/strelka/app/templating.rb +7 -3
  27. data/lib/strelka/app.rb +5 -145
  28. data/lib/strelka/behavior/plugin.rb +4 -4
  29. data/lib/strelka/discovery.rb +211 -0
  30. data/lib/strelka/httprequest.rb +1 -0
  31. data/lib/strelka/httpresponse/negotiation.rb +7 -1
  32. data/lib/strelka/mixins.rb +4 -1
  33. data/lib/strelka/paramvalidator.rb +1 -1
  34. data/lib/strelka/plugins.rb +8 -6
  35. data/lib/strelka/websocketserver/routing.rb +116 -0
  36. data/lib/strelka/websocketserver.rb +147 -0
  37. data/lib/strelka.rb +5 -4
  38. data/spec/{lib/constants.rb → constants.rb} +3 -2
  39. data/spec/{lib/helpers.rb → helpers.rb} +15 -14
  40. data/spec/strelka/app/auth_spec.rb +145 -142
  41. data/spec/strelka/app/errors_spec.rb +20 -26
  42. data/spec/strelka/app/filters_spec.rb +67 -54
  43. data/spec/strelka/app/negotiation_spec.rb +8 -14
  44. data/spec/strelka/app/parameters_spec.rb +23 -29
  45. data/spec/strelka/app/restresources_spec.rb +98 -100
  46. data/spec/strelka/app/routing_spec.rb +57 -57
  47. data/spec/strelka/app/sessions_spec.rb +11 -17
  48. data/spec/strelka/app/templating_spec.rb +36 -40
  49. data/spec/strelka/app_spec.rb +48 -147
  50. data/spec/strelka/authprovider/basic_spec.rb +5 -11
  51. data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
  52. data/spec/strelka/authprovider_spec.rb +3 -9
  53. data/spec/strelka/cookie_spec.rb +32 -38
  54. data/spec/strelka/cookieset_spec.rb +31 -37
  55. data/spec/strelka/discovery_spec.rb +144 -0
  56. data/spec/strelka/exceptions_spec.rb +2 -8
  57. data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
  58. data/spec/strelka/httprequest/auth_spec.rb +5 -15
  59. data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
  60. data/spec/strelka/httprequest/session_spec.rb +12 -22
  61. data/spec/strelka/httprequest_spec.rb +1 -7
  62. data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
  63. data/spec/strelka/httpresponse/session_spec.rb +25 -35
  64. data/spec/strelka/httpresponse_spec.rb +20 -26
  65. data/spec/strelka/mixins_spec.rb +66 -61
  66. data/spec/strelka/multipartparser_spec.rb +31 -37
  67. data/spec/strelka/paramvalidator_spec.rb +389 -373
  68. data/spec/strelka/plugins_spec.rb +17 -23
  69. data/spec/strelka/router/default_spec.rb +32 -38
  70. data/spec/strelka/router/exclusive_spec.rb +28 -34
  71. data/spec/strelka/router_spec.rb +2 -8
  72. data/spec/strelka/session/db_spec.rb +17 -15
  73. data/spec/strelka/session/default_spec.rb +22 -28
  74. data/spec/strelka/session_spec.rb +3 -9
  75. data/spec/strelka/websocketserver/routing_spec.rb +119 -0
  76. data/spec/strelka/websocketserver_spec.rb +149 -0
  77. data/spec/strelka_spec.rb +11 -13
  78. data.tar.gz.sig +3 -3
  79. metadata +22 -14
  80. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b902501570fb51a630e6db3a1caf76e2d6b95cf
4
- data.tar.gz: 887a594a9a0f7bec5f078780d70213bbbf42659c
3
+ metadata.gz: 9917d0f2aa0af3e703673e52fa232213ca6c1ecd
4
+ data.tar.gz: 33663b826ca6419b795bb01272c4d89bea9f1944
5
5
  SHA512:
6
- metadata.gz: 6fa8677d58715cdbf5c49f5ebb869ee8375276bac1bfa7f053e12af22e4c2b5bdc8cd7bb67ffac82b5e1aa1fede89bce8b3135695c1270c76df8f1b37deb363f
7
- data.tar.gz: a412d2434be44b12180bf63c76ffe8905fda2dd0728173a37a3522a8635c682de47f9bddb894b645af2c96aebff6be4cc70ccea76e2530b050d9650fdaf10459
6
+ metadata.gz: 0e9d6bc816de257d09d2f96135cec0f4e167e18657e458d172cf51fde131ba58f5f8e761adec8a4709cc4a3849e8a8c067539993ee9e01cca98ebaacd71818c4
7
+ data.tar.gz: ebfb61a89a233bba657937877bf1eb61ade3b907bda55ba2d188ce397358e52e5cc6a762a04c13664baa45867c8640967903acb63f095a979a011e87d3139c27
checksums.yaml.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,156 @@
1
+ 2013-10-15 Michael Granger <ged@faeriemud.org>
2
+
3
+ * Close branch rdolgushin/ideasrdoc-russian-woof-fix-1381879886956
4
+ [dedc90b70209] [tip] <rdolgushin/ideasrdoc-russian-woof-fix-1381879886956>
5
+
6
+ * Merged in rdolgushin/strelka/rdolgushin/ideasrdoc-russian-woof-
7
+ fix-1381879886956 (pull request #2)
8
+
9
+ IDEAS.rdoc: Russian 'woof' fix
10
+ [ac7fea5af58f] [github/master]
11
+
12
+ 2013-10-15 Roman Dolgushin <rd@roman-dolgushin.ru>
13
+
14
+ * IDEAS.rdoc:
15
+ IDEAS.rdoc: Russian 'woof' fix
16
+ [639105edf399] <rdolgushin/ideasrdoc-russian-woof-fix-1381879886956>
17
+
18
+ 2013-10-15 Michael Granger <ged@FaerieMUD.org>
19
+
20
+ * Manifest.txt, bin/strelka, lib/strelka/app.rb,
21
+ lib/strelka/app/restresources.rb, lib/strelka/behavior/plugin.rb,
22
+ lib/strelka/httprequest.rb, spec/constants.rb, spec/helpers.rb,
23
+ spec/lib/constants.rb, spec/lib/helpers.rb,
24
+ spec/strelka/app/auth_spec.rb, spec/strelka/app/errors_spec.rb,
25
+ spec/strelka/app/filters_spec.rb,
26
+ spec/strelka/app/negotiation_spec.rb,
27
+ spec/strelka/app/parameters_spec.rb,
28
+ spec/strelka/app/restresources_spec.rb,
29
+ spec/strelka/app/routing_spec.rb, spec/strelka/app/sessions_spec.rb,
30
+ spec/strelka/app/templating_spec.rb, spec/strelka/app_spec.rb,
31
+ spec/strelka/authprovider/basic_spec.rb,
32
+ spec/strelka/authprovider/hostaccess_spec.rb,
33
+ spec/strelka/authprovider_spec.rb, spec/strelka/cookie_spec.rb,
34
+ spec/strelka/cookieset_spec.rb, spec/strelka/discovery_spec.rb,
35
+ spec/strelka/exceptions_spec.rb,
36
+ spec/strelka/httprequest/acceptparams_spec.rb,
37
+ spec/strelka/httprequest/auth_spec.rb,
38
+ spec/strelka/httprequest/negotiation_spec.rb,
39
+ spec/strelka/httprequest/session_spec.rb,
40
+ spec/strelka/httprequest_spec.rb,
41
+ spec/strelka/httpresponse/negotiation_spec.rb,
42
+ spec/strelka/httpresponse/session_spec.rb,
43
+ spec/strelka/httpresponse_spec.rb, spec/strelka/mixins_spec.rb,
44
+ spec/strelka/multipartparser_spec.rb,
45
+ spec/strelka/paramvalidator_spec.rb, spec/strelka/plugins_spec.rb,
46
+ spec/strelka/router/default_spec.rb,
47
+ spec/strelka/router/exclusive_spec.rb, spec/strelka/router_spec.rb,
48
+ spec/strelka/session/db_spec.rb,
49
+ spec/strelka/session/default_spec.rb, spec/strelka/session_spec.rb,
50
+ spec/strelka/websocketserver/routing_spec.rb,
51
+ spec/strelka/websocketserver_spec.rb, spec/strelka_spec.rb:
52
+ Convert specs to new RSpec syntax.
53
+ [44fa18409c36]
54
+
55
+ * contrib/hoetemplate/.tm_properties,
56
+ contrib/hoetemplate/data/project/apps/file_name_app,
57
+ contrib/hoetemplate/lib/file_name.rb.erb:
58
+ Update Textmate properties in Hoe template
59
+ [ffc16e8412df]
60
+
61
+ 2013-10-07 Michael Granger <ged@FaerieMUD.org>
62
+
63
+ * .rvm.gems:
64
+ Update rvm gemset
65
+ [004066a49de5]
66
+
67
+ 2013-10-06 Michael Granger <ged@FaerieMUD.org>
68
+
69
+ * Gemfile, Rakefile:
70
+ Don't explicitly depend on RSpec version (use hoe-deveiate's
71
+ version)
72
+ [d0020cb5b3b5]
73
+
74
+ * examples/Procfile, examples/gen-config.rb:
75
+ Update for latest versions of Mongrel2 and the mongrel2 gem
76
+ [bcb0496f6135]
77
+
78
+ * lib/strelka/mixins.rb, spec/strelka/mixins_spec.rb:
79
+ Don't dup IOs or Tempfiles while deep-copying
80
+ [307d1a75161c]
81
+
82
+ * .hgignore, examples/.env:
83
+ Don't include example .env settings or logs
84
+ [76d01cc8ee54]
85
+
86
+ * Rakefile:
87
+ Fix Rakefile for latest version of Hoe
88
+ [ed5ff1b21eb1]
89
+
90
+ * .hgignore, Gemfile, Rakefile:
91
+ Add hoe-bundler for generated Gemfile.
92
+ [c2180fd0ac4f]
93
+
94
+ 2013-09-20 Michael Granger <ged@FaerieMUD.org>
95
+
96
+ * lib/strelka/app.rb:
97
+ Update for newest version of Configurability.
98
+ [79b29b4c9079]
99
+
100
+ * Manifest.txt:
101
+ Update manifest
102
+ [719fbab274b9]
103
+
104
+ 2013-09-10 Michael Granger <ged@FaerieMUD.org>
105
+
106
+ * IDEAS.rdoc, MILESTONES.rdoc, bin/strelka, examples/Procfile,
107
+ examples/apps/hello-world, examples/apps/ws-chat, examples/apps/ws-
108
+ echo, lib/strelka.rb, lib/strelka/app.rb,
109
+ lib/strelka/app/templating.rb, lib/strelka/behavior/plugin.rb,
110
+ lib/strelka/discovery.rb, lib/strelka/websocketserver.rb,
111
+ lib/strelka/websocketserver/routing.rb, spec/lib/constants.rb,
112
+ spec/strelka/app/auth_spec.rb, spec/strelka/app/errors_spec.rb,
113
+ spec/strelka/app/filters_spec.rb,
114
+ spec/strelka/app/negotiation_spec.rb,
115
+ spec/strelka/app/parameters_spec.rb,
116
+ spec/strelka/app/restresources_spec.rb,
117
+ spec/strelka/app/routing_spec.rb, spec/strelka/app/sessions_spec.rb,
118
+ spec/strelka/app/templating_spec.rb, spec/strelka/app_spec.rb,
119
+ spec/strelka/discovery_spec.rb,
120
+ spec/strelka/websocketserver/routing_spec.rb,
121
+ spec/strelka/websocketserver_spec.rb:
122
+ Adding a websocket service base class
123
+ [dc4b69988131]
124
+
125
+ * lib/strelka/app.rb, lib/strelka/httpresponse/negotiation.rb,
126
+ spec/strelka/httpresponse/negotiation_spec.rb:
127
+ Treat exceptions raised from negotiated content blocks as a failed
128
+ format
129
+ [48fb08c7a2a3]
130
+
131
+ * spec/strelka/httpresponse/negotiation_spec.rb:
132
+ Convert httpresponse/negotiation spec to expect syntax
133
+ [f727ec415c0d]
134
+
135
+ 2013-06-19 Michael Granger <ged@FaerieMUD.org>
136
+
137
+ * .hgtags:
138
+ Added tag v0.6.0 for changeset 25c5569e585b
139
+ [db22abb5e332]
140
+
141
+ * .hgsigs:
142
+ Added signature for changeset a043d61c759c
143
+ [25c5569e585b] [v0.6.0]
144
+
1
145
  2013-06-12 Michael Granger <ged@FaerieMUD.org>
2
146
 
147
+ * History.rdoc, lib/strelka.rb:
148
+ Bump the minor version, update history.
149
+ [a043d61c759c]
150
+
3
151
  * Rakefile:
4
152
  Add Mahlon (finally) as an author
5
- [d0a7eba63c10] [tip]
153
+ [d0a7eba63c10]
6
154
 
7
155
  * lib/strelka/httprequest.rb, spec/strelka/httprequest_spec.rb:
8
156
  Make HTTPRequest#params always return a Hash
@@ -31,7 +179,7 @@
31
179
  * .rvm.gems, Rakefile, lib/strelka/httprequest.rb,
32
180
  lib/strelka/session/db.rb, spec/strelka/httprequest_spec.rb:
33
181
  Use the safe_yaml gem for loading untrusted request bodies.
34
- [ce0387824c10] [github/master]
182
+ [ce0387824c10]
35
183
 
36
184
  * lib/strelka/paramvalidator.rb, spec/strelka/paramvalidator_spec.rb:
37
185
  Fix validator for literal "false" (via JSON)
@@ -2092,8 +2240,8 @@
2092
2240
  - Require Ruby-Mongrel 0.12+
2093
2241
  - This is just the initial implementation. Yet to be added:
2094
2242
  configuration options for enabling/disabling stuff, automatic
2095
- composite services mapped from association reflections, mass-
2096
- create option, and lots more I'm forgetting.
2243
+ composite services mapped from association reflections, mass- create
2244
+ option, and lots more I'm forgetting.
2097
2245
  [23acdb6e9afc]
2098
2246
 
2099
2247
  * data/strelka/bootstrap-config.rb:
@@ -2411,12 +2559,11 @@
2411
2559
  spec/strelka/httpresponse/negotiation_spec.rb:
2412
2560
  Alterations to the plugin system to reflect dogfood discoveries.
2413
2561
  - Rearranged the lifecycle of the request to all happen inside the
2414
- try/catch to allow fixup hooks to finish with an error status,
2415
- too.
2562
+ try/catch to allow fixup hooks to finish with an error status, too.
2416
2563
  - Moved the negotiation plugin closer to the router so negotation
2417
- callbacks can return responses that will be further altered by
2418
- later plugins. Moved the acceptable check into the response fixup
2419
- hook to accomplish this.
2564
+ callbacks can return responses that will be further altered by later
2565
+ plugins. Moved the acceptable check into the response fixup hook to
2566
+ accomplish this.
2420
2567
  - Made the response fixup hook only take a response object since
2421
2568
  responses can now know what their request is.
2422
2569
  - Made language-negotiation short-circuit whenever there aren't any
data/History.rdoc CHANGED
@@ -1,3 +1,18 @@
1
+ == v0.7.0 [2013-10-21] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Make response filters always receive a response even if the handler
4
+ returns a Symbol, e.g., for the templating plugin.
5
+ - Add a note about needed documentation to :templating
6
+ - Change filter plugin order; change run_before/run_after to
7
+ run_outside/run_inside. Backward-compatibility maintained with an alias.
8
+ - Consider empty string as no value for parameter validation. (fixes #8)
9
+ - IDEAS.rdoc: Russian 'woof' fix (thanks to Roman Dolgushin <rd@roman-dolgushin.ru>)
10
+ - Don't dup IOs or Tempfiles while deep-copying
11
+ - Adding a websocket service base class
12
+ - Treat exceptions raised from negotiated content blocks as a failed
13
+ format
14
+
15
+
1
16
  == v0.6.0 [2013-06-12] Michael Granger <ged@FaerieMUD.org>
2
17
 
3
18
  - Bump dependency on Loggability and Configurability
data/IDEAS.rdoc CHANGED
@@ -55,8 +55,24 @@ gem sandboxing.
55
55
  * caching -- utilities for easy HTTP caching
56
56
 
57
57
 
58
- == уток! (woof!)
58
+ == гав! (woof!)
59
59
 
60
60
  Make a MacOS X tool like Pow! that makes it easy to run Strelka apps with a
61
61
  minimum of setup.
62
62
 
63
+
64
+ == WebSocketServer
65
+
66
+ Planned features:
67
+
68
+ * DSL plugin for handling various kinds of frames, ala the App routing plugin
69
+ * DSL plugin derived from the frame-based routing plugin that adds routing logic based on a
70
+ JSON data structure's contents
71
+ * Automatic de-fragmenting of frames, with a plugin that allows customization of fragment-handling.
72
+ * Heartbeat plugin that automatically pings connected clients, and disconnects them if they haven't
73
+ been seen in a while.
74
+ * Plugin class to facilitate extensions? Not sure how this would work, but it could use
75
+ the 'deflate' extension as the test case.
76
+
77
+
78
+
data/MILESTONES.rdoc CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  === Documentation
6
6
 
7
- [ ] Ensure the README is up to date
7
+ [] Ensure the README is up to date
8
8
  [ ] Update the IDEAS doc
9
9
  [ ] Extract the rest of the tutorial part of the manual out into RDoc for the app classes
10
10
  [ ] Lay out the framework for the 'cookbook' section of the manual
data/Manifest.txt CHANGED
@@ -27,6 +27,8 @@ examples/apps/auth-demo2
27
27
  examples/apps/hello-world
28
28
  examples/apps/sessions-demo
29
29
  examples/apps/upload-demo
30
+ examples/apps/ws-chat
31
+ examples/apps/ws-echo
30
32
  examples/config.yml
31
33
  examples/gen-config.rb
32
34
  examples/static/examples.css
@@ -55,6 +57,7 @@ lib/strelka/behavior/plugin.rb
55
57
  lib/strelka/constants.rb
56
58
  lib/strelka/cookie.rb
57
59
  lib/strelka/cookieset.rb
60
+ lib/strelka/discovery.rb
58
61
  lib/strelka/exceptions.rb
59
62
  lib/strelka/httprequest.rb
60
63
  lib/strelka/httprequest/acceptparams.rb
@@ -75,6 +78,9 @@ lib/strelka/session.rb
75
78
  lib/strelka/session/db.rb
76
79
  lib/strelka/session/default.rb
77
80
  lib/strelka/testing.rb
81
+ lib/strelka/websocketserver.rb
82
+ lib/strelka/websocketserver/routing.rb
83
+ spec/constants.rb
78
84
  spec/data/error.tmpl
79
85
  spec/data/forms/2_images.form
80
86
  spec/data/forms/singleupload.form
@@ -87,8 +93,7 @@ spec/data/forms/testform_multivalue.form
87
93
  spec/data/forms/testform_truncated_metadata.form
88
94
  spec/data/layout.tmpl
89
95
  spec/data/main.tmpl
90
- spec/lib/constants.rb
91
- spec/lib/helpers.rb
96
+ spec/helpers.rb
92
97
  spec/strelka/app/auth_spec.rb
93
98
  spec/strelka/app/errors_spec.rb
94
99
  spec/strelka/app/filters_spec.rb
@@ -104,6 +109,7 @@ spec/strelka/authprovider/hostaccess_spec.rb
104
109
  spec/strelka/authprovider_spec.rb
105
110
  spec/strelka/cookie_spec.rb
106
111
  spec/strelka/cookieset_spec.rb
112
+ spec/strelka/discovery_spec.rb
107
113
  spec/strelka/exceptions_spec.rb
108
114
  spec/strelka/httprequest/acceptparams_spec.rb
109
115
  spec/strelka/httprequest/auth_spec.rb
@@ -123,4 +129,6 @@ spec/strelka/router_spec.rb
123
129
  spec/strelka/session/db_spec.rb
124
130
  spec/strelka/session/default_spec.rb
125
131
  spec/strelka/session_spec.rb
132
+ spec/strelka/websocketserver/routing_spec.rb
133
+ spec/strelka/websocketserver_spec.rb
126
134
  spec/strelka_spec.rb
data/Plugins.rdoc CHANGED
@@ -58,8 +58,8 @@ applications can use it like so:
58
58
  == Load Order
59
59
 
60
60
  The request is passed through plugins sequentually. You can control where in
61
- the chain your plugin belongs, by using the <tt>run_before</tt> and
62
- <tt>run_after</tt> methods. Both methods accept a comma separated list of other
61
+ the chain your plugin belongs, by using the <tt>run_outside</tt> and
62
+ <tt>run_inside</tt> methods. Both methods accept a comma separated list of other
63
63
  plugin names.
64
64
 
65
65
  In this example case, we want the logger to log the request before the other
@@ -71,7 +71,7 @@ core plugins run, so any errors still make it out to the log.
71
71
  module Strelka::App::DBLogger
72
72
  extend Strelka::Plugin
73
73
 
74
- run_before :auth,
74
+ run_outside :auth,
75
75
  :filters,
76
76
  :negotiation,
77
77
  :parameters,
@@ -125,7 +125,7 @@ Here's the complete plugin.
125
125
  module Strelka::App::DBLogger
126
126
  extend Strelka::Plugin
127
127
 
128
- run_before :auth,
128
+ run_outside :auth,
129
129
  :filters,
130
130
  :negotiation,
131
131
  :parameters,
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = Strelka (Стрелка)
2
2
 
3
3
  home :: http://deveiate.org/projects/Strelka
4
- code :: http://repo.deveiate.org/Strelka
4
+ code :: http://bitbucket.org/ged/Strelka
5
5
  github :: https://github.com/ged/strelka
6
6
  docs :: http://deveiate.org/code/strelka
7
7
 
@@ -182,7 +182,7 @@ Support for sending partial responses via the Chunked encoding.
182
182
  == Contributing
183
183
 
184
184
  You can check out the current development source with Mercurial via its
185
- {project page}[http://repo.deveiate.org/Strelka]. Or if you prefer Git, via
185
+ {project page}[http://bitbucket.org/ged/Strelka]. Or if you prefer Git, via
186
186
  {its Github mirror}[https://github.com/ged/strelka].
187
187
 
188
188
  After checking out the source, run:
@@ -195,7 +195,7 @@ and generate the API documentation.
195
195
 
196
196
  == License
197
197
 
198
- Copyright (c) 2011-2012, Michael Granger
198
+ Copyright (c) 2011-2013, Michael Granger and Mahlon E. Smith
199
199
  All rights reserved.
200
200
 
201
201
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ end
11
11
  Hoe.plugin :mercurial
12
12
  Hoe.plugin :signing
13
13
  Hoe.plugin :deveiate
14
+ Hoe.plugin :bundler
14
15
 
15
16
  Hoe.plugins.delete :rubyforge
16
17
 
@@ -27,19 +28,19 @@ hoespec = Hoe.spec 'strelka' do
27
28
  self.dependency 'highline', '~> 1.6'
28
29
  self.dependency 'inversion', '~> 0.12'
29
30
  self.dependency 'loggability', '~> 0.6'
30
- self.dependency 'mongrel2', '~> 0.36'
31
+ self.dependency 'mongrel2', '~> 0.40'
31
32
  self.dependency 'pluggability', '~> 0.2'
32
33
  self.dependency 'sysexits', '~> 1.1'
33
34
  self.dependency 'trollop', '~> 2.0'
34
35
  self.dependency 'uuidtools', '~> 2.1'
35
36
  self.dependency 'safe_yaml', '~> 0.9'
36
37
 
37
- self.dependency 'hoe-deveiate', '~> 0.1', :developer
38
- self.dependency 'rspec', '~> 0.14', :developer
38
+ self.dependency 'hoe-deveiate', '~> 0.3', :developer
39
+ self.dependency 'hoe-bundler', '~> 1.2', :developer
39
40
  self.dependency 'simplecov', '~> 0.7', :developer
40
41
  self.dependency 'rdoc-generator-fivefish', '~> 0.2', :developer
41
42
 
42
- self.spec_extras[:licenses] = ["BSD"]
43
+ self.license "BSD"
43
44
  self.spec_extras[:rdoc_options] = [
44
45
  '-t', 'Strelka Web Application Toolkit',
45
46
  '-w', '4',
data/bin/strelka CHANGED
@@ -2,6 +2,8 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
 
4
4
  require 'strelka'
5
+ require 'strelka/discovery'
6
+
5
7
  require 'trollop'
6
8
  require 'highline'
7
9
  require 'loggability'
@@ -211,7 +213,7 @@ class Strelka::CLICommand
211
213
  # Set the datadir override if it's given
212
214
  if self.options.datadir
213
215
  self.log.debug "Using data dir option: %s" % [ self.options.datadir ]
214
- Strelka::App.local_data_dirs = Pathname( self.options.datadir )
216
+ Strelka::Discovery.local_data_dirs = Pathname( self.options.datadir )
215
217
  end
216
218
 
217
219
  # Include a 'lib' directory if there is one
@@ -266,7 +268,7 @@ class Strelka::CLICommand
266
268
 
267
269
  self.load_additional_requires
268
270
 
269
- paths = Strelka::App.discover_paths
271
+ paths = Strelka::Discovery.discover_paths
270
272
  if paths.empty?
271
273
  message "None found."
272
274
  else
@@ -297,14 +299,21 @@ class Strelka::CLICommand
297
299
  def start_command( *args )
298
300
  appname = args.pop
299
301
  gemname = args.pop
300
- path, gemname = Strelka::App.find( appname, gemname )
302
+ path = nil
303
+
304
+ if File.exist?( appname )
305
+ header "Starting %s." % [ appname ]
306
+ path = appname
307
+ else
308
+ path, gemname = Strelka::Discovery.find( appname, gemname )
301
309
 
302
- header "Starting the %s app%s" % [
303
- appname,
304
- gemname == '' ? '' : " from the #{gemname} gem"
305
- ]
310
+ header "Starting the %s app%s" % [
311
+ appname,
312
+ gemname == '' ? '' : " from the #{gemname} gem"
313
+ ]
314
+ end
306
315
 
307
- apps = Strelka::App.load( path )
316
+ apps = Strelka::Discovery.load( path )
308
317
  Strelka.load_config( self.options.config ) if self.options.config
309
318
  self.log.debug " loaded: %p" % [ apps ]
310
319
 
@@ -328,13 +337,13 @@ class Strelka::CLICommand
328
337
  discovery_name = gemname || ''
329
338
 
330
339
  header "Dumping config for %s" % [ gemname || 'local apps' ]
331
- discovered_apps = Strelka::App.discover_paths
340
+ discovered_apps = Strelka::Discovery.discover_paths
332
341
 
333
342
  raise ArgumentError, "No apps discovered" unless discovered_apps.key?( discovery_name )
334
343
 
335
344
  discovered_apps[ discovery_name ].each do |apppath|
336
345
  message " loading %s (%s)" % [ apppath, apppath.basename('.rb') ]
337
- Strelka::App.load( apppath )
346
+ Strelka::Discovery.load( apppath )
338
347
  end
339
348
 
340
349
  self.load_additional_requires
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ #encoding: utf-8
2
3
 
3
4
  require 'strelka'
4
5
 
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  # <%= XIF %> (top-level documentation)
4
5
  module <%= klass %>
@@ -7,7 +8,7 @@ module <%= klass %>
7
8
  VERS<%# this is just here so Hoe doesn't see this constant %>ION = '0.0.1'
8
9
 
9
10
  # Version-control revision constant
10
- REVISION = %q$Revision: 485638c9ec10 $
11
+ REVISION = %q$Revision: ffc16e8412df $
11
12
 
12
13
  end # module <%= klass %>
13
14
 
@@ -26,4 +26,5 @@ end # class HelloWorldApp
26
26
 
27
27
 
28
28
  # Run the app
29
+ Encoding.default_internal = Encoding::UTF_8
29
30
  HelloWorldApp.run if __FILE__ == $0
@@ -0,0 +1,69 @@
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
+
@@ -0,0 +1,61 @@
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
@@ -17,17 +17,17 @@ server 'examples' do
17
17
  name 'Strelka Examples'
18
18
  default_host 'localhost'
19
19
 
20
- access_log '/logs/access.log'
21
- error_log '/logs/error.log'
22
- chroot '/var/mongrel2'
23
- pid_file '/run/mongrel2.pid'
20
+ access_log 'logs/access.log'
21
+ error_log 'logs/error.log'
22
+ pid_file 'run/mongrel2.pid'
24
23
 
24
+ chroot ''
25
25
  bind_addr '0.0.0.0'
26
26
  port 8113
27
27
 
28
28
  host 'localhost' do
29
29
 
30
- route '/', directory( 'examples/static/', 'examples.html', 'text/html' )
30
+ route '/', directory( 'static/', 'examples.html', 'text/html' )
31
31
 
32
32
  # Handlers
33
33
  route '/hello', handler( 'tcp://127.0.0.1:9900', 'hello-world' )
@@ -45,6 +45,7 @@ setting "zeromq.threads", 1
45
45
 
46
46
  setting 'limits.content_length', 8096
47
47
  setting 'upload.temp_store', 'var/uploads/mongrel2.upload.XXXXXX'
48
+ setting 'server.daemonize', false
48
49
 
49
50
  mkdir_p 'var/uploads'
50
51
  mkdir_p 'run'
@@ -234,8 +234,8 @@ module Strelka::App::Auth
234
234
  config_key :auth
235
235
 
236
236
  # Plugins API -- Set up load order
237
- run_before :routing, :restresources
238
- run_after :templating, :errors, :sessions
237
+ run_outside :routing, :restresources
238
+ run_inside :templating, :errors, :sessions
239
239
 
240
240
 
241
241
  # The name of the default plugin to use for authentication