nitro 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +43 -1
- data/README +7 -1
- data/doc/AUTHORS +3 -0
- data/doc/RELEASES +153 -2
- data/lib/nitro.rb +1 -1
- data/lib/nitro/caching.rb +6 -0
- data/lib/nitro/caching/actions.rb +4 -6
- data/lib/nitro/caching/fragments.rb +3 -5
- data/lib/nitro/caching/output.rb +2 -2
- data/lib/nitro/conf.rb +2 -4
- data/lib/nitro/controller.rb +2 -0
- data/lib/nitro/dispatcher.rb +5 -32
- data/lib/nitro/element.rb +2 -2
- data/lib/nitro/flash.rb +105 -0
- data/lib/nitro/render.rb +2 -2
- data/lib/nitro/response.rb +2 -4
- data/lib/nitro/runner.rb +3 -0
- data/lib/nitro/service.rb +2 -0
- data/lib/nitro/testing/testcase.rb +3 -7
- data/test/nitro/builder/tc_atom.rb +0 -2
- data/test/nitro/tc_caching.rb +3 -2
- data/test/nitro/tc_controller.rb +4 -2
- data/test/nitro/tc_element.rb +0 -1
- data/test/nitro/tc_flash.rb +45 -0
- metadata +6 -4
data/CHANGELOG
CHANGED
@@ -1,4 +1,46 @@
|
|
1
|
-
|
1
|
+
17-06-2005 George Moschovitis <gm@navel.gr>
|
2
|
+
|
3
|
+
* README: updated.
|
4
|
+
|
5
|
+
* doc/RELEASES: updated.
|
6
|
+
|
7
|
+
* lib/nitro/dispatcher.rb (#controller_for_class): added
|
8
|
+
SUPERB new support for reloading!!! I LOVE IT!
|
9
|
+
|
10
|
+
* lib/nitro/runner.rb (#setup_debug): call autoreload by default,
|
11
|
+
dissable caching in debug mode.
|
12
|
+
|
13
|
+
* lib/nitro/caching/*: small fixes.
|
14
|
+
|
15
|
+
* lib/nitro/caching.rb (#caching_enabled): introduced.
|
16
|
+
|
17
|
+
16-06-2005 George Moschovitis <gm@navel.gr>
|
18
|
+
|
19
|
+
* doc/RELEASES: updated.
|
20
|
+
|
21
|
+
15-06-2005 George Moschovitis <gm@navel.gr>
|
22
|
+
|
23
|
+
* test/nitro/tc_controller.rb: fixed to pass again.
|
24
|
+
|
25
|
+
* lib/nitro/flash.rb (#flash): made private.
|
26
|
+
|
27
|
+
08-06-2005 George Moschovitis <gm@navel.gr>
|
28
|
+
|
29
|
+
* lib/nitro/testing/testcase.rb: Og related fix.
|
30
|
+
|
31
|
+
* lib/nitro/controller.rb: include flashing by default.
|
32
|
+
|
33
|
+
* lib/nitro/flash.rb: introduced and implemented,
|
34
|
+
added aspects,
|
35
|
+
(#set_dirty): fixed flag.
|
36
|
+
|
37
|
+
02-06-2005 George Moschovitis <gm@navel.gr>
|
38
|
+
|
39
|
+
* lib/nitro/element.rb: fixed a bug with capitalize.
|
40
|
+
|
41
|
+
01-06-2005 George Moschovitis <gm@navel.gr>
|
42
|
+
|
43
|
+
* --- VERSION 0.18.0 ---
|
2
44
|
|
3
45
|
* test/*: some fixes to make the tests pass again.
|
4
46
|
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Nitro 0.
|
1
|
+
= Nitro 0.19.0 README
|
2
2
|
|
3
3
|
Nitro is an efficient, yet simple engine for developing professional Web
|
4
4
|
Applications using the Ruby language. Nitro aims to provide a robust
|
@@ -255,10 +255,16 @@ The latest version of Nitro can be found at
|
|
255
255
|
|
256
256
|
* http://nitro.rubyforge.org
|
257
257
|
|
258
|
+
== Documentation
|
259
|
+
|
258
260
|
Documentation for Nitro can be found at
|
259
261
|
|
260
262
|
* http://nitro.rubyforge.org
|
261
263
|
|
264
|
+
Don't forget to read the file doc/RELEASES for usefull
|
265
|
+
documentation bits. Also, have a look at the test cases in
|
266
|
+
the test directory for examples of usage.
|
267
|
+
|
262
268
|
|
263
269
|
== Requirements
|
264
270
|
|
data/doc/AUTHORS
CHANGED
@@ -9,6 +9,9 @@ IDEAS, ADDITIONAL CODING, SUPPORT:
|
|
9
9
|
* Anastasios Koutoumanos <ak@navel.gr>
|
10
10
|
Design, additional coding.
|
11
11
|
|
12
|
+
* Dan Yoder <dan@zeraweb.com>
|
13
|
+
Original 'Elements' implementation, bug reports.
|
14
|
+
|
12
15
|
* James Britt <james_b@neurogami.com>
|
13
16
|
Additional code, design, bug reports.
|
14
17
|
|
data/doc/RELEASES
CHANGED
@@ -1,4 +1,155 @@
|
|
1
|
-
== Version 0.
|
1
|
+
== Version 0.19.0
|
2
|
+
|
3
|
+
Og reloaded part 2: Another superb release introducing a balanced
|
4
|
+
mix of innovative new features, common but useful stuff and bug
|
5
|
+
fixes.
|
6
|
+
|
7
|
+
Some notable changes:
|
8
|
+
|
9
|
+
* Og polymorphic relations. A groundbreaking feature made possible
|
10
|
+
by Og's unique design and Ruby's power. Let's use an example
|
11
|
+
to explain the concept:
|
12
|
+
|
13
|
+
class Comment
|
14
|
+
...
|
15
|
+
belongs_to Object # polymorphic marker
|
16
|
+
end
|
17
|
+
|
18
|
+
class User
|
19
|
+
...
|
20
|
+
has_many Comment
|
21
|
+
end
|
22
|
+
|
23
|
+
class Article
|
24
|
+
...
|
25
|
+
has_many Comment
|
26
|
+
end
|
27
|
+
|
28
|
+
u = User.new
|
29
|
+
u.comments << User::Comment('Hello')
|
30
|
+
|
31
|
+
a = Article.new
|
32
|
+
a.comments << Article::Comment('Wow!')
|
33
|
+
|
34
|
+
User::Comment and Article::Comment where automatically created
|
35
|
+
by Og and are serialized in different tables (also automatically
|
36
|
+
created by Og). This is the next step in DRY!
|
37
|
+
|
38
|
+
* Og now supports inheritance using the well known Single Table
|
39
|
+
Inheritance pattern. Thanks to Og's advanced design the pattern
|
40
|
+
is fully encapsulated:
|
41
|
+
|
42
|
+
class Document
|
43
|
+
...
|
44
|
+
schema_inheritance
|
45
|
+
end
|
46
|
+
|
47
|
+
class Article < Document
|
48
|
+
..
|
49
|
+
end
|
50
|
+
|
51
|
+
class Photo < Document
|
52
|
+
..
|
53
|
+
end
|
54
|
+
|
55
|
+
Document.all # => includes Articles and Photos
|
56
|
+
Article.all # => only Articles
|
57
|
+
|
58
|
+
User.documents # => Articles and Photos
|
59
|
+
User.documents(:type => Photo) # => only photos.
|
60
|
+
|
61
|
+
Btw, this feature is orthogonal to the polymorphic relations
|
62
|
+
feature just described, giving the developer great
|
63
|
+
flexibility.
|
64
|
+
|
65
|
+
* Added SUPERB support for auto reloading, the new system
|
66
|
+
can detect source changes everywhere! Based on original
|
67
|
+
code by Michael Neumann.
|
68
|
+
|
69
|
+
* Introduced the concept of Flash, a temporal store where
|
70
|
+
objects that should be kept alive for the next request are
|
71
|
+
saved.
|
72
|
+
|
73
|
+
* Recoded the Blog example to use the Elements system for
|
74
|
+
shading instead of XSLT. The new code runs easier under Windows
|
75
|
+
(so the no_xsl_blog example is now removed). Here comes an
|
76
|
+
example:
|
77
|
+
|
78
|
+
<Page>
|
79
|
+
<Box>
|
80
|
+
Please login as an author by entering the blog password.
|
81
|
+
<br />
|
82
|
+
The password is: <b>#{Blog.password}</b>.
|
83
|
+
</Box>
|
84
|
+
|
85
|
+
<Error>#@error</Error>
|
86
|
+
...
|
87
|
+
</Page>
|
88
|
+
|
89
|
+
The <Page> tag is supported by the Page Ruby class to do the
|
90
|
+
programmatic rendering of templates or logic code:
|
91
|
+
|
92
|
+
class Page
|
93
|
+
def render
|
94
|
+
...
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
This system can be used to create a library of useful
|
99
|
+
components to abstract common tasks.
|
100
|
+
|
101
|
+
* The updated Blog example demonstrates how easy it is to write
|
102
|
+
webservices using Nitro and the experimental Service feature.
|
103
|
+
The code is so short, so lets paste it here:
|
104
|
+
|
105
|
+
module BloggerApi
|
106
|
+
SBlog = Struct.new(:url, :blogid, :blogName)
|
107
|
+
|
108
|
+
def blogger__getUsersBlogs(appkey, username, password)
|
109
|
+
Blog.all.collect { |b| SBlog.new('http://www.gmosx.com', b.oid, b.title) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
module MetaWeblogApi
|
114
|
+
def metaWeblog__newPost(blogid, username, password, content, publish)
|
115
|
+
entry = BlogEntry.new(content['title'], content['description'])
|
116
|
+
entry.blog = Blog[blogid]
|
117
|
+
entry.save
|
118
|
+
entry.oid
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
module MovableTypeApi
|
123
|
+
SCategory = Struct.new(:categoryId, :categoryName)
|
124
|
+
|
125
|
+
def mt__getCategoryList(blogid, username, password)
|
126
|
+
blog = Blog[blogid]
|
127
|
+
blog.categories.collect { |c| SCategory.new(c.oid, c.title) }
|
128
|
+
end
|
129
|
+
|
130
|
+
def mt__setPostCategories(postid, username, password, categories)
|
131
|
+
cid = categories.first['categoryId']
|
132
|
+
BlogEntry.update(postid, "category_oid=#{cid}")
|
133
|
+
true
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class ApiController < Nitro::XmlRpcService
|
138
|
+
include BloggerApi
|
139
|
+
include MovableTypeApi
|
140
|
+
include MetaWeblogApi
|
141
|
+
end
|
142
|
+
|
143
|
+
That's all!
|
144
|
+
|
145
|
+
* Integrated an SQLite3 patch by Ghislain Mary.
|
146
|
+
|
147
|
+
* Integrated PostgreSQL binary data patch by Michael Neumann.
|
148
|
+
|
149
|
+
* Fixed all reported bugs.
|
150
|
+
|
151
|
+
|
152
|
+
== Version 0.18.0 was released on 01/06/2005.
|
2
153
|
|
3
154
|
Mainly a bug fix release. Many small improvements were
|
4
155
|
implemented. All reported bugs were fixed, as well as bugs found
|
@@ -47,7 +198,7 @@ Some notable changes:
|
|
47
198
|
* Cleaned up some source files.
|
48
199
|
|
49
200
|
|
50
|
-
== Version 0.17.0
|
201
|
+
== Version 0.17.0 was released on 16/05/2005.
|
51
202
|
|
52
203
|
The biggest release yet, featuring the brand new implementation
|
53
204
|
of Og. Due to the many changes this should be considered a preview
|
data/lib/nitro.rb
CHANGED
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: actions.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'fileutils'
|
6
2
|
|
7
3
|
module Nitro
|
@@ -22,7 +18,7 @@ module Caching
|
|
22
18
|
module ClassMethods
|
23
19
|
|
24
20
|
def cache_action(*actions)
|
25
|
-
return unless caching_enabled
|
21
|
+
return unless caching_enabled?
|
26
22
|
|
27
23
|
before_filter(
|
28
24
|
%{
|
@@ -53,7 +49,7 @@ module Caching
|
|
53
49
|
#++
|
54
50
|
|
55
51
|
def expire_action(*actions)
|
56
|
-
return unless caching_enabled
|
52
|
+
return unless caching_enabled?
|
57
53
|
|
58
54
|
for action in [actions].flatten
|
59
55
|
expire_fragment(action)
|
@@ -65,3 +61,5 @@ module Caching
|
|
65
61
|
end
|
66
62
|
|
67
63
|
end
|
64
|
+
|
65
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: fragments.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'fileutils'
|
6
2
|
|
7
3
|
require 'glue/attribute'
|
@@ -48,7 +44,7 @@ module Caching
|
|
48
44
|
end
|
49
45
|
|
50
46
|
def cache_fragment(block, name, options = {})
|
51
|
-
unless caching_enabled
|
47
|
+
unless caching_enabled?
|
52
48
|
block.call
|
53
49
|
return
|
54
50
|
end
|
@@ -70,3 +66,5 @@ module Caching
|
|
70
66
|
end
|
71
67
|
|
72
68
|
end
|
69
|
+
|
70
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/caching/output.rb
CHANGED
@@ -30,7 +30,7 @@ module Caching
|
|
30
30
|
# Enable output caching for the given actions.
|
31
31
|
|
32
32
|
def cache_output(*actions)
|
33
|
-
return unless
|
33
|
+
return unless caching_enabled?
|
34
34
|
|
35
35
|
str = actions.collect { |a| ":#{a}" }.join(', ')
|
36
36
|
|
@@ -53,7 +53,7 @@ module Caching
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def do_cache_output
|
56
|
-
if caching_enabled and
|
56
|
+
if caching_enabled? and caching_allowed?
|
57
57
|
self.class.do_cache_output(@request.uri, @out)
|
58
58
|
end
|
59
59
|
end
|
data/lib/nitro/conf.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: conf.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'glue/flexob'
|
6
2
|
|
7
3
|
require 'nitro/dispatcher'
|
@@ -41,3 +37,5 @@ class Conf < Flexob
|
|
41
37
|
end
|
42
38
|
|
43
39
|
end
|
40
|
+
|
41
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/controller.rb
CHANGED
@@ -4,6 +4,7 @@ require 'nitro'
|
|
4
4
|
require 'nitro/render'
|
5
5
|
require 'nitro/scaffold'
|
6
6
|
require 'nitro/caching'
|
7
|
+
require 'nitro/flash'
|
7
8
|
|
8
9
|
module Nitro
|
9
10
|
|
@@ -78,6 +79,7 @@ class Controller
|
|
78
79
|
include Glue::Aspects
|
79
80
|
include Scaffolding
|
80
81
|
include Caching
|
82
|
+
include Flashing
|
81
83
|
|
82
84
|
# A hash containing metadata for the action
|
83
85
|
# methods.
|
data/lib/nitro/dispatcher.rb
CHANGED
@@ -140,44 +140,17 @@ class Dispatcher
|
|
140
140
|
|
141
141
|
# Get the controller for the given key.
|
142
142
|
# Also handles reloading of controllers.
|
143
|
-
#--
|
144
|
-
# gmosx, FIXME: this method is a NASTY hack, anyone can
|
145
|
-
# help me fix this ?
|
146
|
-
#++
|
147
143
|
|
148
144
|
def controller_class_for(key, context)
|
149
145
|
klass = @controllers[key]
|
150
146
|
|
151
|
-
if (:full == Rendering.reload)
|
152
|
-
|
153
|
-
|
154
|
-
while (c = c.superclass) != Nitro::Controller
|
155
|
-
ancestors.unshift(c)
|
147
|
+
if klass and (:full == Rendering.reload)
|
148
|
+
klass.instance_methods.grep(/(action$)|(template$)/).each do |m|
|
149
|
+
klass.send(:remove_method, m) rescue nil
|
156
150
|
end
|
157
|
-
|
158
|
-
for c in ancestors
|
159
|
-
actions = c.public_instance_methods.find_all { |m| m.to_s =~ /(_action$)|(_template$)/ }
|
160
|
-
actions += c.action_methods
|
161
|
-
actions.each { |m| c.send(:remove_method, m) rescue nil }
|
162
|
-
c.advices = []
|
163
|
-
|
164
|
-
Object.send(:remove_const, c) rescue nil
|
165
|
-
load(c::DEF_FILE)
|
166
|
-
c = Object.const_get(klass.name.intern)
|
167
|
-
end
|
168
|
-
#=end
|
169
|
-
=begin
|
170
|
-
def_file = klass::DEF_FILE
|
171
|
-
# Object.send(:remove_const, klass) rescue nil
|
172
|
-
# FIXME: also reload superclasses!
|
173
|
-
Controller.remove_subclasses
|
174
|
-
load(def_file)
|
175
|
-
=end
|
176
|
-
klass = @controllers[key] = Object.const_get(klass.name.intern)
|
177
|
-
context[:__RELOADED__] = true
|
178
151
|
end
|
179
|
-
|
180
|
-
return klass
|
152
|
+
|
153
|
+
return klass
|
181
154
|
end
|
182
155
|
|
183
156
|
end
|
data/lib/nitro/element.rb
CHANGED
@@ -85,7 +85,7 @@ class ElementProcessor # :nodoc: all
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def tag_start(name, attributes)
|
88
|
-
if name.capitalized?
|
88
|
+
if name =~ /^[A-Z]/ # .capitalized?
|
89
89
|
obj = Object.const_get(name).new
|
90
90
|
|
91
91
|
attributes.each do | k, v |
|
@@ -111,7 +111,7 @@ class ElementProcessor # :nodoc: all
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def tag_end(name)
|
114
|
-
if name.capitalized?
|
114
|
+
if name =~ /^[A-Z]/ # .capitalized?
|
115
115
|
obj, @buffer = @stack.pop
|
116
116
|
@buffer << obj.render
|
117
117
|
else
|
data/lib/nitro/flash.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module Nitro
|
2
|
+
|
3
|
+
# This module adds flashing support to the Controllers.
|
4
|
+
|
5
|
+
module Flashing
|
6
|
+
|
7
|
+
def self.append_features(base)
|
8
|
+
super
|
9
|
+
base.pre 'flash.discard'
|
10
|
+
base.post 'flash.clean'
|
11
|
+
end
|
12
|
+
|
13
|
+
# A Flash is a special hash object that lives in the session.
|
14
|
+
# The values stored in the Flash are typically maintained
|
15
|
+
# for the duration of one request.
|
16
|
+
#
|
17
|
+
# You may want to use the Flash to pass error messages or
|
18
|
+
# other short lived objects.
|
19
|
+
|
20
|
+
class Flash < Hash
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
@dirty = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def []=(key, val)
|
28
|
+
super
|
29
|
+
keep(key)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Keep the specific key or the whole Flash.
|
33
|
+
|
34
|
+
def keep(key = nil)
|
35
|
+
set_dirty(key, false)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Discard the specific key or the whole Flash.
|
39
|
+
|
40
|
+
def discard(key = nil)
|
41
|
+
set_dirty(key)
|
42
|
+
end
|
43
|
+
|
44
|
+
def clean # :nodoc:
|
45
|
+
keys.each do |k|
|
46
|
+
unless @dirty[k]
|
47
|
+
set_dirty(k)
|
48
|
+
else
|
49
|
+
delete(k)
|
50
|
+
@dirty.delete(k)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# remove externaly updated keys.
|
55
|
+
|
56
|
+
(@dirty.keys - keys).each { |k| @dirty.delete k }
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def set_dirty(key = nil, flag = true)
|
62
|
+
if key
|
63
|
+
@dirty[key] = flag
|
64
|
+
else
|
65
|
+
keys.each { |k| @dirty[k] = flag }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
# A Flash for the current request only.
|
72
|
+
#--
|
73
|
+
# gmosx: crap, not really needed!
|
74
|
+
#++
|
75
|
+
|
76
|
+
class FlashNow
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def flash
|
82
|
+
session[:FLASH] ||= Flash.new
|
83
|
+
end
|
84
|
+
|
85
|
+
# Some useful aspects.
|
86
|
+
|
87
|
+
# Marks flash entries as used and expose the flash to the
|
88
|
+
# view.
|
89
|
+
|
90
|
+
def init_flash
|
91
|
+
flash.discard
|
92
|
+
end
|
93
|
+
|
94
|
+
# Deletes the flash entries that were not marked for
|
95
|
+
# keeping.
|
96
|
+
|
97
|
+
def clean_flash
|
98
|
+
flash.clean
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/render.rb
CHANGED
@@ -63,7 +63,7 @@ module Rendering
|
|
63
63
|
# template_root/action.xhtml
|
64
64
|
|
65
65
|
path = "#{template_root}/#{action.gsub(/__/, '/')}.#{ext}".squeeze('/')
|
66
|
-
|
66
|
+
|
67
67
|
unless File.exist?(path)
|
68
68
|
# attempt to find a template of the form
|
69
69
|
# template_root/action/index.xhtml
|
@@ -75,7 +75,7 @@ module Rendering
|
|
75
75
|
path = nil
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
return path
|
80
80
|
end
|
81
81
|
|
data/lib/nitro/response.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: response.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
module Nitro
|
6
2
|
|
7
3
|
# HTTP Response. This module is included in Context.
|
@@ -45,3 +41,5 @@ module Response
|
|
45
41
|
end
|
46
42
|
|
47
43
|
end
|
44
|
+
|
45
|
+
# * George Moschovitis <gm@navel.gr>
|
data/lib/nitro/runner.rb
CHANGED
data/lib/nitro/service.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
3
|
-
# $Id: testcase.rb 1 2005-04-11 11:04:30Z gmosx $
|
4
|
-
|
5
1
|
require 'test/unit'
|
6
2
|
require 'test/unit/assertions'
|
7
3
|
require 'rexml/document'
|
@@ -25,8 +21,6 @@ class TestCase
|
|
25
21
|
@conf.template_root ||= File.join(File.dirname(__FILE__), '..', 'public')
|
26
22
|
|
27
23
|
begin
|
28
|
-
Og.db.get_connection if defined?(Og) and Og.db
|
29
|
-
|
30
24
|
context = Context.new(@conf)
|
31
25
|
|
32
26
|
# context.in = StringIO.new(req.body || "")
|
@@ -45,7 +39,7 @@ class TestCase
|
|
45
39
|
|
46
40
|
return context
|
47
41
|
ensure
|
48
|
-
Og.
|
42
|
+
Og.manager.put_store if defined?(Og) and Og.manager
|
49
43
|
end
|
50
44
|
end
|
51
45
|
alias_method :process, :handle
|
@@ -53,3 +47,5 @@ class TestCase
|
|
53
47
|
end
|
54
48
|
|
55
49
|
end
|
50
|
+
|
51
|
+
# * George Moschovitis <gm@navel.gr>
|
@@ -16,8 +16,6 @@ class TestCaseBuildersAtom < Test::Unit::TestCase # :nodoc: all
|
|
16
16
|
blogs << Blog.new('Hello3', 'World3', 'uri3', 'Renos');
|
17
17
|
|
18
18
|
rss = AtomBuilder.build(blogs, :link => 'http://www.navel.gr')
|
19
|
-
|
20
|
-
puts '--', rss
|
21
19
|
=end
|
22
20
|
# assert_match %r{<link>http://www.navel.gr/uri1</link>}, rss
|
23
21
|
# assert_match %r{<link>http://www.navel.gr/uri2</link>}, rss
|
data/test/nitro/tc_caching.rb
CHANGED
@@ -12,7 +12,8 @@ class TC_Caching < Test::Unit::TestCase # :nodoc: all
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_all
|
15
|
-
|
16
|
-
|
15
|
+
# bug:
|
16
|
+
assert_equal [], Caching.public_instance_methods
|
17
|
+
assert_equal [], DummyCa.public_instance_methods.grep(/caching/)
|
17
18
|
end
|
18
19
|
end
|
data/test/nitro/tc_controller.rb
CHANGED
@@ -15,7 +15,7 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
|
|
15
15
|
class Blog2Controller < Controller
|
16
16
|
attr_reader :aflag, :tflag
|
17
17
|
|
18
|
-
@template_root = 'test/public/blog'
|
18
|
+
@template_root = File.expand_path(Nitro::LibPath + '../../test/public/blog')
|
19
19
|
|
20
20
|
def list
|
21
21
|
@aflag = true
|
@@ -26,7 +26,6 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
|
|
26
26
|
@disp = Dispatcher.new({
|
27
27
|
'blog' => Blog2Controller,
|
28
28
|
})
|
29
|
-
@disp.template_root = 'test/public/root'
|
30
29
|
@conf = OpenStruct.new
|
31
30
|
@conf.dispatcher = @disp
|
32
31
|
end
|
@@ -36,13 +35,16 @@ class TC_Controller < Test::Unit::TestCase # :nodoc: all
|
|
36
35
|
ctx.headers = {}
|
37
36
|
ctx.params = {}
|
38
37
|
ctx.headers['REQUEST_URI'] = '/blog/list'
|
38
|
+
ctx.instance_eval '@session = {}'
|
39
39
|
klass, action = ctx.dispatcher.dispatch(ctx.path, ctx)
|
40
40
|
c = klass.new(ctx)
|
41
|
+
|
41
42
|
begin
|
42
43
|
c.send(action)
|
43
44
|
rescue RenderExit
|
44
45
|
# drink
|
45
46
|
end
|
47
|
+
|
46
48
|
assert_equal true, c.aflag
|
47
49
|
assert_equal true, $include1
|
48
50
|
assert_equal true, $include2
|
data/test/nitro/tc_element.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
require 'nitro'
|
7
|
+
require 'nitro/controller'
|
8
|
+
require 'nitro/flash'
|
9
|
+
|
10
|
+
class TC_Flash < Test::Unit::TestCase # :nodoc: all
|
11
|
+
include Nitro
|
12
|
+
|
13
|
+
class MyController < Controller
|
14
|
+
attr_accessor :flag
|
15
|
+
|
16
|
+
def action1
|
17
|
+
flash[:msg] = 'Hello world!'
|
18
|
+
end
|
19
|
+
|
20
|
+
def action2
|
21
|
+
@flag = flash[:msg]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup
|
26
|
+
@conf = OpenStruct.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
@conf = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_all
|
34
|
+
ctx = Context.new(@conf)
|
35
|
+
ctx.headers = {}
|
36
|
+
ctx.params = {}
|
37
|
+
ctx.instance_eval '@session = {}'
|
38
|
+
c = MyController.new(ctx)
|
39
|
+
c.action1
|
40
|
+
c.action2
|
41
|
+
assert_equal 'Hello world!', c.flag
|
42
|
+
c.action2
|
43
|
+
assert_equal 'Hello world!', c.flag
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: nitro
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-06-
|
6
|
+
version: 0.19.0
|
7
|
+
date: 2005-06-17
|
8
8
|
summary: Nitro Web Engine
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/nitro/element.rb
|
112
112
|
- lib/nitro/service.rb
|
113
113
|
- lib/nitro/service
|
114
|
+
- lib/nitro/flash.rb
|
114
115
|
- lib/nitro/builder/xhtml.rb
|
115
116
|
- lib/nitro/builder/xml.rb
|
116
117
|
- lib/nitro/builder/form.rb
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- test/nitro/tc_dispatcher.rb
|
151
152
|
- test/nitro/tc_element.rb
|
152
153
|
- test/nitro/tc_caching.rb
|
154
|
+
- test/nitro/tc_flash.rb
|
153
155
|
- test/nitro/builder/tc_rss.rb
|
154
156
|
- test/nitro/builder/tc_table.rb
|
155
157
|
- test/nitro/builder/tc_xhtml.rb
|
@@ -192,7 +194,7 @@ dependencies:
|
|
192
194
|
-
|
193
195
|
- "="
|
194
196
|
- !ruby/object:Gem::Version
|
195
|
-
version: 0.
|
197
|
+
version: 0.19.0
|
196
198
|
version:
|
197
199
|
- !ruby/object:Gem::Dependency
|
198
200
|
name: og
|
@@ -202,7 +204,7 @@ dependencies:
|
|
202
204
|
-
|
203
205
|
- "="
|
204
206
|
- !ruby/object:Gem::Version
|
205
|
-
version: 0.
|
207
|
+
version: 0.19.0
|
206
208
|
version:
|
207
209
|
- !ruby/object:Gem::Dependency
|
208
210
|
name: facets
|