nitro 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +124 -0
- data/README +2 -2
- data/Rakefile +4 -12
- data/bin/nitro +1 -1
- data/bin/nitrogen +47 -31
- data/doc/AUTHORS +3 -3
- data/doc/RELEASES +50 -1
- data/examples/README +7 -0
- data/lib/nitro.rb +5 -4
- data/lib/nitro/{adapters → adapter}/cgi.rb +2 -4
- data/lib/nitro/{adapters → adapter}/fastcgi.rb +1 -1
- data/lib/nitro/{adapters → adapter}/webrick.rb +5 -10
- data/lib/nitro/buffering.rb +6 -0
- data/lib/nitro/{builders → builder}/atom.rb +1 -5
- data/lib/nitro/{builders → builder}/form.rb +1 -5
- data/lib/nitro/{builders → builder}/rss.rb +3 -1
- data/lib/nitro/{builders → builder}/table.rb +2 -4
- data/lib/nitro/{builders → builder}/xhtml.rb +3 -5
- data/lib/nitro/{builders → builder}/xml.rb +2 -4
- data/lib/nitro/caching.rb +6 -4
- data/lib/nitro/caching/output.rb +18 -11
- data/lib/nitro/context.rb +3 -1
- data/lib/nitro/controller.rb +29 -18
- data/lib/nitro/dispatcher.rb +2 -4
- data/lib/nitro/element.rb +2 -0
- data/lib/nitro/environment.rb +2 -4
- data/lib/nitro/errors.rb +69 -0
- data/lib/nitro/mail.rb +2 -4
- data/lib/nitro/markup.rb +20 -3
- data/lib/nitro/output.rb +5 -9
- data/lib/nitro/part.rb +2 -3
- data/lib/nitro/render.rb +49 -30
- data/lib/nitro/request.rb +2 -1
- data/lib/nitro/runner.rb +23 -12
- data/lib/nitro/scaffold.rb +5 -3
- data/lib/nitro/service.rb +22 -0
- data/lib/nitro/service/xmlrpc.rb +42 -0
- data/lib/nitro/session.rb +2 -4
- data/lib/nitro/template.rb +8 -10
- data/lib/nitro/testing.rb +0 -4
- data/proto/public/error.xhtml +27 -2
- data/test/nitro/{adapters → adapter}/raw_post1.bin +0 -0
- data/test/nitro/{adapters → adapter}/tc_cgi.rb +1 -1
- data/test/nitro/{adapters → adapter}/tc_webrick.rb +1 -1
- data/test/nitro/{builders → builder}/tc_atom.rb +1 -1
- data/test/nitro/{builders → builder}/tc_rss.rb +1 -1
- data/test/nitro/{builders → builder}/tc_table.rb +1 -1
- data/test/nitro/{builders → builder}/tc_xhtml.rb +1 -1
- data/test/nitro/{builders → builder}/tc_xml.rb +1 -1
- data/test/nitro/tc_caching.rb +18 -0
- data/test/nitro/tc_controller.rb +1 -1
- data/test/nitro/tc_mail.rb +3 -1
- metadata +33 -168
- data/examples/README.windows +0 -9
- data/examples/ajax/controller.rb +0 -21
- data/examples/ajax/public/index.xhtml +0 -72
- data/examples/ajax/public/js/ajax.js +0 -64
- data/examples/ajax/run.rb +0 -14
- data/examples/blog/README +0 -70
- data/examples/blog/conf/apache.conf +0 -30
- data/examples/blog/conf/apache.conf.new +0 -53
- data/examples/blog/conf/lhttpd.conf +0 -79
- data/examples/blog/conf/locales/de.yml +0 -4
- data/examples/blog/conf/locales/en.yml +0 -4
- data/examples/blog/log/README +0 -3
- data/examples/blog/log/apache.error_log +0 -6647
- data/examples/blog/log/rewrite_log +0 -161
- data/examples/blog/public/base.xsl +0 -153
- data/examples/blog/public/fcgi.rb +0 -5
- data/examples/blog/public/m/bubbles.gif +0 -0
- data/examples/blog/public/m/comments_curve.gif +0 -0
- data/examples/blog/public/m/down.gif +0 -0
- data/examples/blog/public/m/footer_bg.gif +0 -0
- data/examples/blog/public/m/garrow.gif +0 -0
- data/examples/blog/public/m/gbull.gif +0 -0
- data/examples/blog/public/m/grbull.gif +0 -0
- data/examples/blog/public/m/h1_bg.gif +0 -0
- data/examples/blog/public/m/header_bg.gif +0 -0
- data/examples/blog/public/m/nitro.gif +0 -0
- data/examples/blog/public/m/obull.gif +0 -0
- data/examples/blog/public/m/page_bg.gif +0 -0
- data/examples/blog/public/m/rss.gif +0 -0
- data/examples/blog/public/m/side_title_bg.gif +0 -0
- data/examples/blog/public/m/sidebar_bg.gif +0 -0
- data/examples/blog/public/style.css +0 -305
- data/examples/blog/run.rb +0 -43
- data/examples/blog/src/blog.rb +0 -21
- data/examples/blog/src/controller.rb +0 -151
- data/examples/blog/src/mailer.rb +0 -23
- data/examples/blog/src/models/blog.rb +0 -33
- data/examples/blog/src/models/content.rb +0 -18
- data/examples/blog/src/views/blog_entry_email.xhtml +0 -16
- data/examples/blog/src/views/comments.xhtml +0 -36
- data/examples/blog/src/views/entry_form.xhtml +0 -22
- data/examples/blog/src/views/error.xhtml +0 -56
- data/examples/blog/src/views/index.xhtml +0 -49
- data/examples/blog/src/views/login.xhtml +0 -26
- data/examples/blog/src/views/recent_posts.xhtml +0 -14
- data/examples/blog/src/views/view_entry.xhtml +0 -37
- data/examples/blog/src/views/view_entry.xml +0 -12
- data/examples/blog/src/xsl/base.xsl +0 -160
- data/examples/blog/src/xsl/style.xsl +0 -143
- data/examples/blog/test/tc_blog.rb +0 -43
- data/examples/flash/log/README +0 -3
- data/examples/flash/root/index.xhtml +0 -16
- data/examples/flash/root/show_inline_text.xhtml +0 -17
- data/examples/flash/run.rb +0 -7
- data/examples/no_xsl_blog/README +0 -24
- data/examples/no_xsl_blog/conf/apache.conf +0 -30
- data/examples/no_xsl_blog/conf/lhttpd.conf +0 -79
- data/examples/no_xsl_blog/conf/locales/de.yml +0 -4
- data/examples/no_xsl_blog/conf/locales/en.yml +0 -4
- data/examples/no_xsl_blog/lib/blog.rb +0 -16
- data/examples/no_xsl_blog/lib/blog/controller.rb +0 -116
- data/examples/no_xsl_blog/lib/blog/model.rb +0 -35
- data/examples/no_xsl_blog/lib/blog/template.rb +0 -138
- data/examples/no_xsl_blog/lib/content.rb +0 -47
- data/examples/no_xsl_blog/log/README +0 -3
- data/examples/no_xsl_blog/log/apache.error_log +0 -473
- data/examples/no_xsl_blog/public/comments.xhtml +0 -36
- data/examples/no_xsl_blog/public/entry_form.xhtml +0 -22
- data/examples/no_xsl_blog/public/fcgi.rb +0 -5
- data/examples/no_xsl_blog/public/index.xhtml +0 -39
- data/examples/no_xsl_blog/public/login.xhtml +0 -21
- data/examples/no_xsl_blog/public/m/bubbles.gif +0 -0
- data/examples/no_xsl_blog/public/m/comments_curve.gif +0 -0
- data/examples/no_xsl_blog/public/m/down.gif +0 -0
- data/examples/no_xsl_blog/public/m/footer_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/garrow.gif +0 -0
- data/examples/no_xsl_blog/public/m/gbull.gif +0 -0
- data/examples/no_xsl_blog/public/m/grbull.gif +0 -0
- data/examples/no_xsl_blog/public/m/h1_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/header_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/nitro.gif +0 -0
- data/examples/no_xsl_blog/public/m/obull.gif +0 -0
- data/examples/no_xsl_blog/public/m/page_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/rss.gif +0 -0
- data/examples/no_xsl_blog/public/m/side_title_bg.gif +0 -0
- data/examples/no_xsl_blog/public/m/sidebar_bg.gif +0 -0
- data/examples/no_xsl_blog/public/recent_posts.xhtml +0 -14
- data/examples/no_xsl_blog/public/style.css +0 -299
- data/examples/no_xsl_blog/public/view_entry.xhtml +0 -25
- data/examples/no_xsl_blog/public/view_entry.xml +0 -12
- data/examples/no_xsl_blog/run.rb +0 -35
- data/examples/tiny/README +0 -14
- data/examples/tiny/conf/apache.conf +0 -30
- data/examples/tiny/conf/lhttpd.conf +0 -79
- data/examples/tiny/log/README +0 -3
- data/examples/tiny/log/apache.error_log +0 -154
- data/examples/tiny/public/deep/dir/hello.xhtml +0 -3
- data/examples/tiny/public/fcgi.rb +0 -5
- data/examples/tiny/public/include.xhtml +0 -3
- data/examples/tiny/public/index.xhtml +0 -55
- data/examples/tiny/public/nitro.png +0 -0
- data/examples/tiny/public/upload.xhtml +0 -21
- data/examples/tiny/run.rb +0 -7
- data/examples/wee_style/README +0 -10
- data/examples/wee_style/run.rb +0 -50
- data/examples/why_wiki/README +0 -5
- data/examples/why_wiki/run.rb +0 -59
- data/proto/public/js/ajax.js +0 -63
data/lib/nitro/buffering.rb
CHANGED
@@ -6,6 +6,10 @@ module Nitro
|
|
6
6
|
|
7
7
|
# The output buffering mixin. Provides php-style output
|
8
8
|
# buffering functionality.
|
9
|
+
#--
|
10
|
+
# TODO: use better names but keep the ob_xxx php style methods
|
11
|
+
# as aliases.
|
12
|
+
#++
|
9
13
|
|
10
14
|
module OutputBuffering
|
11
15
|
# Output buffers stack, used for php-style nested output
|
@@ -37,3 +41,5 @@ module OutputBuffering
|
|
37
41
|
end
|
38
42
|
|
39
43
|
end
|
44
|
+
|
45
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
3
|
-
# $Id: form.rb 30 2005-04-25 12:28:02Z gmosx $
|
4
|
-
|
5
1
|
require 'glue/hash'
|
6
2
|
require 'nitro/markup'
|
7
3
|
|
@@ -25,7 +21,7 @@ module FormBuilderMixin
|
|
25
21
|
def build_form(obj, lc = nil, show_all = false)
|
26
22
|
str = '<dl>'
|
27
23
|
|
28
|
-
for p in obj.class.
|
24
|
+
for p in obj.class.properties
|
29
25
|
unless show_all
|
30
26
|
next if :oid == p.symbol
|
31
27
|
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: table.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
module Nitro
|
6
2
|
|
7
3
|
# The TableBuilder is a helper class that automates the creation
|
@@ -80,3 +76,5 @@ class TableBuilder
|
|
80
76
|
end
|
81
77
|
|
82
78
|
end
|
79
|
+
|
80
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
3
|
-
# $Id: xhtml.rb 25 2005-04-18 12:31:55Z gmosx $
|
4
|
-
|
5
|
-
require 'nitro/builders/xml'
|
1
|
+
require 'nitro/builder/xml'
|
6
2
|
|
7
3
|
module Nitro
|
8
4
|
|
@@ -117,3 +113,5 @@ class XhtmlBuilder
|
|
117
113
|
end
|
118
114
|
|
119
115
|
end
|
116
|
+
|
117
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
3
|
-
# $Id: xml.rb 25 2005-04-18 12:31:55Z gmosx $
|
4
|
-
|
5
1
|
module Nitro
|
6
2
|
|
7
3
|
# A helper mixin for programmatically building XML
|
@@ -131,3 +127,5 @@ class XmlBuilder
|
|
131
127
|
end
|
132
128
|
|
133
129
|
end
|
130
|
+
|
131
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/caching.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: caching.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'fileutils'
|
6
2
|
|
7
3
|
require 'glue/attribute'
|
@@ -15,6 +11,10 @@ module Nitro
|
|
15
11
|
# Adds support for caching.
|
16
12
|
|
17
13
|
module Caching
|
14
|
+
|
15
|
+
# Globaly enable/disable caching.
|
16
|
+
|
17
|
+
mattr_accessor :caching_enabled, true
|
18
18
|
|
19
19
|
def self.append_features(base) #:nodoc:
|
20
20
|
super
|
@@ -27,3 +27,5 @@ module Caching
|
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
30
|
+
|
31
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/caching/output.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: output.rb 9 2005-04-13 00:08:20Z nasis $
|
4
|
-
|
5
1
|
require 'fileutils'
|
6
2
|
|
7
3
|
module Nitro
|
@@ -34,21 +30,22 @@ module Caching
|
|
34
30
|
# Enable output caching for the given actions.
|
35
31
|
|
36
32
|
def cache_output(*actions)
|
37
|
-
return unless caching_enabled
|
33
|
+
return unless (caching_enabled and Caching.caching_enabled)
|
38
34
|
|
39
35
|
str = actions.collect { |a| ":#{a}" }.join(', ')
|
40
36
|
|
41
37
|
module_eval %{
|
42
|
-
|
38
|
+
post "do_cache_output", :only => [ #{str} ]
|
43
39
|
}
|
44
40
|
end
|
45
41
|
|
46
42
|
private
|
47
43
|
|
48
44
|
def output_cache_path(path)
|
49
|
-
filename = ((path.empty? || path == '/') ? '/index' : path)
|
50
|
-
filename
|
51
|
-
|
45
|
+
filename = ((path.empty? || path == '/') ? '/index' : path.dup)
|
46
|
+
# filename.gsub!(/\/$/, '')
|
47
|
+
filename << 'index.html' unless (name.split('/').last || name).include? '.'
|
48
|
+
return output_cache_root + '/' + filename
|
52
49
|
end
|
53
50
|
|
54
51
|
end
|
@@ -56,11 +53,19 @@ module Caching
|
|
56
53
|
private
|
57
54
|
|
58
55
|
def do_cache_output
|
59
|
-
if caching_enabled and caching_allowed?
|
60
|
-
self.class.do_cache_output(@request.
|
56
|
+
if caching_enabled and Caching.caching_enabled and caching_allowed?
|
57
|
+
self.class.do_cache_output(@request.uri, @out)
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
61
|
+
def expire_output(name)
|
62
|
+
begin
|
63
|
+
FileUtils.rm("#{context.dispatcher.public_root}/#{name}/index.html")
|
64
|
+
rescue Object
|
65
|
+
# gmosx: is this the right thing to do?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
64
69
|
def caching_allowed?
|
65
70
|
!@request.post?
|
66
71
|
end
|
@@ -70,3 +75,5 @@ module Caching
|
|
70
75
|
end
|
71
76
|
|
72
77
|
end
|
78
|
+
|
79
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/context.rb
CHANGED
@@ -3,7 +3,7 @@ require 'nitro/response'
|
|
3
3
|
require 'nitro/render'
|
4
4
|
require 'nitro/session'
|
5
5
|
require 'nitro/output'
|
6
|
-
require 'nitro/
|
6
|
+
require 'nitro/adapter/cgi.rb'
|
7
7
|
|
8
8
|
module Nitro
|
9
9
|
|
@@ -100,3 +100,5 @@ class Context
|
|
100
100
|
end
|
101
101
|
|
102
102
|
end
|
103
|
+
|
104
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/controller.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'glue/aspects'
|
2
2
|
|
3
|
+
require 'nitro'
|
3
4
|
require 'nitro/render'
|
4
5
|
require 'nitro/scaffold'
|
5
6
|
require 'nitro/caching'
|
@@ -81,18 +82,27 @@ class Controller
|
|
81
82
|
# A hash containing metadata for the action
|
82
83
|
# methods.
|
83
84
|
|
84
|
-
|
85
|
+
def self.action_metadata
|
86
|
+
# FIXME: improve this.
|
87
|
+
@action_metadata ||= {}
|
88
|
+
@action_metadata
|
89
|
+
end
|
90
|
+
|
91
|
+
# The directory where the templates for this controller
|
92
|
+
# reside.
|
93
|
+
|
94
|
+
@template_root = File.join(Nitro::LibPath, '..', 'proto', 'public')
|
85
95
|
|
86
96
|
def initialize(context, base = nil)
|
87
97
|
super
|
88
|
-
self.class.template_root ||= "#{@context.dispatcher.template_root}#{base}"
|
98
|
+
# self.class.template_root ||= "#{@context.dispatcher.template_root}#{base}"
|
89
99
|
end
|
90
100
|
|
91
101
|
# Use the method_missing hook to compile the actions
|
92
102
|
# for this controller.
|
93
103
|
|
94
104
|
def method_missing(action, *args)
|
95
|
-
if Rendering.compile_action(self.class, action
|
105
|
+
if Rendering.compile_action(self.class, action)
|
96
106
|
send(action, *args)
|
97
107
|
else
|
98
108
|
super
|
@@ -100,32 +110,30 @@ class Controller
|
|
100
110
|
end
|
101
111
|
|
102
112
|
class << self
|
113
|
+
attr_accessor :template_root
|
103
114
|
|
104
115
|
alias __old_inherited inherited
|
105
|
-
|
116
|
+
|
106
117
|
#--
|
107
118
|
# gmosx, FIXME: the template_root hack is temporary.
|
108
119
|
# this should be moved to the render.
|
109
120
|
#++
|
110
121
|
|
111
122
|
def inherited(child)
|
123
|
+
# child.template_root = template_root
|
124
|
+
child.template_root = 'public'
|
125
|
+
|
126
|
+
# Calculate the name of the file where this controller
|
127
|
+
# is defined. Currently used for reloading.
|
128
|
+
|
112
129
|
child.class_eval %{
|
113
130
|
if caller[2].to_s.split(':').last =~ /[0-9]+/
|
114
131
|
DEF_FILE = caller[2].to_s.strip.gsub( /:[0-9]+$/ , '')
|
115
132
|
else
|
116
133
|
DEF_FILE = caller[3].to_s.strip.gsub( /:[0-9]+$/ , '')
|
117
134
|
end
|
118
|
-
|
119
|
-
@template_root = 'public'
|
120
|
-
|
121
|
-
def self.template_root
|
122
|
-
@template_root
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.template_root=(root)
|
126
|
-
@template_root = root
|
127
|
-
end
|
128
135
|
}
|
136
|
+
|
129
137
|
__old_inherited(child)
|
130
138
|
end
|
131
139
|
|
@@ -133,10 +141,10 @@ class Controller
|
|
133
141
|
# macro.
|
134
142
|
|
135
143
|
def action(name, options)
|
136
|
-
if meta =
|
144
|
+
if meta = action_metadata[name]
|
137
145
|
meta.update(options)
|
138
146
|
else
|
139
|
-
|
147
|
+
action_metadata[name] = ActionMeta.new(options)
|
140
148
|
end
|
141
149
|
end
|
142
150
|
|
@@ -145,7 +153,7 @@ class Controller
|
|
145
153
|
|
146
154
|
def action_methods
|
147
155
|
classes = self.ancestors.reject do |a|
|
148
|
-
[Object, Kernel, Render, Controller].include?(a)
|
156
|
+
[Object, Kernel, Render, Controller, Caching].include?(a)
|
149
157
|
end
|
150
158
|
|
151
159
|
classes.delete(PP::ObjectMixin) if defined?(PP::ObjectMixin)
|
@@ -159,7 +167,10 @@ class Controller
|
|
159
167
|
return methods
|
160
168
|
end
|
161
169
|
|
162
|
-
end
|
170
|
+
end
|
163
171
|
end
|
164
172
|
|
165
173
|
end
|
174
|
+
|
175
|
+
# * George Moschovitis <gm@navel.gr>
|
176
|
+
# * James Britt <james_b@neurogami.com>
|
data/lib/nitro/dispatcher.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: dispatcher.rb 30 2005-04-25 12:28:02Z gmosx $
|
4
|
-
|
5
1
|
module Nitro
|
6
2
|
|
7
3
|
require 'nitro/controller'
|
@@ -187,3 +183,5 @@ class Dispatcher
|
|
187
183
|
end
|
188
184
|
|
189
185
|
end
|
186
|
+
|
187
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/element.rb
CHANGED
@@ -144,6 +144,8 @@ class ElementProcessor # :nodoc: all
|
|
144
144
|
def render(source)
|
145
145
|
listener = Listener.new
|
146
146
|
REXML::Document.parse_stream(source, listener)
|
147
|
+
# gmosx, FIXME: optimize this, how?
|
148
|
+
listener.buffer.gsub! /<(.*) ([^>]*)><\/\1>/, '<\1 \2 />'
|
147
149
|
return listener.buffer
|
148
150
|
end
|
149
151
|
end
|
data/lib/nitro/environment.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: environment.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
# Setup up the proposed environment. You are free
|
6
2
|
# to skip this if you dont like it. Just set
|
7
3
|
#
|
@@ -21,3 +17,5 @@ $LOAD_PATH.unshift 'src'
|
|
21
17
|
# Library code come here.
|
22
18
|
|
23
19
|
$LOAD_PATH.unshift 'lib'
|
20
|
+
|
21
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/errors.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'facet/string/demodulize'
|
2
|
+
|
3
|
+
module Nitro
|
4
|
+
|
5
|
+
class ActionCompileError < SyntaxError
|
6
|
+
SOURCE_CODE_RADIUS = 5
|
7
|
+
|
8
|
+
attr_accessor :original_excpetion
|
9
|
+
|
10
|
+
def initialize(source_code, filename, original_exception)
|
11
|
+
@source_code = source_code.split("\n")
|
12
|
+
@filename = filename
|
13
|
+
@original_exception = original_exception
|
14
|
+
end
|
15
|
+
|
16
|
+
def line_number
|
17
|
+
trace = @original_exception.backtrace.join
|
18
|
+
|
19
|
+
if trace.include?(":in `class_eval'")
|
20
|
+
trace.scan(/:([0-9]*):in `class_eval'/).first.first.to_i
|
21
|
+
else
|
22
|
+
1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def source_extract(indent = 0)
|
27
|
+
ln = line_number
|
28
|
+
start_line = [ln - SOURCE_CODE_RADIUS, 0].max
|
29
|
+
end_line = [ln + SOURCE_CODE_RADIUS - 1, @source_code.length].min
|
30
|
+
|
31
|
+
number = start_line
|
32
|
+
extract = @source_code[start_line..end_line].collect do |line|
|
33
|
+
number += 1
|
34
|
+
line = line.gsub(/; @out << %\^/, ' ?>').gsub(/\^;/, '<?r ')
|
35
|
+
if number == line_number
|
36
|
+
"#{' ' * indent}#{number}: #{line}"
|
37
|
+
else
|
38
|
+
"#{' ' * indent}#{number}: #{line}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
return extract.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def backtrace
|
46
|
+
@original_exception.backtrace.collect do |line|
|
47
|
+
# unless line =~ /\/usr/
|
48
|
+
line.gsub("#{Nitro::LibPath}/", '')
|
49
|
+
# else
|
50
|
+
# nil
|
51
|
+
# end
|
52
|
+
end.compact
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_s
|
56
|
+
"#{self.class.to_s.demodulize} (#{@original_exception.class}): '#@filename' at line ##{line_number}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def message
|
60
|
+
"#{to_s}\n#{source_extract}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class TemplateCompileError < ActionCompileError
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/mail.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# Based on original code from the RubyOnRails project.
|
2
2
|
# http://www.rubyonrails.com
|
3
3
|
# Copyright (c) 2004 David Heinemeier Hansson
|
4
|
-
#
|
5
|
-
# * George Moschovitis <gm@navel.gr>
|
6
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
7
|
-
# $Id: mail.rb 1 2005-04-11 11:04:30Z gmosx $
|
8
4
|
|
9
5
|
require 'net/smtp'
|
10
6
|
|
@@ -270,3 +266,5 @@ class Mailer < Mail
|
|
270
266
|
end
|
271
267
|
|
272
268
|
end
|
269
|
+
|
270
|
+
# * George Moschovitis <gm@navel.gr>
|