nitro 0.13.0 → 0.14.0

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 (64) hide show
  1. data/CHANGELOG +91 -1632
  2. data/INSTALL +44 -0
  3. data/README +1 -1
  4. data/Rakefile +3 -3
  5. data/doc/CHANGELOG.2 +1688 -0
  6. data/doc/RELEASES +84 -1
  7. data/examples/blog/cache/entriesadmin +12 -0
  8. data/examples/blog/conf/apache.conf.new +53 -0
  9. data/examples/blog/conf/lhttpd.conf +23 -180
  10. data/examples/blog/log/apache.error_log +271 -0
  11. data/examples/blog/log/rewrite_log +161 -0
  12. data/examples/blog/public/fcgi.rb +2 -0
  13. data/examples/blog/run.rb +4 -3
  14. data/examples/blog/src/controller.rb +10 -4
  15. data/examples/blog/src/views/index.xhtml +3 -0
  16. data/examples/blog/src/xsl/base.xsl +7 -0
  17. data/examples/no_xsl_blog/conf/lhttpd.conf +24 -181
  18. data/examples/tiny/conf/lhttpd.conf +24 -181
  19. data/examples/tiny/log/apache.error_log +24 -0
  20. data/examples/tiny/public/index.xhtml +0 -6
  21. data/examples/tiny/public/upload.xhtml +12 -14
  22. data/examples/wee_style/run.rb +2 -0
  23. data/examples/why_wiki/run.rb +2 -0
  24. data/lib/nitro.rb +2 -2
  25. data/lib/nitro/adapters/cgi.rb +36 -109
  26. data/lib/nitro/adapters/webrick.rb +76 -62
  27. data/lib/nitro/caching.rb +29 -0
  28. data/lib/nitro/caching/actions.rb +67 -0
  29. data/lib/nitro/caching/fragments.rb +72 -0
  30. data/lib/nitro/caching/invalidation.rb +51 -0
  31. data/lib/nitro/caching/output.rb +72 -0
  32. data/lib/nitro/caching/stores.rb +84 -0
  33. data/lib/nitro/controller.rb +3 -1
  34. data/lib/nitro/dispatcher.rb +0 -1
  35. data/lib/nitro/filters.rb +112 -55
  36. data/lib/nitro/mail.rb +6 -3
  37. data/lib/nitro/render.rb +27 -4
  38. data/lib/nitro/request.rb +13 -1
  39. data/test/nitro/tc_controller.rb +6 -4
  40. data/test/nitro/tc_filters.rb +111 -0
  41. metadata +19 -29
  42. data/examples/why_wiki/wiki.yml +0 -1
  43. data/vendor/README +0 -11
  44. data/vendor/binding_of_caller.rb +0 -81
  45. data/vendor/blankslate.rb +0 -53
  46. data/vendor/breakpoint.rb +0 -523
  47. data/vendor/breakpoint_client.rb +0 -196
  48. data/vendor/extensions/_base.rb +0 -153
  49. data/vendor/extensions/_template.rb +0 -36
  50. data/vendor/extensions/all.rb +0 -21
  51. data/vendor/extensions/array.rb +0 -68
  52. data/vendor/extensions/binding.rb +0 -224
  53. data/vendor/extensions/class.rb +0 -50
  54. data/vendor/extensions/continuation.rb +0 -71
  55. data/vendor/extensions/enumerable.rb +0 -250
  56. data/vendor/extensions/hash.rb +0 -23
  57. data/vendor/extensions/io.rb +0 -58
  58. data/vendor/extensions/kernel.rb +0 -42
  59. data/vendor/extensions/module.rb +0 -114
  60. data/vendor/extensions/numeric.rb +0 -230
  61. data/vendor/extensions/object.rb +0 -164
  62. data/vendor/extensions/ostruct.rb +0 -41
  63. data/vendor/extensions/string.rb +0 -316
  64. data/vendor/extensions/symbol.rb +0 -28
data/lib/nitro/request.rb CHANGED
@@ -52,7 +52,7 @@ module Request
52
52
  # The path is the uri without the query string.
53
53
 
54
54
  def path
55
- uri ? uri.split('?').first : ''
55
+ path = uri ? uri.split('?').first : ''
56
56
  end
57
57
 
58
58
  def path_info
@@ -71,6 +71,12 @@ module Request
71
71
  @headers['REQUEST_METHOD'].downcase.intern
72
72
  end
73
73
 
74
+ # Is this a post method?
75
+
76
+ def post?
77
+ method == :post
78
+ end
79
+
74
80
  # Return the referer. For the initial page in the
75
81
  # clickstream there is no referer, set "/" by default.
76
82
 
@@ -78,6 +84,12 @@ module Request
78
84
  return @headers['HTTP_REFERER'] || '/'
79
85
  end
80
86
 
87
+ # The content_length
88
+
89
+ def content_length
90
+ return @headers['CONTENT_LENGTH'].to_i
91
+ end
92
+
81
93
  # The remote IP address. REMOTE_ADDR is the standard
82
94
  # but will fail if the user is behind a proxy.
83
95
  # HTTP_CLIENT_IP and/or HTTP_X_FORWARDED_FOR are set by
@@ -10,7 +10,7 @@ require 'nitro/controller'
10
10
  class TC_Controller < Test::Unit::TestCase # :nodoc: all
11
11
  include N
12
12
 
13
- class BlogController < Controller
13
+ class Blog2Controller < Controller
14
14
  attr_reader :aflag, :tflag
15
15
 
16
16
  def initialize(context)
@@ -25,7 +25,7 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
25
25
 
26
26
  def setup
27
27
  @disp = Dispatcher.new({
28
- 'blog' => BlogController,
28
+ 'blog' => Blog2Controller,
29
29
  })
30
30
  @disp.template_root = File.join(File.dirname(__FILE__), '..', 'public')
31
31
  @conf = OpenStruct.new
@@ -39,6 +39,8 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
39
39
  ctx.headers['REQUEST_URI'] = '/blog/list'
40
40
  klass, action = ctx.dispatcher.dispatch(ctx.path, ctx)
41
41
  c = klass.new(ctx)
42
+ p klass.before_filters, klass.after_filters
43
+ p '--', Controller.before_filters, Controller.after_filters
42
44
  begin
43
45
  c.send(action)
44
46
  rescue RenderExit
@@ -52,8 +54,8 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
52
54
 
53
55
  def test_action_methods
54
56
  # aflag/tflag are counted too!
55
- assert_equal 3, BlogController.action_methods.size
56
- assert BlogController.action_methods.include?('list')
57
+ assert_equal 3, Blog2Controller.action_methods.size
58
+ assert Blog2Controller.action_methods.include?('list')
57
59
  end
58
60
 
59
61
  end
@@ -0,0 +1,111 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
2
+
3
+ require 'test/unit'
4
+ require 'ostruct'
5
+
6
+ require 'nitro/dispatcher'
7
+ require 'nitro/context'
8
+ require 'nitro/controller'
9
+ require 'nitro/filters'
10
+
11
+ class TestCaseFilters < Test::Unit::TestCase # :nodoc: all
12
+ include N
13
+
14
+ class MyController < Controller
15
+
16
+ attr_accessor :login_f, :pre_f, :post_f
17
+
18
+ before_filter :pre, :only => :login
19
+ after_filter :post, :except => :login
20
+
21
+ def initialize(*args)
22
+ super
23
+ @login_f = @pre_f = @post_f = 0
24
+ end
25
+
26
+ def login
27
+ @login_f = @pre_f + @post_f + 1
28
+ render_nothing
29
+ end
30
+
31
+ def logout
32
+ @login_f = @pre_f + @post_f + 1
33
+ render_nothing
34
+ end
35
+
36
+ private
37
+
38
+ def pre
39
+ @pre_f += 1
40
+ end
41
+
42
+ def post
43
+ @post_f += 1
44
+ end
45
+ end
46
+
47
+ class AnotherController < MyController
48
+ before_filter :more
49
+
50
+ def register
51
+ @login_f = @pre_f + @post_f + 1
52
+ render_nothing
53
+ end
54
+
55
+ private
56
+
57
+ def more
58
+ @a = 2
59
+ end
60
+ end
61
+
62
+ def setup
63
+ @disp = Dispatcher.new(
64
+ 'my' => MyController,
65
+ 'another' => AnotherController
66
+ )
67
+ @conf = OpenStruct.new
68
+ @conf.dispatcher = @disp
69
+ @ctx = Context.new(@conf)
70
+ @ctx.headers = {}
71
+ @ctx.params = {}
72
+ end
73
+
74
+ def teardown
75
+ @conf = @ctx = nil
76
+ end
77
+
78
+ def test_options
79
+ c = MyController.new(@ctx)
80
+
81
+ c.__xhtml__login
82
+ assert_equal 2, c.login_f
83
+ assert_equal 1, c.pre_f
84
+ assert_equal 0, c.post_f
85
+
86
+ c.__xhtml__logout
87
+ assert_equal 2, c.login_f
88
+ assert_equal 1, c.pre_f
89
+ assert_equal 1, c.post_f
90
+ end
91
+
92
+ def test_inheritable
93
+ c = AnotherController.new(@ctx)
94
+
95
+ c.__xhtml__register
96
+ assert_equal 1, c.login_f
97
+ assert_equal 0, c.pre_f
98
+ assert_equal 1, c.post_f
99
+
100
+ # bug: test filters not propageted.
101
+
102
+ assert_equal 0, Controller.before_filters.size
103
+ assert_equal 1, MyController.before_filters.size
104
+ assert_equal 2, AnotherController.before_filters.size
105
+
106
+ assert_equal 0, Controller.after_filters.size
107
+ assert_equal 1, MyController.after_filters.size
108
+ assert_equal 1, AnotherController.after_filters.size
109
+ end
110
+
111
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.8
2
+ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: nitro
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.13.0
7
- date: 2005-03-17
6
+ version: 0.14.0
7
+ date: 2005-03-28
8
8
  summary: Nitro Web Engine
9
9
  require_paths:
10
10
  - lib
@@ -98,7 +98,6 @@ files:
98
98
  - examples/no_xsl_blog/lib/blog/template.rb
99
99
  - examples/no_xsl_blog/lib/blog/model.rb
100
100
  - examples/no_xsl_blog/lib/blog/controller.rb
101
- - examples/why_wiki/wiki.yml
102
101
  - examples/why_wiki/run.rb
103
102
  - examples/why_wiki/README
104
103
  - examples/flash/log
@@ -126,14 +125,18 @@ files:
126
125
  - examples/wee_style/README
127
126
  - examples/blog/log
128
127
  - examples/blog/conf
128
+ - examples/blog/cache
129
129
  - examples/blog/public
130
130
  - examples/blog/src
131
131
  - examples/blog/run.rb
132
132
  - examples/blog/README
133
133
  - examples/blog/log/apache.error_log
134
+ - examples/blog/log/rewrite_log
134
135
  - examples/blog/log/README
135
136
  - examples/blog/conf/apache.conf
136
137
  - examples/blog/conf/lhttpd.conf
138
+ - examples/blog/conf/apache.conf.new
139
+ - examples/blog/cache/entriesadmin
137
140
  - examples/blog/public/style.css
138
141
  - examples/blog/public/m
139
142
  - examples/blog/public/fcgi.rb
@@ -181,9 +184,13 @@ files:
181
184
  - doc/RELEASES
182
185
  - doc/tutorial.txt
183
186
  - doc/architecture.txt
187
+ - doc/CHANGELOG.2
184
188
  - doc/bugs.txt
185
189
  - lib/nitro
186
190
  - lib/nitro.rb
191
+ - lib/nitro/caching.rb
192
+ - lib/nitro/caching
193
+ - lib/nitro/testing
187
194
  - lib/nitro/localization.rb
188
195
  - lib/nitro/cookie.rb
189
196
  - lib/nitro/session.rb
@@ -213,6 +220,11 @@ files:
213
220
  - lib/nitro/component.rb
214
221
  - lib/nitro/markup.rb
215
222
  - lib/nitro/filters.rb
223
+ - lib/nitro/caching/invalidation.rb
224
+ - lib/nitro/caching/output.rb
225
+ - lib/nitro/caching/fragments.rb
226
+ - lib/nitro/caching/actions.rb
227
+ - lib/nitro/caching/stores.rb
216
228
  - lib/nitro/adapters/cgi.rb
217
229
  - lib/nitro/adapters/fastcgi.rb
218
230
  - lib/nitro/adapters/webrick.rb
@@ -239,6 +251,7 @@ files:
239
251
  - test/nitro/ui
240
252
  - test/nitro/tc_mail.rb
241
253
  - test/nitro/tc_context.rb
254
+ - test/nitro/tc_filters.rb
242
255
  - test/nitro/tc_dispatcher.rb
243
256
  - test/nitro/adapters/tc_webrick.rb
244
257
  - test/nitro/adapters/tc_cgi.rb
@@ -252,29 +265,6 @@ files:
252
265
  - test/public/dummy_mailer
253
266
  - test/public/blog/list.xhtml
254
267
  - test/public/dummy_mailer/registration.xhtml
255
- - vendor/breakpoint_client.rb
256
- - vendor/extensions
257
- - vendor/binding_of_caller.rb
258
- - vendor/blankslate.rb
259
- - vendor/breakpoint.rb
260
- - vendor/README
261
- - vendor/extensions/enumerable.rb
262
- - vendor/extensions/all.rb
263
- - vendor/extensions/hash.rb
264
- - vendor/extensions/continuation.rb
265
- - vendor/extensions/module.rb
266
- - vendor/extensions/binding.rb
267
- - vendor/extensions/ostruct.rb
268
- - vendor/extensions/kernel.rb
269
- - vendor/extensions/class.rb
270
- - vendor/extensions/numeric.rb
271
- - vendor/extensions/_base.rb
272
- - vendor/extensions/io.rb
273
- - vendor/extensions/string.rb
274
- - vendor/extensions/object.rb
275
- - vendor/extensions/array.rb
276
- - vendor/extensions/symbol.rb
277
- - vendor/extensions/_template.rb
278
268
  test_files: []
279
269
  rdoc_options:
280
270
  - "--main"
@@ -301,7 +291,7 @@ dependencies:
301
291
  -
302
292
  - "="
303
293
  - !ruby/object:Gem::Version
304
- version: 0.13.0
294
+ version: 0.14.0
305
295
  version:
306
296
  - !ruby/object:Gem::Dependency
307
297
  name: og
@@ -311,7 +301,7 @@ dependencies:
311
301
  -
312
302
  - "="
313
303
  - !ruby/object:Gem::Version
314
- version: 0.13.0
304
+ version: 0.14.0
315
305
  version:
316
306
  - !ruby/object:Gem::Dependency
317
307
  name: ruby-breakpoint
@@ -1 +0,0 @@
1
- --- {}
data/vendor/README DELETED
@@ -1,11 +0,0 @@
1
- = Extensions and Libraries from other vendors.
2
-
3
- Libraries from other vendors belong here. This file
4
-
5
- === Included libraries
6
-
7
- * extensions
8
- * breakpointer
9
- * dev-utils
10
- * postgres-pr
11
-
@@ -1,81 +0,0 @@
1
- begin
2
- require 'simplecc'
3
- rescue LoadError
4
- def Continuation.create(*args, &block)
5
- cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
6
- result ||= args
7
- return *[cc, *result]
8
- end
9
- end
10
-
11
- # This method returns the binding of the method that called your
12
- # method. It will raise an Exception when you're not inside a method.
13
- #
14
- # It's used like this:
15
- # def inc_counter(amount = 1)
16
- # Binding.of_caller do |binding|
17
- # # Create a lambda that will increase the variable 'counter'
18
- # # in the caller of this method when called.
19
- # inc = eval("lambda { |arg| counter += arg }", binding)
20
- # # We can refer to amount from inside this block safely.
21
- # inc.call(amount)
22
- # end
23
- # # No other statements can go here. Put them inside the block.
24
- # end
25
- # counter = 0
26
- # 2.times { inc_counter }
27
- # counter # => 2
28
- #
29
- # Binding.of_caller must be the last statement in the method.
30
- # This means that you will have to put everything you want to
31
- # do after the call to Binding.of_caller into the block of it.
32
- # This should be no problem however, because Ruby has closures.
33
- # If you don't do this an Exception will be raised. Because of
34
- # the way that Binding.of_caller is implemented it has to be
35
- # done this way.
36
- def Binding.of_caller(&block)
37
- old_critical = Thread.critical
38
- Thread.critical = true
39
- count = 0
40
- cc, result, error, extra_data = Continuation.create(nil, nil)
41
- error.call if error
42
-
43
- tracer = lambda do |*args|
44
- type, context, extra_data = args[0], args[4], args
45
- if type == "return"
46
- count += 1
47
- # First this method and then calling one will return --
48
- # the trace event of the second event gets the context
49
- # of the method which called the method that called this
50
- # method.
51
- if count == 2
52
- # It would be nice if we could restore the trace_func
53
- # that was set before we swapped in our own one, but
54
- # this is impossible without overloading set_trace_func
55
- # in current Ruby.
56
- set_trace_func(nil)
57
- cc.call(eval("binding", context), nil, extra_data)
58
- end
59
- elsif type == "line" then
60
- nil
61
- elsif type == "c-return" and extra_data[3] == :set_trace_func then
62
- nil
63
- else
64
- set_trace_func(nil)
65
- error_msg = "Binding.of_caller used in non-method context or " +
66
- "trailing statements of method using it aren't in the block."
67
- cc.call(nil, lambda { raise(ArgumentError, error_msg) }, nil)
68
- end
69
- end
70
-
71
- unless result
72
- set_trace_func(tracer)
73
- return nil
74
- else
75
- Thread.critical = old_critical
76
- case block.arity
77
- when 1 then yield(result)
78
- else yield(result, extra_data)
79
- end
80
- end
81
- end
data/vendor/blankslate.rb DELETED
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
4
- # All rights reserved.
5
-
6
- # Permission is granted for use, copying, modification, distribution,
7
- # and distribution of modified versions of this work as long as the
8
- # above copyright notice is included.
9
- #++
10
-
11
- module Builder #:nodoc:
12
-
13
- # BlankSlate provides an abstract base class with no predefined
14
- # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
15
- # BlankSlate is useful as a base class when writing classes that
16
- # depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
17
- class BlankSlate #:nodoc:
18
- class << self
19
- def hide(name)
20
- undef_method name if
21
- instance_methods.include?(name.to_s) and
22
- name !~ /^(__|instance_eval)/
23
- end
24
- end
25
-
26
- instance_methods.each { |m| hide(m) }
27
- end
28
- end
29
-
30
- # Since Ruby is very dynamic, methods added to the ancestors of
31
- # BlankSlate <em>after BlankSlate is defined</em> will show up in the
32
- # list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any defined
33
- module Kernel #:nodoc:
34
- class << self
35
- alias_method :blank_slate_method_added, :method_added
36
- def method_added(name)
37
- blank_slate_method_added(name)
38
- return if self != Kernel
39
- Builder::BlankSlate.hide(name)
40
- end
41
- end
42
- end
43
-
44
- class Object #:nodoc:
45
- class << self
46
- alias_method :blank_slate_method_added, :method_added
47
- def method_added(name)
48
- blank_slate_method_added(name)
49
- return if self != Object
50
- Builder::BlankSlate.hide(name)
51
- end
52
- end
53
- end