nitro 0.15.0 → 0.16.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 (111) hide show
  1. data/CHANGELOG +218 -0
  2. data/INSTALL +3 -0
  3. data/README +4 -2
  4. data/Rakefile +150 -8
  5. data/benchmark/bench.rb +1 -1
  6. data/doc/AUTHORS +2 -8
  7. data/doc/RELEASES +63 -1
  8. data/examples/ajax/controller.rb +2 -2
  9. data/examples/ajax/public/index.xhtml +3 -1
  10. data/examples/ajax/run.rb +3 -3
  11. data/examples/blog/README +8 -0
  12. data/examples/blog/cache/entriesadmintrue +3 -0
  13. data/examples/blog/run.rb +38 -40
  14. data/examples/blog/src/blog.rb +2 -1
  15. data/examples/blog/src/controller.rb +40 -20
  16. data/examples/blog/src/mailer.rb +2 -2
  17. data/examples/blog/src/models/blog.rb +2 -1
  18. data/examples/blog/src/models/content.rb +4 -33
  19. data/examples/blog/src/views/error.xhtml +1 -1
  20. data/examples/blog/src/xsl/style.xsl +1 -1
  21. data/examples/blog/test/tc_blog.rb +43 -0
  22. data/examples/flash/run.rb +2 -2
  23. data/examples/no_xsl_blog/lib/blog.rb +1 -1
  24. data/examples/no_xsl_blog/lib/blog/controller.rb +26 -17
  25. data/examples/no_xsl_blog/lib/blog/model.rb +3 -3
  26. data/examples/no_xsl_blog/lib/blog/template.rb +1 -1
  27. data/examples/no_xsl_blog/lib/content.rb +3 -7
  28. data/examples/no_xsl_blog/run.rb +34 -34
  29. data/examples/tiny/public/deep/dir/hello.xhtml +2 -0
  30. data/examples/tiny/run.rb +2 -2
  31. data/examples/wee_style/run.rb +5 -3
  32. data/examples/why_wiki/run.rb +5 -3
  33. data/install.rb +1 -1
  34. data/lib/nitro.rb +10 -9
  35. data/lib/nitro/adapters/cgi.rb +27 -2
  36. data/lib/nitro/adapters/fastcgi.rb +6 -2
  37. data/lib/nitro/adapters/webrick.rb +11 -9
  38. data/lib/nitro/buffering.rb +2 -2
  39. data/lib/nitro/builders/atom.rb +78 -0
  40. data/lib/nitro/builders/form.rb +2 -2
  41. data/lib/nitro/builders/rss.rb +4 -4
  42. data/lib/nitro/builders/table.rb +2 -2
  43. data/lib/nitro/builders/xhtml.rb +5 -8
  44. data/lib/nitro/builders/xml.rb +38 -14
  45. data/lib/nitro/caching.rb +2 -2
  46. data/lib/nitro/caching/actions.rb +2 -2
  47. data/lib/nitro/caching/fragments.rb +2 -2
  48. data/lib/nitro/caching/invalidation.rb +2 -28
  49. data/lib/nitro/caching/output.rb +3 -3
  50. data/lib/nitro/caching/stores.rb +4 -4
  51. data/lib/nitro/conf.rb +11 -6
  52. data/lib/nitro/context.rb +2 -2
  53. data/lib/nitro/controller.rb +12 -7
  54. data/lib/nitro/cookie.rb +2 -2
  55. data/lib/nitro/dispatcher.rb +33 -40
  56. data/lib/nitro/environment.rb +1 -1
  57. data/lib/nitro/localization.rb +5 -7
  58. data/lib/nitro/mail.rb +2 -2
  59. data/lib/nitro/markup.rb +5 -5
  60. data/lib/nitro/output.rb +2 -2
  61. data/lib/nitro/part.rb +8 -5
  62. data/lib/nitro/render.rb +46 -45
  63. data/lib/nitro/request.rb +7 -6
  64. data/lib/nitro/response.rb +14 -5
  65. data/lib/nitro/routing.rb +2 -2
  66. data/lib/nitro/runner.rb +57 -17
  67. data/lib/nitro/scaffold.rb +14 -8
  68. data/lib/nitro/session.rb +7 -4
  69. data/lib/nitro/session/drb.rb +2 -2
  70. data/lib/nitro/session/drbserver.rb +2 -2
  71. data/lib/nitro/session/memory.rb +2 -2
  72. data/lib/nitro/shaders.rb +8 -7
  73. data/lib/nitro/simple.rb +4 -1
  74. data/lib/nitro/template.rb +8 -8
  75. data/lib/nitro/testing.rb +6 -0
  76. data/lib/nitro/testing/assertions.rb +102 -0
  77. data/lib/nitro/testing/context.rb +52 -0
  78. data/lib/nitro/testing/testcase.rb +55 -0
  79. data/lib/nitro/ui/pager.rb +3 -3
  80. data/lib/nitro/ui/popup.rb +8 -13
  81. data/lib/nitro/ui/tabs.rb +4 -10
  82. data/lib/nitro/uri.rb +7 -7
  83. data/proto/doc/README +1 -0
  84. data/proto/public/cgi.rb +5 -0
  85. data/proto/run.rb +2 -4
  86. data/test/nitro/adapters/tc_cgi.rb +1 -1
  87. data/test/nitro/adapters/tc_webrick.rb +1 -2
  88. data/test/nitro/builders/tc_atom.rb +26 -0
  89. data/test/nitro/builders/tc_rss.rb +3 -2
  90. data/test/nitro/builders/tc_table.rb +1 -1
  91. data/test/nitro/builders/tc_xhtml.rb +4 -3
  92. data/test/nitro/builders/tc_xml.rb +7 -7
  93. data/test/nitro/tc_context.rb +1 -1
  94. data/test/nitro/tc_controller.rb +5 -3
  95. data/test/nitro/tc_dispatcher.rb +19 -18
  96. data/test/nitro/tc_localization.rb +1 -1
  97. data/test/nitro/tc_mail.rb +1 -1
  98. data/test/nitro/tc_session.rb +1 -1
  99. data/test/nitro/tc_template.rb +1 -1
  100. data/test/nitro/tc_uri.rb +3 -4
  101. data/test/nitro/ui/tc_pager.rb +7 -7
  102. data/test/public/blog/inc1.xhtml +2 -0
  103. data/test/public/blog/inc2.xhtml +1 -0
  104. data/test/public/blog/list.xhtml +3 -0
  105. metadata +180 -203
  106. data/examples/blog/cache/entriesadmin +0 -12
  107. data/lib/nitro/cluster.rb +0 -218
  108. data/lib/nitro/component.rb +0 -15
  109. data/lib/nitro/filters.rb +0 -215
  110. data/lib/nitro/ui/date-select.rb +0 -69
  111. data/test/nitro/tc_filters.rb +0 -111
@@ -1,17 +1,11 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: tabs.rb 266 2005-02-28 14:50:48Z gmosx $
3
+ # $Id: tabs.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
- module N; module UI
5
+ module Nitro
6
6
 
7
7
  # Render a tabs bar
8
- #
9
- # Example:
10
- #
11
- # #{N::UI.tabs(request,
12
- # ["Page1", "Page2", "Page3"]
13
- # }
14
- #
8
+
15
9
  def self.tabs(request, options, param)
16
10
  tabs = []
17
11
 
@@ -28,4 +22,4 @@ module N; module UI
28
22
  return %|<div class="tabs">#{tabs.join('<span class="sep">|</span>')}</div>|
29
23
  end
30
24
 
31
- end; end # module
25
+ end
@@ -1,13 +1,13 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: uri.rb 263 2005-02-23 13:45:08Z gmosx $
3
+ # $Id: uri.rb 1 2005-04-11 11:04:30Z gmosx $
4
4
 
5
- require "uri"
6
- require "cgi"
5
+ require 'uri'
6
+ require 'cgi'
7
7
 
8
- require "glue/string"
8
+ require 'glue/string'
9
9
 
10
- module N
10
+ module Nitro
11
11
 
12
12
  # URI utilities collection.
13
13
  #
@@ -41,7 +41,7 @@ module UriUtils
41
41
 
42
42
  # real_path = "#{$root_dir}/#{path}"
43
43
 
44
- parameters = N::UriUtils.query_string_to_hash(query_string)
44
+ parameters = UriUtils.query_string_to_hash(query_string)
45
45
  path.gsub!(/\+/, " ")
46
46
 
47
47
  return [path, type, parameters, query_string]
@@ -164,7 +164,7 @@ module UriUtils
164
164
  hash.update(parameters)
165
165
  query_string = self.hash_to_query_string(hash)
166
166
 
167
- if N::StringUtils.valid?(query_string)
167
+ if Glue::StringUtils.valid?(query_string)
168
168
  return "#{rest}?#{query_string}"
169
169
  else
170
170
  return rest
@@ -0,0 +1 @@
1
+ Your documentation comes here.
@@ -0,0 +1,5 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ ENV['NITRO_INVOKE'] = 'cgi_proc'
4
+ $0 = File.join(File.dirname(__FILE__), '..', 'run.rb')
5
+ require $0
@@ -2,10 +2,8 @@
2
2
 
3
3
  # * George Moschovitis <gm@navel.gr>
4
4
  # (c) 2004-2005 Navel, all rights reserved.
5
- # $Id: run.rb 331 2005-03-28 11:12:43Z gmosx $
6
-
7
- Dir.chdir File.dirname(__FILE__)
5
+ # $Id: run.rb 1 2005-04-11 11:04:30Z gmosx $
8
6
 
9
7
  require 'nitro'
10
8
 
11
- N::Runner.run(:host => '127.0.0.1', :port => 9999)
9
+ Nitro::Runner.run(:host => '127.0.0.1', :port => 9999)
@@ -7,7 +7,7 @@ require 'nitro/cookie'
7
7
  require 'nitro/adapters/cgi'
8
8
 
9
9
  class TC_AdaptersCgi < Test::Unit::TestCase # :nodoc: all
10
- include N
10
+ include Nitro
11
11
 
12
12
  def test_parse_query_parameters
13
13
  qs = 'name=tml;id=12354'
@@ -6,10 +6,9 @@ require 'ostruct'
6
6
  require 'nitro/adapters/webrick'
7
7
 
8
8
  class TC_AdaptersWebrick < Test::Unit::TestCase # :nodoc: all
9
- include N
9
+ include Nitro
10
10
 
11
11
  def test_adaptor
12
- # w = WebrickAdapter.new()
13
12
  end
14
13
 
15
14
  end
@@ -0,0 +1,26 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
2
+
3
+ require 'test/unit'
4
+ require 'nitro/builders/atom'
5
+
6
+ class TestCaseBuildersAtom < Test::Unit::TestCase # :nodoc: all
7
+ include Nitro
8
+
9
+ Blog = Struct.new(:title, :body, :view_uri, :author)
10
+
11
+ def test_render
12
+ =begin
13
+ blogs = []
14
+ blogs << Blog.new('Hello1', 'World1', 'uri1', 'George');
15
+ blogs << Blog.new('Hello2', 'World2', 'uri2', 'Stella');
16
+ blogs << Blog.new('Hello3', 'World3', 'uri3', 'Renos');
17
+
18
+ rss = AtomBuilder.build(blogs, :link => 'http://www.navel.gr')
19
+
20
+ puts '--', rss
21
+ =end
22
+ # assert_match %r{<link>http://www.navel.gr/uri1</link>}, rss
23
+ # assert_match %r{<link>http://www.navel.gr/uri2</link>}, rss
24
+ end
25
+
26
+ end
@@ -4,7 +4,8 @@ require 'test/unit'
4
4
  require 'nitro/builders/rss'
5
5
 
6
6
  class TC_BuildersRss < Test::Unit::TestCase # :nodoc: all
7
-
7
+ include Nitro
8
+
8
9
  Blog = Struct.new(:title, :body, :view_uri)
9
10
 
10
11
  def test_render
@@ -13,7 +14,7 @@ class TC_BuildersRss < Test::Unit::TestCase # :nodoc: all
13
14
  blogs << Blog.new('Hello2', 'World2', 'uri2');
14
15
  blogs << Blog.new('Hello3', 'World3', 'uri3');
15
16
 
16
- rss = N::RssBuilder.build(blogs, :link => 'http://www.navel.gr')
17
+ rss = RssBuilder.build(blogs, :link => 'http://www.navel.gr')
17
18
 
18
19
  assert_match %r{<link>http://www.navel.gr/uri1</link>}, rss
19
20
  assert_match %r{<link>http://www.navel.gr/uri2</link>}, rss
@@ -4,7 +4,7 @@ require 'test/unit'
4
4
  require 'nitro/builders/table'
5
5
 
6
6
  class TC_BuildersTable < Test::Unit::TestCase # :nodoc: all
7
- include N
7
+ include Nitro
8
8
 
9
9
  User = Struct.new(:name, :password, :email)
10
10
 
@@ -4,9 +4,10 @@ require 'test/unit'
4
4
  require 'nitro/builders/xhtml'
5
5
 
6
6
  class TC_BuildersXhtml < Test::Unit::TestCase # :nodoc: all
7
+ include Nitro
7
8
 
8
9
  def test_options
9
- x = N::XhtmlString.new
10
+ x = XhtmlString.new
10
11
  options = ['Male', 'Female']
11
12
  x.select(:name => 'sex') do
12
13
  x.options(options, 1)
@@ -15,7 +16,7 @@ class TC_BuildersXhtml < Test::Unit::TestCase # :nodoc: all
15
16
  '<option value="1" selected="1">Female</option></select>'
16
17
  assert_equal res, x
17
18
 
18
- x = N::XhtmlString.new
19
+ x = XhtmlString.new
19
20
  options = ['Male', 'Female']
20
21
  x.select('-- Select sex --', :name => 'sex') do
21
22
  x.options(options, 1)
@@ -25,7 +26,7 @@ class TC_BuildersXhtml < Test::Unit::TestCase # :nodoc: all
25
26
  '<option value="1" selected="1">Female</option></select>'
26
27
  assert_equal res, x
27
28
 
28
- x = N::XhtmlString.new
29
+ x = XhtmlString.new
29
30
  options = {'Male' => 'm', 'Female' => 'f'}
30
31
  x.select(:name => 'sex') do
31
32
  x.options(options, 'm')
@@ -4,14 +4,14 @@ require 'test/unit'
4
4
  require 'nitro/builders/xml'
5
5
 
6
6
  class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all
7
- include N
7
+ include Nitro
8
8
 
9
9
  def test_string
10
10
  x = XmlString.new
11
11
 
12
- x.start_tag('html').
13
- start_tag('title').text('hello').end_tag('title').
14
- end_tag('html')
12
+ x.start_tag!('html').
13
+ start_tag!('title').text!('hello').end_tag!('title').
14
+ end_tag!('html')
15
15
 
16
16
  assert_equal '<html><title>hello</title></html>', x
17
17
  end
@@ -46,9 +46,9 @@ class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all
46
46
  buffer = ''
47
47
  x = XmlBuilder.new(buffer)
48
48
 
49
- x.start_tag('html').
50
- start_tag('title').text('hello').end_tag('title').
51
- end_tag('html')
49
+ x.start_tag!('html').
50
+ start_tag!('title').text!('hello').end_tag!('title').
51
+ end_tag!('html')
52
52
 
53
53
  assert_equal '<html><title>hello</title></html>', buffer
54
54
  end
@@ -6,7 +6,7 @@ require 'ostruct'
6
6
  require 'nitro/context'
7
7
 
8
8
  class TC_Context < Test::Unit::TestCase # :nodoc: all
9
- include N
9
+ include Nitro
10
10
 
11
11
  def test_context
12
12
  conf = OpenStruct.new
@@ -3,12 +3,14 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
3
3
  require 'test/unit'
4
4
  require 'ostruct'
5
5
 
6
+ require 'glue'
7
+ require 'glue/logger'
6
8
  require 'nitro/context'
7
9
  require 'nitro/dispatcher'
8
10
  require 'nitro/controller'
9
11
 
10
12
  class TC_Controller < Test::Unit::TestCase # :nodoc: all
11
- include N
13
+ include Nitro
12
14
 
13
15
  class Blog2Controller < Controller
14
16
  attr_reader :aflag, :tflag
@@ -36,14 +38,14 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
36
38
  ctx.headers['REQUEST_URI'] = '/blog/list'
37
39
  klass, action = ctx.dispatcher.dispatch(ctx.path, ctx)
38
40
  c = klass.new(ctx)
39
- p klass.before_filters, klass.after_filters
40
- p '--', Controller.before_filters, Controller.after_filters
41
41
  begin
42
42
  c.send(action)
43
43
  rescue RenderExit
44
44
  # drink
45
45
  end
46
46
  assert_equal true, c.aflag
47
+ assert_equal true, $include1
48
+ assert_equal true, $include2
47
49
 
48
50
  # the template is compiled
49
51
  assert_equal true, c.tflag
@@ -4,24 +4,26 @@ require 'test/unit'
4
4
  require 'nitro/dispatcher'
5
5
 
6
6
  class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all
7
+ include Nitro
7
8
 
8
- class MainController < N::Controller
9
+ class MainController < Controller
9
10
  end
10
11
 
11
- class BlogController < N::Controller
12
+ class BlogController < Controller
12
13
  end
13
14
 
14
15
  def setup
15
- @d = N::Dispatcher.new({
16
+ @d = Dispatcher.new({
16
17
  :root => MainController,
17
18
  'blog' => BlogController
18
19
  })
19
20
 
20
- @dxml = N::Dispatcher.new({
21
+ @dxml = Dispatcher.new({
21
22
  :root => MainController,
22
- 'blog' => BlogController
23
+ 'blog' => BlogController,
24
+ # FIXME: this is a hack!
25
+ 'xml:blog' => BlogController
23
26
  })
24
- @dxml.add_api('xml', 'xml')
25
27
  end
26
28
 
27
29
  def teardown
@@ -29,47 +31,46 @@ class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all
29
31
  end
30
32
 
31
33
  def test_initialize
32
- d = N::Dispatcher.new(BlogController)
34
+ d = Dispatcher.new(BlogController)
33
35
  assert_equal BlogController, d.controllers[:root]
34
36
  end
35
37
 
36
38
  def test_dispatch
37
39
  klass, action = @d.dispatch('/blog/list')
38
40
  assert_equal BlogController, klass
39
- assert_equal '__xhtml__list', action
41
+ assert_equal 'list_action', action
40
42
 
41
43
  klass, action = @d.dispatch('/blog/another/very_litle/list')
42
44
  assert_equal BlogController, klass
43
- assert_equal '__xhtml__another__very_litle__list', action
45
+ assert_equal 'another__very_litle__list_action', action
44
46
 
45
47
  klass, action = @d.dispatch('/another/litle/list')
46
48
  assert_equal MainController, klass
47
- assert_equal '__xhtml__another__litle__list', action
49
+ assert_equal 'another__litle__list_action', action
48
50
 
49
- klass, action, ctype = @d.dispatch('/blog')
51
+ klass, action = @d.dispatch('/blog')
50
52
  assert_equal BlogController, klass
51
- assert_equal '__xhtml__index', action
52
- assert_equal 'text/html', ctype
53
+ assert_equal 'index_action', action
53
54
 
54
55
  klass, action, ctype = @d.dispatch('/login')
55
56
  assert_equal MainController, klass
56
- assert_equal '__xhtml__login', action
57
+ assert_equal 'login_action', action
57
58
 
58
59
  klass, action = @d.dispatch('/')
59
60
  assert_equal MainController, klass
60
- assert_equal '__xhtml__index', action
61
+ assert_equal 'index_action', action
61
62
 
62
63
  # multi-api dispatcher.
63
64
 
64
65
  # no xml prefix, use xhtml api.
65
66
  klass, action = @dxml.dispatch('/blog/list')
66
67
  assert_equal BlogController, klass
67
- assert_equal '__xhtml__list', action
68
+ assert_equal 'list_action', action
68
69
 
69
70
  # xml prefix, use xml api.
70
- klass, action = @dxml.dispatch('/xml/blog/list')
71
+ klass, action = @dxml.dispatch('/xml:blog/list')
71
72
  assert_equal BlogController, klass
72
- assert_equal '__xml__list', action
73
+ assert_equal 'list_action', action
73
74
  end
74
75
 
75
76
  end
@@ -6,7 +6,7 @@ require 'ostruct'
6
6
  require 'nitro/localization'
7
7
 
8
8
  class TestCaseLocalization < Test::Unit::TestCase # :nodoc: all
9
- include N
9
+ include Nitro
10
10
 
11
11
  def setup
12
12
  locale_en = {
@@ -7,7 +7,7 @@ require 'nitro/controller'
7
7
  require 'nitro/mail'
8
8
 
9
9
  class TestCaseMail < Test::Unit::TestCase # :nodoc: all
10
- include N
10
+ include Nitro
11
11
 
12
12
  class DummyMailer < Mailer
13
13
  def initialize
@@ -6,7 +6,7 @@ require 'test/unit'
6
6
  require 'nitro/session'
7
7
 
8
8
  class TC_Session < Test::Unit::TestCase # :nodoc: all
9
- include N
9
+ include Nitro
10
10
 
11
11
  def test_create_id
12
12
  sid = Session.new.session_id
@@ -6,7 +6,7 @@ require 'ostruct'
6
6
  require 'nitro/template'
7
7
 
8
8
  class TC_Template < Test::Unit::TestCase # :nodoc: all
9
- include N
9
+ include Nitro
10
10
 
11
11
  def test_all
12
12
  template = %q{
@@ -1,13 +1,12 @@
1
- require "test/unit"
2
- require "nitro/uri"
3
-
4
- include N
1
+ require 'test/unit'
2
+ require 'nitro/uri'
5
3
 
6
4
  class Dummy # :nodoc: all
7
5
  attr_accessor :test1, :test2
8
6
  end
9
7
 
10
8
  class TC_Uri < Test::Unit::TestCase # :nodoc: all
9
+ include Nitro
11
10
 
12
11
  def test_query_string_to_hash
13
12
  # bad query string
@@ -1,11 +1,11 @@
1
1
  # :nodoc: all
2
2
 
3
- require "test/unit"
3
+ require 'test/unit'
4
4
 
5
- require "glue/logger"
5
+ require 'glue/logger'
6
6
 
7
- require "og"
8
- require "nitro/ui/pager"
7
+ require 'og'
8
+ require 'nitro/ui/pager'
9
9
 
10
10
  class RequestMock < Hash
11
11
  attr_accessor :query
@@ -20,12 +20,12 @@ class RequestMock < Hash
20
20
  end
21
21
 
22
22
  class TC_N_UI_Pager < Test::Unit::TestCase
23
-
23
+ include Nitro
24
+
24
25
  def setup
25
26
  end
26
27
 
27
28
  def teardown
28
- # $og.shutdown()
29
29
  end
30
30
 
31
31
  def test_all
@@ -33,7 +33,7 @@ class TC_N_UI_Pager < Test::Unit::TestCase
33
33
  count = items.size()
34
34
 
35
35
  request = RequestMock.new()
36
- pager = N::UI::Pager.new("tst", request, 2, items)
36
+ pager = UI::Pager.new('tst', request, 2, items)
37
37
 
38
38
  assert_equal(pager.total_count, count)
39
39