strelka 0.0.1.pre.244 → 0.0.1.pre.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +57 -3
  3. data/Manifest.txt +3 -4
  4. data/Rakefile +1 -1
  5. data/bin/strelka +4 -7
  6. data/examples/.env +4 -0
  7. data/examples/Procfile +8 -0
  8. data/examples/apps/auth-demo +3 -5
  9. data/examples/apps/auth-demo2 +10 -9
  10. data/{data/strelka → examples}/apps/hello-world +1 -2
  11. data/examples/apps/sessions-demo +2 -2
  12. data/examples/config.yml +12 -1
  13. data/examples/gen-config.rb +5 -6
  14. data/examples/templates/auth-form.tmpl +4 -0
  15. data/examples/templates/auth-success.tmpl +3 -1
  16. data/lib/strelka.rb +15 -21
  17. data/lib/strelka/app.rb +53 -31
  18. data/lib/strelka/app/auth.rb +260 -132
  19. data/lib/strelka/app/sessions.rb +25 -31
  20. data/lib/strelka/authprovider/basic.rb +33 -9
  21. data/lib/strelka/authprovider/hostaccess.rb +1 -1
  22. data/lib/strelka/constants.rb +0 -11
  23. data/lib/strelka/cookie.rb +17 -1
  24. data/lib/strelka/httpresponse/negotiation.rb +1 -1
  25. data/lib/strelka/session/db.rb +49 -25
  26. data/lib/strelka/session/default.rb +39 -19
  27. data/spec/lib/helpers.rb +3 -24
  28. data/spec/strelka/app/auth_spec.rb +461 -177
  29. data/spec/strelka/app/sessions_spec.rb +7 -26
  30. data/spec/strelka/app_spec.rb +3 -3
  31. data/spec/strelka/authprovider/basic_spec.rb +4 -4
  32. data/spec/strelka/httprequest/session_spec.rb +1 -1
  33. data/spec/strelka/httpresponse/session_spec.rb +1 -1
  34. data/spec/strelka/session/db_spec.rb +6 -1
  35. data/spec/strelka/session/default_spec.rb +3 -3
  36. metadata +7 -8
  37. metadata.gz.sig +2 -2
  38. data/examples/apps/ws-echo +0 -17
  39. data/lib/strelka/logging.rb +0 -301
  40. data/spec/strelka/logging_spec.rb +0 -74
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,62 @@
1
+ 2012-05-31 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .tm_properties, lib/strelka/app/auth.rb,
4
+ lib/strelka/authprovider/basic.rb,
5
+ lib/strelka/authprovider/hostaccess.rb,
6
+ spec/strelka/app/auth_spec.rb,
7
+ spec/strelka/authprovider/basic_spec.rb:
8
+ Rewriting auth plugin to work app-agnostically
9
+ [f569df3baa60] [tip]
10
+
11
+ * lib/strelka/app/sessions.rb, lib/strelka/cookie.rb,
12
+ lib/strelka/session/db.rb, lib/strelka/session/default.rb,
13
+ spec/strelka/app/sessions_spec.rb,
14
+ spec/strelka/httprequest/session_spec.rb,
15
+ spec/strelka/httpresponse/session_spec.rb,
16
+ spec/strelka/session/db_spec.rb,
17
+ spec/strelka/session/default_spec.rb:
18
+ Made session configuration consistent
19
+ [0b493098c008]
20
+
21
+ 2012-05-30 Michael Granger <ged@FaerieMUD.org>
22
+
23
+ * data/strelka/apps/hello-world, examples/.env, examples/Procfile,
24
+ examples/apps/auth-demo, examples/apps/auth-demo2, examples/apps
25
+ /hello-world, examples/apps/sessions-demo, examples/apps/ws-echo,
26
+ examples/config.yml, examples/gen-config.rb, examples/templates
27
+ /auth-form.tmpl, examples/templates/auth-success.tmpl:
28
+ Consolidated examples into a more-cohesive environment
29
+ [a594decb869b]
30
+
31
+ * bin/strelka, lib/strelka.rb, lib/strelka/app.rb,
32
+ lib/strelka/constants.rb, lib/strelka/logging.rb,
33
+ spec/strelka/app_spec.rb, spec/strelka/logging_spec.rb:
34
+ Modify local discovery to be configurable
35
+ [c3b2a812c363]
36
+
37
+ 2012-05-29 Michael Granger <ged@FaerieMUD.org>
38
+
39
+ * .rvm.gems:
40
+ Update the inversion depenedency in RVM gemset, too
41
+ [6d2b72cb478f]
42
+
43
+ 2012-05-30 Michael Granger <ged@FaerieMUD.org>
44
+
45
+ * lib/strelka/httpresponse/negotiation.rb:
46
+ Dup the negotiated content type in case it's frozen.
47
+ [dcc8fd6d6c76]
48
+
1
49
  2012-05-21 Michael Granger <ged@FaerieMUD.org>
2
50
 
3
51
  * Rakefile:
4
52
  Updating Inversion dependency
5
- [87e4f57ec907] [tip]
53
+ [8309cf9a784a]
54
+
55
+ 2012-05-27 Michael Granger <ged@FaerieMUD.org>
56
+
57
+ * .rvm.gems, Rakefile, spec/lib/helpers.rb:
58
+ Update to Loggability 0.3 and use its spec helpers.
59
+ [dff6dc0f1b19]
6
60
 
7
61
  2012-05-23 Michael Granger <ged@FaerieMUD.org>
8
62
 
@@ -72,7 +126,7 @@
72
126
  - Adding a 'config' subcommand to dump Configurability defaults for
73
127
  discovered apps.
74
128
  - Update for Loggability changes.
75
- [f5c63705cd79] [github/master]
129
+ [f5c63705cd79]
76
130
 
77
131
  * lib/strelka/app.rb, lib/strelka/app/auth.rb:
78
132
  Adding support for config-discovery
@@ -646,7 +700,7 @@
646
700
 
647
701
  * lib/strelka/app/errors.rb, spec/strelka/app/errors_spec.rb:
648
702
  Add documentation for the Errors plugin, improve test coverage.
649
- [ff3ef6e5a7a1] [github/master@default]
703
+ [ff3ef6e5a7a1]
650
704
 
651
705
  * Manifest.txt:
652
706
  Add session files to the manifest
data/Manifest.txt CHANGED
@@ -16,11 +16,12 @@ contrib/hoetemplate/data/project/templates/layout.tmpl.erb
16
16
  contrib/hoetemplate/data/project/templates/top.tmpl.erb
17
17
  contrib/hoetemplate/lib/file_name.rb.erb
18
18
  contrib/hoetemplate/spec/file_name_spec.rb.erb
19
- data/strelka/apps/hello-world
19
+ examples/.env
20
+ examples/Procfile
20
21
  examples/apps/auth-demo
21
22
  examples/apps/auth-demo2
23
+ examples/apps/hello-world
22
24
  examples/apps/sessions-demo
23
- examples/apps/ws-echo
24
25
  examples/config.yml
25
26
  examples/gen-config.rb
26
27
  examples/static/examples.css
@@ -55,7 +56,6 @@ lib/strelka/httprequest/session.rb
55
56
  lib/strelka/httpresponse.rb
56
57
  lib/strelka/httpresponse/negotiation.rb
57
58
  lib/strelka/httpresponse/session.rb
58
- lib/strelka/logging.rb
59
59
  lib/strelka/mixins.rb
60
60
  lib/strelka/paramvalidator.rb
61
61
  lib/strelka/plugins.rb
@@ -94,7 +94,6 @@ spec/strelka/httprequest_spec.rb
94
94
  spec/strelka/httpresponse/negotiation_spec.rb
95
95
  spec/strelka/httpresponse/session_spec.rb
96
96
  spec/strelka/httpresponse_spec.rb
97
- spec/strelka/logging_spec.rb
98
97
  spec/strelka/mixins_spec.rb
99
98
  spec/strelka/paramvalidator_spec.rb
100
99
  spec/strelka/plugins_spec.rb
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ hoespec = Hoe.spec 'strelka' do
31
31
  self.dependency 'uuidtools', '~> 2.1'
32
32
  self.dependency 'configurability', '~> 1.0'
33
33
  self.dependency 'pluginfactory', '~> 1.0'
34
- self.dependency 'loggability', '~> 0.2'
34
+ self.dependency 'loggability', '~> 0.3'
35
35
  self.dependency 'foreman', '~> 0.46'
36
36
 
37
37
  self.dependency 'hoe-deveiate', '~> 0.1', :developer
data/bin/strelka CHANGED
@@ -205,10 +205,7 @@ class Strelka::CLICommand
205
205
  # Set the datadir override if it's given
206
206
  if self.options.datadir
207
207
  self.log.debug "Using data dir option: %s" % [ self.options.datadir ]
208
- Strelka.datadir = Pathname( self.options.datadir )
209
- elsif File.directory?( 'data' ) && subdir = Dir[ 'data/*' ].first
210
- self.log.debug "Using local data dir: %s" % [ subdir ]
211
- Strelka.datadir = subdir
208
+ Strelka::App.local_data_dirs = Pathname( self.options.datadir )
212
209
  end
213
210
 
214
211
  # Include a 'lib' directory if there is one
@@ -330,10 +327,10 @@ class Strelka::CLICommand
330
327
  discovered_apps[ discovery_name ].each do |apppath|
331
328
  message " loading %s (%s)" % [ apppath, apppath.basename('.rb') ]
332
329
  Strelka::App.load( apppath )
333
-
334
- message " dumping config:"
335
- $stdout.puts Configurability.default_config.dump
336
330
  end
331
+
332
+ message " dumping config:"
333
+ $stdout.puts Configurability.default_config.dump
337
334
  end
338
335
  help :config, "Dump the configuration for GEMNAME (or the local directory if no gem is specified)"
339
336
  usage :config, "[GEMNAME]"
data/examples/.env ADDED
@@ -0,0 +1,4 @@
1
+ STRELKA_DATADIR=.
2
+ RUNMODE=development
3
+ RUBYOPT=-I../lib
4
+ MONGREL2=/Users/mgranger/source/C/mongrel2/bin/mongrel2
data/examples/Procfile ADDED
@@ -0,0 +1,8 @@
1
+ # Foreman procfile
2
+ mongrel: m2sh.rb -c mongrel2.sqlite start
3
+ helloworld: ../bin/strelka -l info -c config.yml start hello-world
4
+ auth: ../bin/strelka -l info -c config.yml start auth-demo
5
+ auth2: ../bin/strelka -l info -c config.yml start auth-demo2
6
+ sessions: ../bin/strelka -l info -c config.yml start sessions-demo
7
+ # ws: ../bin/strelka -l info -c config.yml start ws-echo
8
+
@@ -9,10 +9,7 @@ class AuthDemo < Strelka::App
9
9
  # The Mongrel2 appid of this app
10
10
  ID = 'auth-demo'
11
11
 
12
- plugin :auth
13
- auth_provider :basic
14
-
15
- plugin :routing
12
+ plugins :auth, :routing
16
13
 
17
14
  ### Handle any (authenticated) HTTP request
18
15
  get do |req|
@@ -29,4 +26,5 @@ class AuthDemo < Strelka::App
29
26
 
30
27
  end # class AuthDemo
31
28
 
32
- AuthDemo.run
29
+ AuthDemo.run if __FILE__ == $0
30
+
@@ -12,19 +12,20 @@ class AuthDemo2 < Strelka::App
12
12
  # The Mongrel2 appid of this app
13
13
  ID = 'auth-demo2'
14
14
 
15
- plugins :auth, :errors, :templating
16
- auth_provider :session
15
+ plugins :auth, :errors, :templating, :routing
17
16
 
18
- layout 'examples/layout.tmpl'
17
+ default_type 'text/html'
18
+
19
+ layout 'templates/layout.tmpl'
19
20
  templates \
20
- form: 'examples/auth-form.tmpl',
21
- success: 'examples/auth-success.tmpl'
21
+ form: 'templates/auth-form.tmpl',
22
+ success: 'templates/auth-success.tmpl'
22
23
 
23
- on_status AUTH_REQUIRED, :form
24
+ on_status HTTP::AUTH_REQUIRED, :form
24
25
 
25
26
 
26
27
  ### Handle any (authenticated) HTTP request
27
- def handle_request( req )
28
+ get do |req|
28
29
  return :success
29
30
  end
30
31
 
@@ -32,6 +33,6 @@ class AuthDemo2 < Strelka::App
32
33
  end # class AuthDemo2
33
34
 
34
35
 
35
- Strelka.load_config( 'examples/config.yml' )
36
- AuthDemo2.run
36
+ AuthDemo2.run if __FILE__ == $0
37
+
37
38
 
@@ -18,8 +18,7 @@ class HelloWorldApp < Strelka::App
18
18
  # Handle all GET requests the same way
19
19
  get do |req|
20
20
  res = req.response
21
- res.status = HTTP::OK
22
- res << 'Hello, world!'
21
+ res.puts 'Hello, world!'
23
22
  return res
24
23
  end
25
24
 
@@ -39,5 +39,5 @@ class SessionsDemo < Strelka::App
39
39
  end # class SessionsDemo
40
40
 
41
41
 
42
- Strelka.load_config( 'examples/config.yml' )
43
- SessionsDemo.run
42
+ SessionsDemo.run if __FILE__ == $0
43
+
data/examples/config.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  mongrel2:
2
- configdb: amalgalite://examples/mongrel2.sqlite
2
+ configdb: amalgalite://mongrel2.sqlite
3
3
 
4
4
  auth:
5
+ provider: basic
6
+
7
+ basicauth:
5
8
  realm: Examples
6
9
  users:
7
10
  ged: "iEPX+SQWIR3p67lj/0zigSWTKHg="
@@ -17,3 +20,11 @@ templates:
17
20
  template_paths:
18
21
  - examples/templates
19
22
 
23
+ logging:
24
+ strelka: debug (color)
25
+ inversion: info (color)
26
+ configurability: debug (color)
27
+ mongrel2: debug (color)
28
+
29
+
30
+
@@ -27,15 +27,14 @@ server 'examples' do
27
27
 
28
28
  host 'localhost' do
29
29
 
30
- route '/', directory( 'examples/static/', 'examples.html', 'text/html' )
31
-
32
- authdemo = handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
30
+ route '/', directory( 'static/', 'examples.html', 'text/html' )
33
31
 
34
32
  # Handlers
35
- route '/hello', handler( 'tcp://127.0.0.1:9900', 'helloworld-handler' )
33
+ route '/hello', handler( 'tcp://127.0.0.1:9900', 'hello-world' )
36
34
  route '/sessions', handler( 'tcp://127.0.0.1:9905', 'sessions-demo' )
37
- route '/auth', authdemo
38
- route '/chunkers', authdemo
35
+ route '/auth', handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
36
+ route '/formauth', handler( 'tcp://127.0.0.1:9915', 'auth-demo2' )
37
+ route '/ws', handler( 'tcp://127.0.0.1:9920', 'ws-echo' )
39
38
 
40
39
  end
41
40
 
@@ -1,3 +1,7 @@
1
+ <?import request ?>
2
+
3
+ <?publish title ?>Please Log In<?end publish ?>
4
+
1
5
  <form action="[?call request.uri ?]" method="post" accept-charset="utf-8">
2
6
  <label for="username">Username</label>
3
7
  <input type="text" name="username" value="" id="username-input" />
@@ -1,3 +1,5 @@
1
+ <?import request ?>
2
+
1
3
  <?publish title ?>Auth Successful<?end publish ?>
2
4
 
3
- <p>You succesfully authenticated as: <?call request.user ?></p>
5
+ <p>You successfully authenticated as: <?call request.authenticated_user ?></p>
data/lib/strelka.rb CHANGED
@@ -27,14 +27,25 @@ module Strelka
27
27
  VERSION = '0.0.1'
28
28
 
29
29
  # Version-control revision constant
30
- REVISION = %q$Revision: 5288bf325ace $
30
+ REVISION = %q$Revision: c3b2a812c363 $
31
31
 
32
32
  require 'strelka/constants'
33
+ require 'strelka/exceptions'
33
34
  include Strelka::Constants
34
35
 
35
- require 'strelka/exceptions'
36
- require 'strelka/mixins'
37
- extend Strelka::MethodUtilities
36
+ autoload :AuthProvider, 'strelka/authprovider'
37
+ autoload :Cookie, 'strelka/cookie'
38
+ autoload :CookieSet, 'strelka/cookieset'
39
+ autoload :ParamValidator, 'strelka/httpresponse'
40
+ autoload :Plugin, 'strelka/plugins'
41
+ autoload :PluginLoader, 'strelka/plugins'
42
+ autoload :PluginRegistry, 'strelka/plugins'
43
+ autoload :Router, 'strelka/router'
44
+ autoload :Session, 'strelka/session'
45
+
46
+ require 'strelka/app'
47
+ require 'strelka/httprequest'
48
+ require 'strelka/httpresponse'
38
49
 
39
50
 
40
51
  ### Get the library version. If +include_buildnum+ is true, the version string will
@@ -46,23 +57,6 @@ module Strelka
46
57
  end
47
58
 
48
59
 
49
- ##
50
- # The Pathname of the directory that will be searched for default applications,
51
- # config, etc.
52
- singleton_attr_reader :datadir
53
-
54
- ### Set the local data directory to +dir+.
55
- def self::datadir=( dir )
56
- @datadir = Pathname( dir )
57
- end
58
- self.datadir = DEFAULT_DATADIR
59
-
60
-
61
- require 'strelka/app'
62
- require 'strelka/httprequest'
63
- require 'strelka/httpresponse'
64
-
65
-
66
60
  # The installed Configurability::Config object
67
61
  @config = nil
68
62
  class << self; attr_accessor :config; end
data/lib/strelka/app.rb CHANGED
@@ -31,16 +31,27 @@ class Strelka::App < Mongrel2::Handler
31
31
 
32
32
  # Glob for matching Strelka apps relative to a gem's data directory
33
33
  APP_GLOB_PATTERN = '{apps,handlers}/**/*'
34
+ APP_GLOB_PATTERN.freeze
35
+
36
+ # The glob for matching data directories relative to the PWD
37
+ LOCAL_DATA_DIRS = 'data/*'
38
+ LOCAL_DATA_DIRS.freeze
34
39
 
35
40
  # Default config
36
- CONFIG_DEFAULTS = { devmode: false }
41
+ CONFIG_DEFAULTS = {
42
+ devmode: false,
43
+ app_glob_pattern: APP_GLOB_PATTERN,
44
+ local_data_dirs: LOCAL_DATA_DIRS,
45
+ }.freeze
37
46
 
38
47
 
39
48
  # Class instance variables
40
- @devmode = false
41
- @default_type = nil
42
- @loading_file = nil
43
- @subclasses = Hash.new {|h,k| h[k] = [] }
49
+ @devmode = false
50
+ @default_type = nil
51
+ @loading_file = nil
52
+ @subclasses = Hash.new {|h,k| h[k] = [] }
53
+ @app_glob_pattern = APP_GLOB_PATTERN
54
+ @local_data_dirs = LOCAL_DATA_DIRS
44
55
 
45
56
 
46
57
  ##
@@ -52,6 +63,42 @@ class Strelka::App < Mongrel2::Handler
52
63
  # 'Developer mode' flag.
53
64
  singleton_attr_writer :devmode
54
65
 
66
+ ##
67
+ # The glob(3) pattern for matching Apps during discovery
68
+ singleton_attr_accessor :app_glob_pattern
69
+
70
+ ##
71
+ # The glob(3) pattern for matching local data directories during discovery. Local
72
+ # data directories are evaluated relative to the CWD.
73
+ singleton_attr_accessor :local_data_dirs
74
+
75
+
76
+ ### Configure the App. Override this if you wish to add additional configuration
77
+ ### to the 'app' section of the config that will be passed to you when the config
78
+ ### is loaded.
79
+ def self::configure( config=nil )
80
+ if config
81
+ self.devmode = true if config[:devmode]
82
+ self.app_glob_pattern = config[:app_glob_pattern]
83
+ self.local_data_dirs = config[:local_data_dirs]
84
+ else
85
+ self.devmode = $DEBUG ? true : false
86
+ self.app_glob_pattern = APP_GLOB_PATTERN
87
+ self.local_data_dirs = LOCAL_DATA_DIRS
88
+ end
89
+
90
+ self.log.info "Enabled developer mode." if self.devmode?
91
+ end
92
+
93
+
94
+ ### Returns +true+ if the application has been configured to run in 'developer mode'.
95
+ ### Developer mode is mostly informational by default (it just makes logging more
96
+ ### verbose), but plugins and such might alter their behavior based on this setting.
97
+ def self::devmode?
98
+ return @devmode
99
+ end
100
+ singleton_method_alias :in_devmode?, :devmode?
101
+
55
102
 
56
103
  ### Inheritance callback -- add subclasses to @subclasses so .load can figure out which
57
104
  ### classes correspond to which files.
@@ -94,10 +141,8 @@ class Strelka::App < Mongrel2::Handler
94
141
  ### Return a Hash of Strelka app files as Pathname objects from installed gems,
95
142
  ### keyed by gemspec name .
96
143
  def self::discover_paths
97
- self.log.debug "Local paths: %s" % [ Strelka.datadir + APP_GLOB_PATTERN ]
98
-
99
144
  appfiles = {
100
- '' => Pathname.glob( Strelka.datadir + APP_GLOB_PATTERN )
145
+ '' => Pathname.glob( File.join(self.local_data_dirs, self.app_glob_pattern) )
101
146
  }
102
147
 
103
148
  # Find all the gems that depend on Strelka
@@ -172,29 +217,6 @@ class Strelka::App < Mongrel2::Handler
172
217
  end
173
218
 
174
219
 
175
- ### Returns +true+ if the application has been configured to run in 'developer mode'.
176
- ### Developer mode is mostly informational by default (it just makes logging more
177
- ### verbose), but plugins and such might alter their behavior based on this setting.
178
- def self::devmode?
179
- return @devmode
180
- end
181
- singleton_method_alias :in_devmode?, :devmode?
182
-
183
-
184
- ### Configure the App. Override this if you wish to add additional configuration
185
- ### to the 'app' section of the config that will be passed to you when the config
186
- ### is loaded.
187
- def self::configure( config=nil )
188
- if config
189
- self.devmode = true if config[:devmode]
190
- else
191
- self.devmode = $DEBUG ? true : false
192
- end
193
-
194
- self.log.info "Enabled developer mode." if self.devmode?
195
- end
196
-
197
-
198
220
  #
199
221
  # :section: Application declarative methods
200
222
  #