nitro 0.21.2 → 0.22.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.
data/CHANGELOG CHANGED
@@ -1,5 +1,126 @@
1
+ 07-08-2005 George Moschovitis <gm@navel.gr>
2
+
3
+ * lib/nitro/tc_controller.rb: ditto.
4
+
5
+ * lib/nitro/tc_dispatcher.rb: tmp fix for require order problem.
6
+
7
+ * doc/README: updated.
8
+
9
+ * doc/RELEASES: updated.
10
+
11
+ * test/nitro/tc_mail.rb: removed.
12
+
13
+ * lib/nitro/mail.rb: moved to glue.
14
+
15
+ 06-08-2005 George Moschovitis <gm@navel.gr>
16
+
17
+ * proto/script/runner.rb: implemented.
18
+
19
+ 05-08-2005 George Moschovitis <gm@navel.gr>
20
+
21
+ * lib/nitro/render.rb (#render_template): implemented [mneumann].
22
+
23
+ * lib/nitro/element.rb: prefix setting added,
24
+ (#start_tag/#end_tag): also work in prefix mode!
25
+
26
+ 04-08-2005 George Moschovitis <gm@navel.gr>
27
+
28
+ * lib/nitro/template.rb: moved to glue.
29
+
30
+ * lib/nitro/test.rb: $NITRO_NO_INVOKE added.
31
+
32
+ * lib/nitro/test/testcase.rb (#controller): reimplemented to
33
+ be similar to the og test helpers and more flexible,
34
+ no need for settings.rb.
35
+
36
+ * lib/nitro/cache/output.rb (#expire_output): use the passed
37
+ name as is.
38
+
39
+ 03-08-2005 George Moschovitis <gm@navel.gr>
40
+
41
+ * lib/nitro/server.rb (#start): accepts options hash [marcus].
42
+
43
+ 03-08-2005 Michael Neumann <mneumann@ntecs.de>
44
+
45
+ * lib/nitro/adapter/cgi.rb (#parse_params): add query parameters
46
+ to the post parameters.
47
+
48
+ 02-08-2005 George Moschovitis <gm@navel.gr>
49
+
50
+ * lib/nitro/mixin/rss.rb: use markup instead of cgi.escape [lindsay].
51
+
52
+ 01-08-2005 George Moschovitis <gm@navel.gr>
53
+
54
+ * lib/nitro/cache/output.rb (#expire_output): fixed index bug.
55
+
56
+ * lib/nitro/mixin/pager.rb: dont sent offset 0, works with
57
+ older versions of mysql.
58
+
59
+ 31-07-2005 George Moschovitis <gm@navel.gr>
60
+
61
+ * lib/nitro/compiler.rb: fix, don't pass more parameters
62
+ than the method arity.
63
+
64
+ * lib/nitro/caching/output.rb: fixed indexindex.
65
+
66
+ * test/nitro/tc_controller_aspect.rb: implemented.
67
+
68
+ * proto/public/settings.xhtml: only display in debug mode for
69
+ security.
70
+
71
+ * proto/public/error.xhtml: only display in debug mode for
72
+ security.
73
+
74
+ * lib/nitro/runner.rb: added mode setting,
75
+ better handling of mode,
76
+ Run alias for Runner.
77
+
78
+ 30-07-2005 George Moschovitis <gm@navel.gr>
79
+
80
+ * lib/nitro/mixin/pager.rb (#first_page?, #last_page?):
81
+ implemented,
82
+ added more comments.
83
+ (#link_xxx_page): added helpers.
84
+ (#paginate): added support for Og::Collections.
85
+
86
+ * proto/public/error.xhtml: updated.
87
+
88
+ 29-07-2005 George Moschovitis <gm@navel.gr>
89
+
90
+ * lib/nitro/response.rb (#content_type): added.
91
+
92
+ * lib/nitro/test/testcase.rb: recoded from scratch,
93
+ automatically build environment,
94
+ (#process): accept an option hash to be more flexible.
95
+ added process helpers,
96
+ add leading '/' if missing.
97
+
98
+ * lib/nitro/test/assertions.rb (#assert_response): reimplemented,
99
+ (#assert_METHOD): helpers added,
100
+ (#assert_output): reimplemented,
101
+ keep the old assertions, give more option.
102
+ (#assert_session): reimplemented,
103
+ (#assert_redirected): reimplemented.
104
+ (#assert_response): generalized.
105
+ (#assert_cookie): reimplemented.
106
+
107
+ * lib/nitro/test*: renamed from testing.
108
+
109
+ * test/nitro/tc_request.rb: added test case to test the
110
+ new feature, as always I found some bugs :)
111
+
112
+ * lib/nitro/request.rb: added method predicates for all
113
+ request methods,
114
+ (#post_format): added,
115
+ (#xxx_post?): added a set of helper methods,
116
+ (#xml_http_request?): added,
117
+ (#domain): added,
118
+ (#subdomains): added.
119
+
1
120
  28-07-2005 George Moschovitis <gm@navel.gr>
2
121
 
122
+ * --- VERSION 0.21.1 ---
123
+
3
124
  * lib/nitro/dispatcher/nice.rb (#dispatch): fixed.
4
125
 
5
126
  * doc/RELEASES: updated.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = Nitro 0.21.2 README
1
+ = Nitro 0.22.0 README
2
2
 
3
3
  Nitro provides everything you need to develop professional Web
4
4
  applications using Ruby and Javascript.
@@ -112,7 +112,7 @@ A short summary of the major features:
112
112
  'RunTime' time.
113
113
 
114
114
  <!-- compile time include (static include) -->
115
- <?include href="myfile.inc" />
115
+ <?include href="myfile.inc" ?>
116
116
 
117
117
  <!-- run time include (dynamic include) -->
118
118
  <include href="myfile.inc" />
@@ -239,6 +239,11 @@ A short summary of the major features:
239
239
  p u.errors[:password]
240
240
  end
241
241
 
242
+ * Excellent support for Test Driven Development and Testing.
243
+ Nitro provides full support for fixtures, mocking and a set
244
+ of custom assertions for testing everything, from controller
245
+ logic to your models.
246
+
242
247
  * Implicit nice urls. Nitro automatically generates nice urls
243
248
  for your actions. However, if you want to customize the defaults,
244
249
  a powerful routing mechanism is provided.
@@ -272,7 +277,8 @@ A short summary of the major features:
272
277
  * Mailer
273
278
 
274
279
  Nitro provides excellent support for handling emails in your
275
- Web application.
280
+ Web application. Both incoming and outgoing email support is
281
+ provided.
276
282
 
277
283
  * Wee integration.
278
284
 
@@ -1,9 +1,94 @@
1
+ == Version 0.22.0
2
+
3
+ A snapshot of the latest developments. Many requested features
4
+ where implemented, and many reported bugs fixed.
5
+
6
+ * The much requested Og 'reverse mode' is implemented. Og's
7
+ domain specific language and API is extended to allow fine-grained
8
+ customization of the schema-to-objects mapping. Og can now handle
9
+ most of the legacy schemas you can throw at it. Here is an
10
+ example:
11
+
12
+ class User
13
+ property :name, String, :field => :thename, :uniq => true
14
+ property :password, String
15
+ property :age, Fixnum, :field => :age3
16
+ has_many Comment, :foreign_field => :user
17
+ set_table :my_users
18
+ set_primary_key :name, String
19
+ end
20
+
21
+ class Comment
22
+ property :cid, Fixnum
23
+ property :body, String
24
+ belongs_to User, :field => :user
25
+ set_table :my_comments
26
+ set_primary_key :cid
27
+ end
28
+
29
+ As you can see, even relation fields can be customized. For
30
+ higher level customization you can overload methods like #table,
31
+ #field_for_property etc.
32
+
33
+ * Og now handles multiple connections to multiple stores even
34
+ in thread safe mode. This means you can now have objects serialized
35
+ in different RDBM systems in the same application. Or you can have
36
+ some objects managed by an RDBMS store and others by a FAST
37
+ in-memory store. You can still have relations between objects in
38
+ different stores. An example:
39
+
40
+ mysql = Og.setup(:store => :mysql, ..)
41
+ psql = Og.setup(:store => :psql, ..)
42
+
43
+ class User
44
+ has_many Comment
45
+ end
46
+
47
+ class Comment
48
+ belongs_to User
49
+ end
50
+
51
+ mysql.manage_class User
52
+ psql.manage_class Comment
53
+
54
+ user.comments << comment
55
+
56
+ * Greatly improved support for testing and test-driven-development.
57
+ A reworked testing infrastructure for controllers is in place.
58
+ Moreover, support for Og fixtures and automatic test database
59
+ setup is provided. Fixtures can be defined with yml or csv files.
60
+
61
+ For an example of the testing infrastructure check out the
62
+ Spark 0.4.0 sources. Spark is a Wiki powered by Nitro.
63
+
64
+ * Reworked mailer implementation. The new mailer allows for
65
+ incoming email handling. Here is an example:
66
+
67
+ class Mailman < Glue::Mailer
68
+ def receive(mail)
69
+ article = Article.new(mail.subject, mail.body)
70
+ article.category = Category.find_by_name(mail.to.split('@').first)
71
+ article.save
72
+ end
73
+ end
74
+
75
+ * Added script/runner in proto as a convenience to running
76
+ ruby code in your application environment.
77
+
78
+ * Many fixes in the caching infrastructure.
79
+
80
+ * Many fixes in the XMLRPC service infrastructure.
81
+
82
+ * Many smaller changes and feature implementations that make
83
+ development with Nitro so much more pleasurable.
84
+
85
+
1
86
  == Version 0.21.2
2
87
 
3
88
  This is mainly a bug fix release. Some minor features are
4
89
  implemented:
5
90
 
6
- * Plugable dispatchers. A new dispatcher that implicitly handles
91
+ * Pluggable dispatchers. A new dispatcher that implicitly handles
7
92
  nice urls is enabled by default. You can easily change to the
8
93
  old general dispatcher though.
9
94
 
@@ -25,7 +25,7 @@ module Nitro
25
25
 
26
26
  # The version.
27
27
 
28
- Version = '0.21.2'
28
+ Version = '0.22.0'
29
29
 
30
30
  # Library path.
31
31
 
@@ -204,8 +204,10 @@ class CgiUtils
204
204
  if (:post == method) and
205
205
  %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n.match(context.headers['CONTENT_TYPE'])
206
206
  boundary = $1.dup
207
- # context.params = read_multipart(boundary, Integer(context.headers['CONTENT_LENGTH']), context.in, context.headers)
208
207
  context.params = parse_multipart(context, boundary)
208
+
209
+ # Also include the URL parameters.
210
+ context.params.update(CgiUtils.parse_query_string(context.query_string))
209
211
  else
210
212
  case method
211
213
  when :get, :head
@@ -338,3 +340,4 @@ end
338
340
 
339
341
  # * George Moschovitis <gm@navel.gr>
340
342
  # * James Britt <james_b@neurogami.com>
343
+ # * Michael Neumann <mneumann@ntecs.de>
@@ -56,6 +56,8 @@ class Scgi
56
56
  end
57
57
 
58
58
  def self.start(server)
59
+
60
+ puts '-------------1'
59
61
  children = "5"
60
62
  host = "127.0.0.0"
61
63
  port = "8888"
@@ -83,7 +83,7 @@ class WebrickAdapter < WEBrick::HTTPServlet::AbstractServlet
83
83
  rescue WEBrick::HTTPStatus::PartialContent, WEBrick::HTTPStatus::NotModified => err
84
84
  res.set_error(err)
85
85
  return true
86
- rescue
86
+ rescue Object => ex
87
87
  return false
88
88
  ensure
89
89
  unrewrite(req)
@@ -24,7 +24,7 @@ module Caching
24
24
  filepath = output_cache_path(path)
25
25
  FileUtils.makedirs(File.dirname(filepath))
26
26
  File.open(filepath, 'w+') { |f| f.write(content) }
27
- Logger.debug "Cached page: #{filepath}" if $DBG
27
+ Logger.debug "Cached page '#{filepath}'" if $DBG
28
28
  end
29
29
 
30
30
  # Enable output caching for the given actions.
@@ -35,16 +35,16 @@ module Caching
35
35
  str = actions.collect { |a| ":#{a}" }.join(', ')
36
36
 
37
37
  module_eval %{
38
- post "do_cache_output", :only => [ #{str} ]
38
+ after "do_cache_output", :on => [ #{str} ]
39
39
  }
40
40
  end
41
41
 
42
42
  private
43
43
 
44
44
  def output_cache_path(path)
45
- filename = ((path.empty? || path == '/') ? '/index' : path.dup)
45
+ filename = ((path.empty? || path == '/') ? 'index.html' : path.dup)
46
46
  # filename.gsub!(/\/$/, '')
47
- filename << 'index.html' unless (name.split('/').last || name).include? '.'
47
+ filename << 'index.html' unless (filename.split('/').last || filename).include? '.'
48
48
  return output_cache_root + '/' + filename
49
49
  end
50
50
 
@@ -60,7 +60,8 @@ module Caching
60
60
 
61
61
  def expire_output(name)
62
62
  begin
63
- FileUtils.rm("#{context.dispatcher.public_root}/#{name}/index.html")
63
+ Logger.debug "Expirinig cache file '#{context.dispatcher.public_root}/#{name}'" if $DBG
64
+ FileUtils.rm_rf("#{context.dispatcher.public_root}/#{name}")
64
65
  rescue Object
65
66
  # gmosx: is this the right thing to do?
66
67
  end
@@ -1,6 +1,6 @@
1
1
  require 'facet/object/singleton_class'
2
2
 
3
- require 'nitro/template'
3
+ require 'glue/template'
4
4
  require 'nitro/compiler/errors'
5
5
 
6
6
  module Nitro
@@ -135,7 +135,13 @@ class Compiler
135
135
  code << %{
136
136
  params = []
137
137
  if context.query_string
138
- context.query_string.split(/[&;]/).each do |qs|
138
+ context.query_string.split(/[&;]/).each_with_index do |qs, i|
139
+ }
140
+ # Don't pass more parameters than the action's arity.
141
+ if param_count > 0
142
+ code << "break if i >= #{param_count};"
143
+ end
144
+ code << %{
139
145
  params << qs.split(/=/).last
140
146
  end
141
147
  end
@@ -232,7 +238,6 @@ class Compiler
232
238
  compile_template(klass, action, template_path) if template_path
233
239
 
234
240
  return true
235
-
236
241
  end
237
242
 
238
243
  # Compiles an action method in the given (controller) class.
@@ -13,7 +13,7 @@ class Dispatcher
13
13
  include Router
14
14
 
15
15
  # The dispatcher specialization used.
16
-
16
+
17
17
  setting :mode, :default => :nice, :doc => 'The dispatcher specialization used'
18
18
 
19
19
  unless const_defined? :ROOT
@@ -86,7 +86,7 @@ class Dispatcher
86
86
  end
87
87
 
88
88
  auto_mixin(c)
89
-
89
+
90
90
  # Try to setup a template_root if none is defined:
91
91
 
92
92
  unless c.template_root
@@ -27,7 +27,7 @@ class Dispatcher
27
27
  end
28
28
 
29
29
  unless parts.empty?
30
- context.headers['QUERY_STRING'] = "#{parts.join(';')}#{context.headers['QUERY_STRING']}"
30
+ context.headers['QUERY_STRING'] = "#{parts.join(';')};#{context.headers['QUERY_STRING']}"
31
31
  end
32
32
 
33
33
  return klass, "#{action}_action", base
@@ -2,6 +2,9 @@ require 'rexml/document'
2
2
  require 'rexml/streamlistener'
3
3
 
4
4
  require 'facet/string/capitalized%3F'
5
+ require 'facet/string/camelize'
6
+
7
+ require 'glue/configuration'
5
8
 
6
9
  module Nitro
7
10
 
@@ -17,6 +20,10 @@ module Nitro
17
20
  #++
18
21
 
19
22
  class Element
23
+ # The prefix for element tags (in xhtml compatibility mode)
24
+
25
+ setting :prefix, :default => 'x', :doc => 'The prefix for element tags'
26
+
20
27
  # The parent of this element.
21
28
 
22
29
  attr_accessor :_parent
@@ -84,8 +91,15 @@ class ElementProcessor # :nodoc: all
84
91
  @stack = []
85
92
  end
86
93
 
94
+ PREFIX_RE = /^#{Element.prefix}:/
95
+ CAPITALIZED_RE = /^[A-Z]/
96
+
87
97
  def tag_start(name, attributes)
88
- if name =~ /^[A-Z]/ # .capitalized?
98
+ # check if the name starts with the element prefix, or
99
+ # is capitalized.
100
+ if name =~ PREFIX_RE or name =~ CAPITALIZED_RE
101
+ name = name.split(':')[1].camelize if name =~ PREFIX_RE
102
+
89
103
  obj = Object.const_get(name).new
90
104
 
91
105
  attributes.each do | k, v |
@@ -111,7 +125,10 @@ class ElementProcessor # :nodoc: all
111
125
  end
112
126
 
113
127
  def tag_end(name)
114
- if name =~ /^[A-Z]/ # .capitalized?
128
+ # check if the name starts with the element prefix, or
129
+ # is capitalized.
130
+ if name =~ PREFIX_RE or name =~ CAPITALIZED_RE
131
+ name = name.split(':')[1].camelize if name =~ PREFIX_RE
115
132
  obj, @buffer = @stack.pop
116
133
  @buffer << obj.render
117
134
  else