strelka 0.0.1pre4 → 0.0.1.pre129

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/History.rdoc +1 -1
  2. data/IDEAS.rdoc +62 -0
  3. data/Manifest.txt +38 -7
  4. data/README.rdoc +124 -5
  5. data/Rakefile +22 -6
  6. data/bin/leash +102 -157
  7. data/contrib/hoetemplate/.autotest.erb +23 -0
  8. data/contrib/hoetemplate/History.rdoc.erb +4 -0
  9. data/contrib/hoetemplate/Manifest.txt.erb +8 -0
  10. data/contrib/hoetemplate/README.rdoc.erb +17 -0
  11. data/contrib/hoetemplate/Rakefile.erb +24 -0
  12. data/contrib/hoetemplate/data/file_name/apps/file_name_app +36 -0
  13. data/contrib/hoetemplate/data/file_name/templates/layout.tmpl.erb +13 -0
  14. data/contrib/hoetemplate/data/file_name/templates/top.tmpl.erb +8 -0
  15. data/contrib/hoetemplate/lib/file_name.rb.erb +18 -0
  16. data/contrib/hoetemplate/spec/file_name_spec.rb.erb +21 -0
  17. data/data/strelka/apps/hello-world +30 -0
  18. data/lib/strelka/app/defaultrouter.rb +49 -30
  19. data/lib/strelka/app/errors.rb +121 -0
  20. data/lib/strelka/app/exclusiverouter.rb +40 -0
  21. data/lib/strelka/app/filters.rb +18 -7
  22. data/lib/strelka/app/negotiation.rb +122 -0
  23. data/lib/strelka/app/parameters.rb +171 -14
  24. data/lib/strelka/app/paramvalidator.rb +751 -0
  25. data/lib/strelka/app/plugins.rb +66 -46
  26. data/lib/strelka/app/restresources.rb +499 -0
  27. data/lib/strelka/app/router.rb +73 -0
  28. data/lib/strelka/app/routing.rb +140 -18
  29. data/lib/strelka/app/templating.rb +12 -3
  30. data/lib/strelka/app.rb +174 -24
  31. data/lib/strelka/constants.rb +0 -20
  32. data/lib/strelka/exceptions.rb +29 -0
  33. data/lib/strelka/httprequest/acceptparams.rb +377 -0
  34. data/lib/strelka/httprequest/negotiation.rb +257 -0
  35. data/lib/strelka/httprequest.rb +155 -7
  36. data/lib/strelka/httpresponse/negotiation.rb +579 -0
  37. data/lib/strelka/httpresponse.rb +140 -0
  38. data/lib/strelka/logging.rb +4 -1
  39. data/lib/strelka/mixins.rb +53 -0
  40. data/lib/strelka.rb +22 -1
  41. data/spec/data/error.tmpl +1 -0
  42. data/spec/lib/constants.rb +0 -1
  43. data/spec/lib/helpers.rb +21 -0
  44. data/spec/strelka/app/defaultrouter_spec.rb +41 -35
  45. data/spec/strelka/app/errors_spec.rb +212 -0
  46. data/spec/strelka/app/exclusiverouter_spec.rb +220 -0
  47. data/spec/strelka/app/filters_spec.rb +196 -0
  48. data/spec/strelka/app/negotiation_spec.rb +73 -0
  49. data/spec/strelka/app/parameters_spec.rb +149 -0
  50. data/spec/strelka/app/paramvalidator_spec.rb +1059 -0
  51. data/spec/strelka/app/plugins_spec.rb +26 -19
  52. data/spec/strelka/app/restresources_spec.rb +393 -0
  53. data/spec/strelka/app/router_spec.rb +63 -0
  54. data/spec/strelka/app/routing_spec.rb +183 -9
  55. data/spec/strelka/app/templating_spec.rb +1 -2
  56. data/spec/strelka/app_spec.rb +265 -32
  57. data/spec/strelka/exceptions_spec.rb +53 -0
  58. data/spec/strelka/httprequest/acceptparams_spec.rb +282 -0
  59. data/spec/strelka/httprequest/negotiation_spec.rb +246 -0
  60. data/spec/strelka/httprequest_spec.rb +204 -14
  61. data/spec/strelka/httpresponse/negotiation_spec.rb +464 -0
  62. data/spec/strelka/httpresponse_spec.rb +114 -0
  63. data/spec/strelka/mixins_spec.rb +99 -0
  64. data.tar.gz.sig +1 -0
  65. metadata +175 -79
  66. metadata.gz.sig +2 -0
  67. data/IDEAS.textile +0 -174
  68. data/data/strelka/apps/strelka-admin +0 -65
  69. data/data/strelka/apps/strelka-setup +0 -26
  70. data/data/strelka/bootstrap-config.rb +0 -34
  71. data/data/strelka/templates/admin/console.tmpl +0 -21
  72. data/data/strelka/templates/layout.tmpl +0 -30
  73. data/lib/strelka/process.rb +0 -19
data/History.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- == 0.0.1 [2011-08-29] Michael Granger <ged@FaerieMUD.org>
1
+ == v0.0.1 [2011-08-29] Michael Granger <ged@FaerieMUD.org>
2
2
 
3
3
  Initial release.
4
4
 
data/IDEAS.rdoc ADDED
@@ -0,0 +1,62 @@
1
+ = Strelka Ideas
2
+
3
+ This is in-progress documentation for stuff that doesn't yet work, but is
4
+ planned for a future release.
5
+
6
+ Everything here is subject to change, but we'll try to keep this document
7
+ up-to-date if it does.
8
+
9
+ == Leash
10
+
11
+ Setting up a new server from scratch:
12
+
13
+ $ leash setup
14
+
15
+ Adding an admin server to an existing server config:
16
+
17
+ $ leash setup existing.sqlite
18
+
19
+ Start all the configured apps for every server in the default config:
20
+
21
+ $ leash start
22
+
23
+ The admin app will then let you examine and edit the configuration for your
24
+ existing mongrel2 server, just as you would with a new server.
25
+
26
+
27
+ === Join a Mongrel2 Cluster
28
+
29
+ Once you have the first node set up, you need only point 'leash' to the admin
30
+ server running on the first host to set up and automatically configure
31
+ additional Mongrel2 front-ends:
32
+
33
+ server2$ leash join server1
34
+
35
+ This uses a 0MQ service running from the admin server that publishes the
36
+ config using Mongrel2's "config from anything" protocol, so when Mongrel2
37
+ itself supports the 'zmq.so' plugin, you won't even need a local SQLite
38
+ database.
39
+
40
+
41
+ == Strelka Applications
42
+
43
+ * Apps have an appid constant (the mongrel2 UUID)
44
+ * Apps are distributed in gems
45
+ * A larger app can be split across multiple applets within a gem
46
+ - The gem can suggest a set of routes
47
+ - The Strelka admin interface can display the gem with its suggested routes
48
+ * The framework provides convenience methods for looking up the route to
49
+ another app via its appid.
50
+
51
+ For example, a CMS called "Snipper" might come in a gem called 'snipper'
52
+
53
+ === Future Plugins
54
+
55
+ * CORS (cors) — manage {Cross-Origin Resource Sharing}[http://www.html5rocks.com/en/tutorials/cors/]
56
+ headers
57
+
58
+
59
+
60
+
61
+ == Deployment
62
+
data/Manifest.txt CHANGED
@@ -1,38 +1,69 @@
1
+ .gemtest
1
2
  History.rdoc
2
- IDEAS.textile
3
+ IDEAS.rdoc
3
4
  Manifest.txt
4
5
  README.rdoc
5
6
  Rakefile
6
7
  bin/leash
7
- data/strelka/apps/strelka-admin
8
- data/strelka/apps/strelka-setup
9
- data/strelka/bootstrap-config.rb
10
- data/strelka/templates/admin/console.tmpl
11
- data/strelka/templates/layout.tmpl
8
+ contrib/hoetemplate/.autotest.erb
9
+ contrib/hoetemplate/History.rdoc.erb
10
+ contrib/hoetemplate/Manifest.txt.erb
11
+ contrib/hoetemplate/README.rdoc.erb
12
+ contrib/hoetemplate/Rakefile.erb
13
+ contrib/hoetemplate/data/file_name/apps/file_name_app
14
+ contrib/hoetemplate/data/file_name/templates/layout.tmpl.erb
15
+ contrib/hoetemplate/data/file_name/templates/top.tmpl.erb
16
+ contrib/hoetemplate/lib/file_name.rb.erb
17
+ contrib/hoetemplate/spec/file_name_spec.rb.erb
18
+ data/strelka/apps/hello-world
12
19
  lib/strelka.rb
13
20
  lib/strelka/app.rb
14
21
  lib/strelka/app/defaultrouter.rb
22
+ lib/strelka/app/errors.rb
23
+ lib/strelka/app/exclusiverouter.rb
15
24
  lib/strelka/app/filters.rb
25
+ lib/strelka/app/negotiation.rb
16
26
  lib/strelka/app/parameters.rb
27
+ lib/strelka/app/paramvalidator.rb
17
28
  lib/strelka/app/plugins.rb
29
+ lib/strelka/app/restresources.rb
30
+ lib/strelka/app/router.rb
18
31
  lib/strelka/app/routing.rb
19
32
  lib/strelka/app/templating.rb
20
33
  lib/strelka/behavior/plugin.rb
21
34
  lib/strelka/constants.rb
35
+ lib/strelka/exceptions.rb
22
36
  lib/strelka/httprequest.rb
37
+ lib/strelka/httprequest/acceptparams.rb
38
+ lib/strelka/httprequest/negotiation.rb
39
+ lib/strelka/httpresponse.rb
40
+ lib/strelka/httpresponse/negotiation.rb
23
41
  lib/strelka/logging.rb
24
42
  lib/strelka/mixins.rb
25
- lib/strelka/process.rb
43
+ spec/data/error.tmpl
26
44
  spec/data/layout.tmpl
27
45
  spec/data/main.tmpl
28
46
  spec/lib/constants.rb
29
47
  spec/lib/helpers.rb
30
48
  spec/strelka/app/defaultrouter_spec.rb
49
+ spec/strelka/app/errors_spec.rb
50
+ spec/strelka/app/exclusiverouter_spec.rb
51
+ spec/strelka/app/filters_spec.rb
52
+ spec/strelka/app/negotiation_spec.rb
31
53
  spec/strelka/app/parameters_spec.rb
54
+ spec/strelka/app/paramvalidator_spec.rb
32
55
  spec/strelka/app/plugins_spec.rb
56
+ spec/strelka/app/restresources_spec.rb
57
+ spec/strelka/app/router_spec.rb
33
58
  spec/strelka/app/routing_spec.rb
34
59
  spec/strelka/app/templating_spec.rb
35
60
  spec/strelka/app_spec.rb
61
+ spec/strelka/exceptions_spec.rb
62
+ spec/strelka/httprequest/acceptparams_spec.rb
63
+ spec/strelka/httprequest/negotiation_spec.rb
36
64
  spec/strelka/httprequest_spec.rb
65
+ spec/strelka/httpresponse/negotiation_spec.rb
66
+ spec/strelka/httpresponse_spec.rb
37
67
  spec/strelka/logging_spec.rb
68
+ spec/strelka/mixins_spec.rb
38
69
  spec/strelka_spec.rb
data/README.rdoc CHANGED
@@ -1,24 +1,143 @@
1
- = strelka
1
+ = Strelka
2
2
 
3
3
  * http://deveiate.org/projects/Strelka
4
4
 
5
5
  == Description
6
6
 
7
7
  Strelka is a framework for creating and deploying Mongrel2 web applications
8
- in Ruby. It's still pre-alpha.
8
+ in Ruby, and for managing a Mongrel2 cluster.
9
9
 
10
- Strelka is named after a Russian dog who was one of the first space travelers
10
+ It's named after the Russian dog who was one of the first space travelers
11
11
  to orbit the Earth and return alive.
12
12
 
13
13
 
14
+ == Prerequisites
15
+
16
+ * Mongrel2[http://mongrel2.org/]
17
+ * Ruby 1.9.3 or better
18
+
19
+
14
20
  == Installation
15
21
 
16
- gem install strelka
22
+ $ gem install strelka
17
23
 
18
24
 
19
25
  == Usage
20
26
 
27
+ Strelka is an application framework built on top of the Ruby-Mongrel2
28
+ connector. It also includes a command-line tool for discovering Strelka
29
+ application gems that are installed, setting up an application's
30
+ runtime directory, and starting a Strelka application.
31
+
32
+
33
+ === Leash
34
+
35
+ Strelka comes with a command-line tool called 'leash' that you can use to
36
+ make setting up and starting a Strelka application backend a little bit easier.
37
+
38
+ To see a list of the available Strelka applications, run
39
+ <tt>leash discover</tt>:
40
+
41
+ $ leash discover
42
+ Searching for Strelka applications...
43
+ Found:
44
+
45
+ hello-world
46
+
47
+ $ gem install strelka-admin
48
+ Successfully installed strelka-admin-1.1.0
49
+ 1 gem installed
50
+
51
+ $ leash discover
52
+ Searching for Strelka applications...
53
+ Found:
54
+
55
+ hello-world strelka-admin config-service
56
+
57
+
58
+ To set up a new application runtime directory, run <tt>leash setup</tt>
59
+ with the path to the directory and the name of the application:
60
+
61
+ $ leash setup /usr/local/myapp hello-world
62
+ Creating directory...
63
+ Creating barebones config...
64
+
65
+
66
+ === The Application Framework
67
+
68
+ The application framework is primarily geared towards developing web (HTTP)
69
+ applications at the moment, but the intention is to make Strelka useful for
70
+ developing applications that use the other protocols supported by Mongrel2
71
+ at some point as well.
72
+
73
+ The framework is centered around the Strelka::App class, which is what you'll
74
+ subclass when creating your own applications. It's pretty minimal by itself;
75
+ Strelka applications are composed out of plugins that mix in the specific
76
+ framework parts you specify, so you get exactly what you need and nothing
77
+ more.
78
+
79
+ The plugins system itself is contained in the Strelka::App::Plugins mixin,
80
+ which is included in Strelka::App already. This adds the +plugins+
81
+ declarative, which you use from your app to load the plugins you want to use.
82
+
83
+ A very basic application might look like this:
84
+
85
+ #!/usr/bin/env ruby
86
+
87
+ require 'strelka'
88
+
89
+ # The Strelka admin web console.
90
+ class HelloWorldApp < Strelka::App
91
+
92
+ # The route appid that will configure this app's
93
+ # connection to Mongrel2 if no appid is given
94
+ # to App.run
95
+ ID = 'hello-world'
96
+
97
+ # Use Sinatra-like routing
98
+ plugins :routing
99
+
100
+ # Set responses to plaintext if they don't specify differently
101
+ default_type 'text/plain'
102
+
103
+ # Handle all GET requests the same way
104
+ get do |req|
105
+ res = req.response
106
+ res.status = HTTP::OK
107
+ res << 'Hello, world!'
108
+ return res
109
+ end
110
+
111
+ end # class HelloWorldApp
112
+
113
+
114
+ # Run the app
115
+ HelloWorldApp.run if __FILE__ == $0
116
+
117
+ This app uses the 'routing' plugin, which adds Sinatra-like hooks for matching
118
+ callbacks to requests. The example app above responds only to 'GET' requests,
119
+ and ignores the path of the request altogether.
120
+
121
+ Strelka comes with a few default plugins, but you can define your own fairly
122
+ easily.
123
+
124
+
125
+ === Default Plugins
21
126
 
127
+ [routing[rdoc-ref:Strelka::App::Routing]]
128
+ Sinatra-ish request routing.
129
+ [parameters[rdoc-ref:Strelka::App::Parameters]]
130
+ Query and URI path-parameter validation and untainting.
131
+ [filters[rdoc-ref:Strelka::App::Filters]]
132
+ Request/response filters, for doing things like compression, content-type
133
+ negotiation, or other things that somehow modify every request or response.
134
+ [templating[rdoc-ref:Strelka::App::Templating]]
135
+ Templating via the Inversion template engine.
136
+ [errors[rdoc-ref:Strelka::App::Errors]]
137
+ Custom error-handling.
138
+ [restresources[rdoc-ref:Strelka::App::RestResources]]
139
+ Automatically set up RESTful service resources for Sequel::Model-derived
140
+ classes.
22
141
 
23
142
  == Contributing
24
143
 
@@ -36,7 +155,7 @@ and generate the API documentation.
36
155
 
37
156
  == License
38
157
 
39
- Copyright (c) 2011, Michael Granger
158
+ Copyright (c) 2011-2012, Michael Granger
40
159
  All rights reserved.
41
160
 
42
161
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
+ require 'rake/clean'
4
+
3
5
  begin
4
6
  require 'hoe'
5
7
  rescue LoadError
@@ -8,25 +10,33 @@ end
8
10
 
9
11
  Hoe.plugin :mercurial
10
12
  Hoe.plugin :signing
13
+ Hoe.plugin :manualgen
11
14
 
12
15
  Hoe.plugins.delete :rubyforge
13
16
 
14
17
  hoespec = Hoe.spec 'strelka' do
15
18
  self.readme_file = 'README.rdoc'
16
19
  self.history_file = 'History.rdoc'
17
- self.extra_rdoc_files << 'README.rdoc' << 'History.rdoc'
20
+ self.extra_rdoc_files = FileList[ '*.rdoc' ]
18
21
 
19
22
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
20
23
 
21
- self.dependency 'mongrel2', '~> 0.2.3'
24
+ self.dependency 'mongrel2', '~> 0.15'
22
25
  self.dependency 'configurability', '~> 1.0'
23
- self.dependency 'inversion', '~> 0.1'
26
+ self.dependency 'inversion', '~> 0.2'
27
+ self.dependency 'trollop', '~> 1.16'
28
+ self.dependency 'highline', '~> 1.6'
29
+ self.dependency 'formvalidator', '~> 0.1.5'
30
+ self.dependency 'uuidtools', '~> 2.1.2'
31
+ self.dependency 'sysexits', '~> 1.0'
32
+ self.dependency 'pluginfactory', '~> 1.0'
24
33
 
25
- self.dependency 'tilt', '~> 1.3', :developer
26
34
  self.dependency 'rspec', '~> 2.6', :developer
27
35
 
28
36
  self.spec_extras[:licenses] = ["BSD"]
29
- self.require_ruby_version( '>=1.8.7' )
37
+ self.require_ruby_version( '>=1.9.2' )
38
+ self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
39
+ self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
30
40
 
31
41
  self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
32
42
  end
@@ -34,7 +44,7 @@ end
34
44
  ENV['VERSION'] ||= hoespec.spec.version.to_s
35
45
 
36
46
  # Ensure the specs pass before checking in
37
- task 'hg:precheckin' => :spec
47
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
38
48
 
39
49
  ### Make the ChangeLog update if the repo has changed since it was last built
40
50
  file '.hg/branch'
@@ -62,3 +72,9 @@ if Rake::Task.task_defined?( '.gemtest' )
62
72
  $stderr.puts "Not including a .gemtest until I'm confident the test suite is idempotent."
63
73
  end
64
74
  end
75
+
76
+
77
+ # Add admin app testing directories to the clobber list
78
+ CLOBBER.include( 'static', 'run', 'log', 'strelka.sqlite' )
79
+
80
+