nitro 0.27.0 → 0.28.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 (56) hide show
  1. data/CHANGELOG +276 -0
  2. data/ProjectInfo +4 -4
  3. data/README +9 -1
  4. data/Rakefile +1 -1
  5. data/doc/AUTHORS +30 -17
  6. data/doc/RELEASES +110 -23
  7. data/lib/glue/sweeper.rb +1 -1
  8. data/lib/glue/webfile.rb +1 -1
  9. data/lib/nitro.rb +1 -1
  10. data/lib/nitro/adapter/acgi.rb +5 -1
  11. data/lib/nitro/adapter/cgi.rb +4 -0
  12. data/lib/nitro/adapter/fastcgi.rb +12 -1
  13. data/lib/nitro/adapter/mongrel.rb +219 -0
  14. data/lib/nitro/adapter/scgi.rb +62 -69
  15. data/lib/nitro/caching.rb +6 -5
  16. data/lib/nitro/caching/actions.rb +14 -8
  17. data/lib/nitro/caching/fragments.rb +32 -17
  18. data/lib/nitro/caching/output.rb +10 -2
  19. data/lib/nitro/cgi.rb +7 -3
  20. data/lib/nitro/cgi/stream.rb +1 -3
  21. data/lib/nitro/compiler.rb +5 -4
  22. data/lib/nitro/compiler/errors.rb +1 -1
  23. data/lib/nitro/compiler/morphing.rb +2 -2
  24. data/lib/nitro/compiler/script.rb +1 -1
  25. data/lib/nitro/context.rb +8 -2
  26. data/lib/nitro/controller.rb +1 -1
  27. data/lib/nitro/dispatcher.rb +0 -2
  28. data/lib/nitro/element.rb +5 -5
  29. data/lib/nitro/flash.rb +1 -1
  30. data/lib/nitro/helper.rb +2 -2
  31. data/lib/nitro/helper/form.rb +1 -1
  32. data/lib/nitro/helper/form/controls.rb +2 -1
  33. data/lib/nitro/helper/javascript.rb +1 -1
  34. data/lib/nitro/helper/javascript/morphing.rb +1 -1
  35. data/lib/nitro/helper/layout.rb +1 -1
  36. data/lib/nitro/helper/pager.rb +7 -3
  37. data/lib/nitro/helper/rss.rb +1 -1
  38. data/lib/nitro/render.rb +1 -1
  39. data/lib/nitro/scaffolding.rb +26 -4
  40. data/lib/nitro/server/drb.rb +106 -0
  41. data/lib/nitro/server/runner.rb +23 -2
  42. data/lib/nitro/session.rb +33 -16
  43. data/lib/nitro/session/drb.rb +6 -20
  44. data/lib/nitro/session/file.rb +4 -49
  45. data/lib/nitro/session/memory.rb +16 -0
  46. data/lib/nitro/session/og.rb +4 -46
  47. data/src/part/admin/controller.rb +2 -3
  48. data/src/part/admin/template/index.xhtml +1 -1
  49. data/test/nitro/tc_cgi.rb +72 -3
  50. data/test/nitro/tc_render.rb +1 -1
  51. data/test/nitro/tc_session.rb +16 -15
  52. metadata +12 -14
  53. data/lib/nitro/caching/invalidation.rb +0 -25
  54. data/lib/nitro/caching/stores.rb +0 -94
  55. data/lib/nitro/helper/form/test.xhtml +0 -0
  56. data/lib/nitro/session/drbserver.rb +0 -84
@@ -1,9 +1,8 @@
1
- require 'nano/kernel/constant'
2
- require 'nano/time/stamp'
1
+ require 'facet/kernel/constant'
2
+ require 'facet/time/stamp'
3
3
 
4
4
  require 'nitro/controller'
5
5
 
6
-
7
6
  # Provides an automatically generated Administration
8
7
  # interface.
9
8
 
@@ -31,7 +31,7 @@
31
31
  <th>Type</th>
32
32
  <th>Description</th>
33
33
  </tr>
34
- <?r for s in Configuration.settings ?>
34
+ <?r for s in Configuration.settings.sort ?>
35
35
  <tr>
36
36
  <td>#{s.owner}.<strong>#{s.name}</strong></td>
37
37
  <td>#{s.value.inspect}</td>
@@ -1,14 +1,26 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
2
2
 
3
- require 'nano/kernel/assign_with'
4
-
3
+ require 'stringio'
4
+ require 'tempfile'
5
5
  require 'socket'
6
6
  require 'ostruct'
7
7
  require 'test/unit'
8
8
 
9
+ require 'facet/kernel/assign_with'
10
+
9
11
  require 'nitro/cgi'
10
12
  require 'nitro/cgi/cookie'
11
13
 
14
+ class String
15
+ class << self
16
+ def random(size)
17
+ s = String.new
18
+ size.times {|i| s << (Kernel.rand(26)+25) } # ascii range
19
+ s
20
+ end
21
+ end
22
+ end
23
+
12
24
  class TestAdapterCgi < Test::Unit::TestCase # :nodoc: all
13
25
  include Nitro
14
26
 
@@ -16,7 +28,7 @@ class TestAdapterCgi < Test::Unit::TestCase # :nodoc: all
16
28
  attr_accessor :name
17
29
  attr_accessor :password
18
30
  end
19
-
31
+
20
32
  def test_parse_query_parameters
21
33
  qs = 'name=tml;id=12354'
22
34
  params = Cgi.parse_query_string(qs)
@@ -100,4 +112,61 @@ class TestAdapterCgi < Test::Unit::TestCase # :nodoc: all
100
112
  CgiUtils.parse_multipart(context, boundary)
101
113
  end
102
114
  =end
115
+
116
+ def test_parse_multipart
117
+ # MIME block close falls on read boundary, also contains an empty field.
118
+ boundary = "---------------------------15773515131648678014689318540"
119
+ closure = "#{Cgi::EOL}--#{boundary}--#{Cgi::EOL}"
120
+ block_size = Cgi.buffer_size
121
+
122
+ input = StringIO.new
123
+ input << "--#{boundary}#{Cgi::EOL}"
124
+ input << "Content-Disposition: form-data; name=\"test_file_a\"; filename=\"test_case.txt\"#{Cgi::EOL}Content-Type: application/octet-stream#{Cgi::EOL}#{Cgi::EOL}"
125
+ fake_file_a = String.random(block_size - input.size - (closure.size/2))
126
+ input << fake_file_a
127
+ input_after_fake_file = input.size
128
+ input << "#{Cgi::EOL}--#{boundary}#{Cgi::EOL}"
129
+
130
+ #Boundary fell inbetween two reads?
131
+ assert_equal((block_size > input_after_fake_file) && (block_size < input.size),true)
132
+
133
+ input << "Content-Disposition: form-data; name=\"test_file_b\"; filename=\"test_case.txt\"#{Cgi::EOL}Content-Type: application/octet-stream#{Cgi::EOL}#{Cgi::EOL}"
134
+ fake_file_b = Tempfile.new("TCCGI")
135
+
136
+ i = 0
137
+ file_size = 1024*1024*10 # 10MB
138
+ i += fake_file_b.write String.random(1024*10) while i < file_size
139
+
140
+ fake_file_b.rewind
141
+ input << fake_file_b.read
142
+ fake_file_b.rewind
143
+ input << "#{Cgi::EOL}--#{boundary}#{Cgi::EOL}"
144
+
145
+ input << "Content-Disposition: form-data; name=\"empty_field\"#{Cgi::EOL}#{Cgi::EOL}"
146
+ input << closure
147
+ input.rewind
148
+ start = Time.now
149
+ params = Nitro::Cgi.parse_multipart(make_context(input), boundary)
150
+ duration = Time.now - start
151
+ puts "\nparse_multipart took: #{duration} seconds\n"
152
+ assert_equal(fake_file_a,params['test_file_a'].to_s)
153
+ assert_equal(fake_file_b.read,params['test_file_b'].to_s)
154
+ assert_equal(String.new,params['empty_field'].to_s)
155
+ end
156
+
157
+
158
+ def make_context(input)
159
+ context = OpenStruct.new
160
+ context.in = input
161
+ context.content_length = input.size
162
+ context.env = { 'HTTP_USER_AGENT' => 'TestCase' }
163
+ context.session = Hash.new
164
+ class << context.session
165
+ def sync
166
+ true
167
+ end
168
+ end
169
+ context
170
+ end
103
171
  end
172
+ # Tempfile.new("CGI")
@@ -4,7 +4,7 @@ require 'test/unit'
4
4
 
5
5
  require 'nitro'
6
6
  require 'nitro/render'
7
- require 'mega/mock'
7
+ require 'facet/mock'
8
8
 
9
9
  class TestRender < Test::Unit::TestCase # :nodoc: all
10
10
  include Nitro
@@ -11,7 +11,8 @@ require 'nitro/session'
11
11
  class TC_Session < Test::Unit::TestCase # :nodoc: all
12
12
  include Nitro
13
13
 
14
- STORES = [:memory, :file, :og]
14
+ # CACHES = [:memory, :file, :og]
15
+ CACHES = [:memory, :file]
15
16
 
16
17
  def test_create_id
17
18
  sid = Session.new.session_id
@@ -23,25 +24,25 @@ class TC_Session < Test::Unit::TestCase # :nodoc: all
23
24
  end
24
25
 
25
26
  def test_gc
26
- STORES.each do |store_type|
27
- Session.store_type = store_type
27
+ CACHES.each do |cache_type|
28
+ Session.keepalive = 2
28
29
 
29
- if store_type == :og
30
+ Session.cache_type = cache_type
31
+
32
+ if cache_type == :og
30
33
  Og.setup(:store => :sqlite, :name => "/tmp/test", :destroy => true)
31
34
  end
32
35
 
33
- Session.keepalive = 2
34
-
35
- Session.store[1] = Session.new
36
- Session.store[2] = Session.new
37
-
38
- Session.store.gc!
39
- assert_equal 2, Session.store.all.size
40
- Session.store.gc!
41
- assert_equal 2, Session.store.all.size
36
+ Session.cache[1] = Session.new
37
+ Session.cache[2] = Session.new
38
+
39
+ Session.cache.gc!
40
+ assert_equal 2, Session.cache.all.size
41
+ Session.cache.gc!
42
+ assert_equal 2, Session.cache.all.size
42
43
  sleep(3)
43
- Session.store.gc!
44
- assert_equal 0, Session.store.all.size
44
+ Session.cache.gc!
45
+ assert_equal 0, Session.cache.all.size
45
46
  end
46
47
  end
47
48
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: nitro
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.27.0
7
- date: 2006-01-16 00:00:00 +02:00
6
+ version: 0.28.0
7
+ date: 2006-02-06 00:00:00 +02:00
8
8
  summary: Everything you need to create Web 2.0 applications with Ruby and Javascript
9
9
  require_paths:
10
10
  - lib
@@ -15,7 +15,7 @@ description:
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
18
- has_rdoc: true
18
+ has_rdoc: false
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
21
  - - ">"
@@ -45,9 +45,9 @@ files:
45
45
  - doc/lhttpd.txt
46
46
  - doc/faq.txt
47
47
  - doc/config.txt
48
- - doc/RELEASES
49
48
  - doc/CHANGELOG.3
50
49
  - doc/apache.txt
50
+ - doc/RELEASES
51
51
  - doc/MIGRATION
52
52
  - doc/LICENSE
53
53
  - doc/CHANGELOG.2
@@ -66,8 +66,8 @@ files:
66
66
  - lib/nitro/service
67
67
  - lib/nitro/session
68
68
  - lib/nitro/test
69
- - lib/nitro/session.rb
70
69
  - lib/nitro/test.rb
70
+ - lib/nitro/session.rb
71
71
  - lib/nitro/service.rb
72
72
  - lib/nitro/server.rb
73
73
  - lib/nitro/compiler.rb
@@ -84,14 +84,13 @@ files:
84
84
  - lib/nitro/helper.rb
85
85
  - lib/nitro/scaffolding.rb
86
86
  - lib/nitro/adapter/scgi.rb
87
+ - lib/nitro/adapter/mongrel.rb
87
88
  - lib/nitro/adapter/acgi.rb
88
89
  - lib/nitro/adapter/webrick.rb
89
90
  - lib/nitro/adapter/fastcgi.rb
90
91
  - lib/nitro/adapter/cgi.rb
91
92
  - lib/nitro/caching/fragments.rb
92
- - lib/nitro/caching/stores.rb
93
93
  - lib/nitro/caching/output.rb
94
- - lib/nitro/caching/invalidation.rb
95
94
  - lib/nitro/caching/actions.rb
96
95
  - lib/nitro/cgi/response.rb
97
96
  - lib/nitro/cgi/utils.rb
@@ -102,19 +101,19 @@ files:
102
101
  - lib/nitro/compiler/elements.rb
103
102
  - lib/nitro/compiler/xslt.rb
104
103
  - lib/nitro/compiler/squeeze.rb
105
- - lib/nitro/compiler/layout.rb
106
104
  - lib/nitro/compiler/markup.rb
107
105
  - lib/nitro/compiler/errors.rb
108
106
  - lib/nitro/compiler/localization.rb
109
107
  - lib/nitro/compiler/css.rb
108
+ - lib/nitro/compiler/layout.rb
110
109
  - lib/nitro/compiler/morphing.rb
111
110
  - lib/nitro/compiler/include.rb
112
111
  - lib/nitro/compiler/cleanup.rb
113
112
  - lib/nitro/compiler/script.rb
114
113
  - lib/nitro/element/javascript.rb
115
114
  - lib/nitro/server/runner.rb
115
+ - lib/nitro/server/drb.rb
116
116
  - lib/nitro/service/xmlrpc.rb
117
- - lib/nitro/session/drbserver.rb
118
117
  - lib/nitro/session/memory.rb
119
118
  - lib/nitro/session/file.rb
120
119
  - lib/nitro/session/drb.rb
@@ -135,10 +134,9 @@ files:
135
134
  - lib/nitro/helper/buffer.rb
136
135
  - lib/nitro/helper/form
137
136
  - lib/nitro/helper/wee.rb
138
- - lib/nitro/helper/javascript
139
137
  - lib/nitro/helper/layout.rb
138
+ - lib/nitro/helper/javascript
140
139
  - lib/nitro/helper/form/controls.rb
141
- - lib/nitro/helper/form/test.xhtml
142
140
  - lib/nitro/helper/javascript/scriptaculous.rb
143
141
  - lib/nitro/helper/javascript/prototype.rb
144
142
  - lib/nitro/helper/javascript/morphing.rb
@@ -254,7 +252,7 @@ dependencies:
254
252
  requirements:
255
253
  - - "="
256
254
  - !ruby/object:Gem::Version
257
- version: 0.27.0
255
+ version: 0.28.0
258
256
  version:
259
257
  - !ruby/object:Gem::Dependency
260
258
  name: gen
@@ -263,7 +261,7 @@ dependencies:
263
261
  requirements:
264
262
  - - "="
265
263
  - !ruby/object:Gem::Version
266
- version: 0.27.0
264
+ version: 0.28.0
267
265
  version:
268
266
  - !ruby/object:Gem::Dependency
269
267
  name: glue
@@ -272,7 +270,7 @@ dependencies:
272
270
  requirements:
273
271
  - - "="
274
272
  - !ruby/object:Gem::Version
275
- version: 0.27.0
273
+ version: 0.28.0
276
274
  version:
277
275
  - !ruby/object:Gem::Dependency
278
276
  name: RedCloth
@@ -1,25 +0,0 @@
1
- # * George Moschovitis <gm@navel.gr>
2
- # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: invalidation.rb 182 2005-07-22 10:07:50Z gmosx $
4
-
5
- module Nitro
6
-
7
- module Caching
8
-
9
- # Support for invalidating output/fragment caches.
10
-
11
- module Invalidation
12
-
13
- def self.append_features(base) #:nodoc:
14
- super
15
- base.extend(ClassMethods)
16
- end
17
-
18
- module ClassMethods
19
- end
20
-
21
- end
22
-
23
- end
24
-
25
- end
@@ -1,94 +0,0 @@
1
- require 'fileutils'
2
-
3
- require 'mega/synchash'
4
-
5
- require 'glue/attribute'
6
-
7
- module Nitro
8
-
9
- # Adds support for caching.
10
-
11
- module Caching
12
-
13
- # Cached fragments are stored in memory.
14
-
15
- class MemoryStore < SyncHash
16
-
17
- def read(name, options = {})
18
- self[name]
19
- end
20
-
21
- def write(name, content = '', options = {})
22
- self[name] = content
23
- end
24
-
25
- alias_method :old_delete, :delete
26
-
27
- def delete(name, options = {})
28
- old_delete(name)
29
- end
30
-
31
- end
32
-
33
- # Cached fragments are stored as html files
34
- # on the filesystem.
35
-
36
- class FileStore
37
- cattr_accessor :cache_root, 'cache'
38
-
39
- def initialize(cache_root = FileStore.cache_root)
40
- @cache_root = cache_root
41
- end
42
-
43
- def read(name, options = {})
44
- begin
45
- IO.read(path_for_name(name))
46
- rescue
47
- nil
48
- end
49
- end
50
-
51
- def write(name, content = '', options = {})
52
- begin
53
- path = path_for_name(name)
54
- dir = File.dirname(path)
55
- FileUtils.makedirs(dir) unless File.exists?(dir)
56
-
57
- File.open(path, 'w+') { |f| f.write(content) }
58
- rescue
59
- Logger.error "Could not save cached file '#{path}'"
60
- end
61
- end
62
-
63
- def delete(name, options = {})
64
- path = path_for_name(name)
65
- File.delete(path) if File.exist?(path)
66
- end
67
-
68
- private
69
-
70
- def path_for_name(name)
71
- "#@cache_root/#{name}"
72
- end
73
-
74
- end
75
-
76
- #--
77
- # TODO: implement me
78
- #++
79
-
80
- class DrbStrore
81
- end
82
-
83
- #--
84
- # TODO: implement me
85
- #++
86
-
87
- class MemcacheStore
88
- end
89
-
90
- end
91
-
92
- end
93
-
94
- # * George Moschovitis <gm@navel.gr>
File without changes
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'drb'
4
- require 'optparse'
5
-
6
- require 'mega/synchash'
7
- require 'nitro/session'
8
-
9
- # A distributes session store implemented as
10
- # a simple DRb server.
11
- #--
12
- # TODO: add daemonize support.
13
- #++
14
-
15
- address = '127.0.0.1'
16
- port = 9069
17
- debug = false
18
- daemon = false
19
-
20
- parser = OptionParser.new do |opts|
21
-
22
- opts.banner = 'Usage: drbserver.rb [options]'
23
- opts.separator ''
24
- opts.separator 'Specific options:'
25
-
26
- opts.on('-a A', '--address A', 'Listening address.') do |a|
27
- address = a
28
- end
29
-
30
- opts.on('-p P', '--port P', Integer, 'Listening port.') do |p|
31
- port = p
32
- end
33
-
34
- opts.on('-D', '--debug', 'Run in debug mode.') do |p|
35
- debug = true
36
- end
37
-
38
- opts.on('-d', '--daemon', 'Run as daemon.') do |p|
39
- daemon = true
40
- end
41
-
42
- opts.on_tail('-h', '--help', 'Show this message.') do
43
- puts opts
44
- exit
45
- end
46
-
47
- end
48
-
49
- begin
50
- parser.parse!(ARGV)
51
- rescue OptionParser::InvalidOption
52
- puts 'Invalid option, pass the --help parameter to get help!'
53
- exit
54
- end
55
-
56
- sessions = Nitro::MemorySessionStore.new
57
-
58
- if debug
59
-
60
- class << sessions
61
- def []=(k, v)
62
- puts "WRITE: #{k} = #{v}"
63
- super
64
- end
65
-
66
- def [](k)
67
- puts "READ: #{k}"
68
- super
69
- end
70
- end
71
-
72
- end
73
-
74
- puts "Drb session server listening at druby://#{address}:#{port}."
75
-
76
- if daemon
77
- require 'daemons/daemonize'
78
- Daemonize.daemonize()
79
- end
80
-
81
- DRb.start_service("druby://#{address}:#{port}", sessions)
82
- DRb.thread.join
83
-
84
- # * George Moschovitis <gm@navel.gr>