nitro 0.12.0 → 0.13.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 → CHANGELOG} +137 -0
- data/INSTALL +1 -2
- data/README +1 -1
- data/Rakefile +10 -61
- data/benchmark/{nitro/bench.rb → bench.rb} +1 -1
- data/benchmark/{nitro/simple-webrick-n-200.txt → simple-webrick-n-200.txt} +0 -0
- data/benchmark/{nitro/static-webrick-n-200.txt → static-webrick-n-200.txt} +0 -0
- data/benchmark/{nitro/tiny-lhttpd-n-200-c-5.txt → tiny-lhttpd-n-200-c-5.txt} +0 -0
- data/benchmark/{nitro/tiny-webrick-n-200-c-5.txt → tiny-webrick-n-200-c-5.txt} +0 -0
- data/benchmark/{nitro/tiny-webrick-n-200.txt → tiny-webrick-n-200.txt} +0 -0
- data/benchmark/{nitro/tiny2-webrick-n-200.txt → tiny2-webrick-n-200.txt} +0 -0
- data/doc/{ChangeLog.1 → CHANGELOG.1} +0 -0
- data/{RELEASES → doc/RELEASES} +46 -0
- data/doc/faq.txt +7 -0
- data/examples/README.windows +1 -1
- data/examples/ajax/controller.rb +21 -0
- data/examples/ajax/public/index.xhtml +70 -0
- data/examples/ajax/public/js/ajax.js +64 -0
- data/examples/ajax/run.rb +16 -0
- data/examples/blog/README +6 -3
- data/examples/blog/conf/apache.conf +2 -2
- data/examples/blog/conf/lhttpd.conf +2 -2
- data/examples/blog/log/apache.error_log +777 -0
- data/examples/blog/{root → public}/base.xsl +0 -0
- data/examples/blog/{root → public}/fcgi.rb +0 -0
- data/examples/blog/{root → public}/m/bubbles.gif +0 -0
- data/examples/blog/{root → public}/m/comments_curve.gif +0 -0
- data/examples/blog/{root → public}/m/down.gif +0 -0
- data/examples/blog/{root → public}/m/footer_bg.gif +0 -0
- data/examples/blog/{root → public}/m/garrow.gif +0 -0
- data/examples/blog/{root → public}/m/gbull.gif +0 -0
- data/examples/blog/{root → public}/m/grbull.gif +0 -0
- data/examples/blog/{root → public}/m/h1_bg.gif +0 -0
- data/examples/blog/{root → public}/m/header_bg.gif +0 -0
- data/examples/blog/{root → public}/m/nitro.gif +0 -0
- data/examples/blog/{root → public}/m/obull.gif +0 -0
- data/examples/blog/{root → public}/m/page_bg.gif +0 -0
- data/examples/blog/{root → public}/m/rss.gif +0 -0
- data/examples/blog/{root → public}/m/side_title_bg.gif +0 -0
- data/examples/blog/{root → public}/m/sidebar_bg.gif +0 -0
- data/examples/{no_xsl_blog/root → blog/public}/style.css +6 -0
- data/examples/blog/run.rb +10 -12
- data/examples/blog/{lib → src}/blog.rb +3 -3
- data/examples/blog/{lib/blog → src}/controller.rb +13 -2
- data/examples/blog/src/mailer.rb +23 -0
- data/examples/blog/{lib/blog/model.rb → src/models/blog.rb} +4 -7
- data/examples/blog/src/models/content.rb +52 -0
- data/examples/blog/src/views/blog_entry_email.xhtml +16 -0
- data/examples/blog/{root → src/views}/comments.xhtml +0 -0
- data/examples/blog/{root → src/views}/entry_form.xhtml +0 -0
- data/examples/blog/{root → src/views}/error.xhtml +0 -0
- data/examples/blog/{root → src/views}/index.xhtml +0 -0
- data/examples/blog/{root → src/views}/login.xhtml +0 -0
- data/examples/blog/{root → src/views}/recent_posts.xhtml +0 -0
- data/examples/blog/{root → src/views}/view_entry.xhtml +8 -0
- data/examples/blog/{root → src/views}/view_entry.xml +0 -0
- data/examples/blog/src/xsl/base.xsl +153 -0
- data/examples/blog/{root → src/xsl}/style.xsl +2 -2
- data/examples/no_xsl_blog/README +5 -1
- data/examples/no_xsl_blog/conf/apache.conf +2 -2
- data/examples/no_xsl_blog/conf/lhttpd.conf +2 -2
- data/examples/no_xsl_blog/lib/blog/model.rb +1 -1
- data/{lib/parts → examples/no_xsl_blog/lib}/content.rb +1 -11
- data/examples/no_xsl_blog/log/apache.error_log +405 -0
- data/examples/no_xsl_blog/{root → public}/comments.xhtml +0 -0
- data/examples/no_xsl_blog/{root → public}/entry_form.xhtml +0 -0
- data/examples/no_xsl_blog/{root → public}/fcgi.rb +0 -0
- data/examples/no_xsl_blog/{root → public}/index.xhtml +0 -0
- data/examples/no_xsl_blog/{root → public}/login.xhtml +0 -0
- data/examples/no_xsl_blog/{root → public}/m/bubbles.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/comments_curve.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/down.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/footer_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/garrow.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/gbull.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/grbull.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/h1_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/header_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/nitro.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/obull.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/page_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/rss.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/side_title_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/m/sidebar_bg.gif +0 -0
- data/examples/no_xsl_blog/{root → public}/recent_posts.xhtml +0 -0
- data/examples/{blog/root → no_xsl_blog/public}/style.css +0 -0
- data/examples/no_xsl_blog/{root → public}/view_entry.xhtml +0 -0
- data/examples/no_xsl_blog/{root → public}/view_entry.xml +0 -0
- data/examples/tiny/conf/apache.conf +2 -2
- data/examples/tiny/log/apache.error_log +100 -0
- data/examples/tiny/{root → public}/fcgi.rb +0 -0
- data/examples/tiny/{root → public}/include.xhtml +0 -0
- data/examples/tiny/{root → public}/index.xhtml +0 -0
- data/{bin/proto/root/m → examples/tiny/public}/nitro.png +0 -0
- data/examples/tiny/{root → public}/upload.xhtml +0 -0
- data/examples/tiny/run.rb +1 -2
- data/examples/why_wiki/wiki.yml +1 -0
- data/install.rb +5 -2
- data/lib/nitro.rb +2 -6
- data/lib/nitro/adapters/fastcgi.rb +2 -2
- data/lib/nitro/adapters/webrick.rb +4 -4
- data/lib/nitro/conf.rb +5 -2
- data/lib/nitro/controller.rb +2 -2
- data/lib/nitro/dispatcher.rb +19 -8
- data/lib/nitro/mail.rb +252 -8
- data/lib/nitro/render.rb +24 -21
- data/lib/nitro/runner.rb +1 -1
- data/lib/nitro/scaffold.rb +2 -5
- data/lib/nitro/simple.rb +2 -1
- data/lib/nitro/template.rb +42 -2
- data/test/nitro/tc_controller.rb +9 -4
- data/test/nitro/tc_dispatcher.rb +4 -6
- data/test/nitro/tc_mail.rb +95 -0
- data/test/{root → public}/blog/list.xhtml +0 -0
- data/test/public/dummy_mailer/registration.xhtml +5 -0
- data/vendor/README +0 -1
- metadata +136 -181
- data/benchmark/og/bench.rb +0 -75
- data/benchmark/og/sqlite-no-prepare.1.txt +0 -13
- data/benchmark/og/sqlite-no-prepare.2.txt +0 -13
- data/benchmark/og/sqlite-prepare.1.txt +0 -13
- data/benchmark/og/sqlite-prepare.2.txt +0 -13
- data/bin/proto/README +0 -34
- data/bin/proto/conf/apache.conf +0 -1
- data/bin/proto/conf/app.conf.rb +0 -14
- data/bin/proto/conf/lhttpd.conf +0 -236
- data/bin/proto/ctl +0 -4
- data/bin/proto/lib/README +0 -5
- data/bin/proto/log/README +0 -3
- data/bin/proto/root/fcgi.rb +0 -6
- data/bin/proto/root/index.xhtml +0 -69
- data/bin/proto/root/style.css +0 -152
- data/bin/proto/root/style.xsl +0 -99
- data/doc/og_config.txt +0 -35
- data/doc/og_tutorial.txt +0 -595
- data/examples/og/README +0 -11
- data/examples/og/mock_example.rb +0 -50
- data/examples/og/mysql_to_psql.rb +0 -96
- data/examples/og/run.rb +0 -286
- data/examples/tiny/root/nitro.png +0 -0
- data/lib/glue.rb +0 -55
- data/lib/glue/array.rb +0 -61
- data/lib/glue/attribute.rb +0 -83
- data/lib/glue/cache.rb +0 -138
- data/lib/glue/flexob.rb +0 -12
- data/lib/glue/hash.rb +0 -122
- data/lib/glue/inflector.rb +0 -91
- data/lib/glue/logger.rb +0 -147
- data/lib/glue/misc.rb +0 -14
- data/lib/glue/mixins.rb +0 -36
- data/lib/glue/number.rb +0 -24
- data/lib/glue/object.rb +0 -32
- data/lib/glue/pool.rb +0 -60
- data/lib/glue/property.rb +0 -408
- data/lib/glue/string.rb +0 -162
- data/lib/glue/time.rb +0 -85
- data/lib/glue/validation.rb +0 -394
- data/lib/og.rb +0 -185
- data/lib/og/adapter.rb +0 -513
- data/lib/og/adapters/filesys.rb +0 -121
- data/lib/og/adapters/mysql.rb +0 -347
- data/lib/og/adapters/oracle.rb +0 -375
- data/lib/og/adapters/psql.rb +0 -273
- data/lib/og/adapters/sqlite.rb +0 -262
- data/lib/og/backend.rb +0 -297
- data/lib/og/connection.rb +0 -304
- data/lib/og/database.rb +0 -282
- data/lib/og/enchant.rb +0 -125
- data/lib/og/meta.rb +0 -373
- data/lib/og/mock.rb +0 -165
- data/lib/og/observer.rb +0 -53
- data/lib/og/typemacros.rb +0 -23
- data/lib/parts/README +0 -9
- data/test/glue/tc_attribute.rb +0 -22
- data/test/glue/tc_cache.rb +0 -45
- data/test/glue/tc_hash.rb +0 -38
- data/test/glue/tc_logger.rb +0 -39
- data/test/glue/tc_numbers.rb +0 -20
- data/test/glue/tc_property.rb +0 -89
- data/test/glue/tc_property_mixins.rb +0 -93
- data/test/glue/tc_property_type_checking.rb +0 -35
- data/test/glue/tc_strings.rb +0 -103
- data/test/glue/tc_validation.rb +0 -188
- data/test/og/tc_filesys.rb +0 -83
- data/test/og/tc_lifecycle.rb +0 -104
- data/test/og/tc_many_to_many.rb +0 -62
- data/test/og/tc_meta.rb +0 -55
- data/test/og/tc_observer.rb +0 -85
- data/test/og/tc_sqlite.rb +0 -87
- data/test/tc_og.rb +0 -355
- data/vendor/composite_sexp_processor.rb +0 -43
- data/vendor/parse_tree.rb +0 -745
- data/vendor/sexp_processor.rb +0 -453
data/lib/og/mock.rb
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
|
2
|
-
# * Thomas Quas <tquas@yahoo.com>
|
|
3
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
|
4
|
-
# $Id$
|
|
5
|
-
|
|
6
|
-
require 'flexmock'
|
|
7
|
-
|
|
8
|
-
require 'og'
|
|
9
|
-
|
|
10
|
-
module Og
|
|
11
|
-
|
|
12
|
-
# A utility object to Mock a Database in test units.
|
|
13
|
-
# Extends the standard FlexMock object.
|
|
14
|
-
#--
|
|
15
|
-
# TODO: Factor out common functionality with Database
|
|
16
|
-
# to avoid code duplication.
|
|
17
|
-
|
|
18
|
-
class MockDatabase < ::FlexMock
|
|
19
|
-
include Og::Enchant
|
|
20
|
-
|
|
21
|
-
# Managed class metadata
|
|
22
|
-
#
|
|
23
|
-
class ManagedClassMeta
|
|
24
|
-
# The managed class.
|
|
25
|
-
attr_accessor :klass
|
|
26
|
-
|
|
27
|
-
# A mapping of the database fields to the object properties.
|
|
28
|
-
attr_accessor :field_index
|
|
29
|
-
|
|
30
|
-
def initialize(klass = nil)
|
|
31
|
-
@klass = klass
|
|
32
|
-
@field_index = {}
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# hash of configuration options.
|
|
37
|
-
|
|
38
|
-
attr_accessor :config
|
|
39
|
-
|
|
40
|
-
# Pool of connections to the backend.
|
|
41
|
-
|
|
42
|
-
attr_accessor :connection_pool
|
|
43
|
-
|
|
44
|
-
# Managed classes.
|
|
45
|
-
|
|
46
|
-
attr_accessor :managed_classes
|
|
47
|
-
|
|
48
|
-
# Initialize the database interface.
|
|
49
|
-
|
|
50
|
-
def initialize
|
|
51
|
-
# Initialize FlexMock
|
|
52
|
-
super
|
|
53
|
-
|
|
54
|
-
@managed_classes = N::SafeHash.new
|
|
55
|
-
|
|
56
|
-
Logger.info "Using mock database."
|
|
57
|
-
|
|
58
|
-
if Og.auto_manage_classes
|
|
59
|
-
# automatically manage classes with properties and metadata.
|
|
60
|
-
# gmosx: Any idea how to optimize this?
|
|
61
|
-
|
|
62
|
-
classes_to_manage = []
|
|
63
|
-
ObjectSpace.each_object(Class) do |c|
|
|
64
|
-
if c.respond_to?(:__props) and c.__props
|
|
65
|
-
classes_to_manage << c
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
Logger.info "Og auto manages the following classes:"
|
|
69
|
-
Logger.info "#{classes_to_manage.inspect}"
|
|
70
|
-
manage_classes(*classes_to_manage)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# use the newly created database.
|
|
74
|
-
|
|
75
|
-
Og.use(self)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Shutdown the database interface.
|
|
79
|
-
|
|
80
|
-
def shutdown
|
|
81
|
-
end
|
|
82
|
-
alias_method :close, :shutdown
|
|
83
|
-
|
|
84
|
-
# Get a connection from the pool to access the database.
|
|
85
|
-
# Stores the connection in a thread-local variable.
|
|
86
|
-
|
|
87
|
-
def get_connection
|
|
88
|
-
# nop
|
|
89
|
-
end
|
|
90
|
-
alias_method :connection, :get_connection
|
|
91
|
-
|
|
92
|
-
# Restore an unused connection to the pool.
|
|
93
|
-
|
|
94
|
-
def put_connection
|
|
95
|
-
# nop
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# Register a standard Ruby class as managed.
|
|
99
|
-
|
|
100
|
-
def manage(klass)
|
|
101
|
-
return if managed?(klass) or klass.ancestors.include?(Og::Unmanageable)
|
|
102
|
-
|
|
103
|
-
@managed_classes[klass] = ManagedClassMeta.new(klass)
|
|
104
|
-
|
|
105
|
-
# Add standard og methods to the class.
|
|
106
|
-
convert(klass)
|
|
107
|
-
|
|
108
|
-
# Add helper methods to the class.
|
|
109
|
-
enchant(klass) if Og.enchant_managed_classes
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
# Helper method to set multiple managed classes.
|
|
113
|
-
|
|
114
|
-
def manage_classes(*klasses)
|
|
115
|
-
for klass in klasses
|
|
116
|
-
manage(klass)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Stop managing a Ruby class
|
|
121
|
-
|
|
122
|
-
def unmanage(klass)
|
|
123
|
-
@managed_classes.delete(klass)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# Is this class managed?
|
|
127
|
-
|
|
128
|
-
def managed?(klass)
|
|
129
|
-
return @managed_classes.include?(klass)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Add standard og functionality to the class
|
|
133
|
-
|
|
134
|
-
def convert(klass)
|
|
135
|
-
klass.class_eval %{
|
|
136
|
-
DBTABLE = "#{Og::Backend.table(klass)}"
|
|
137
|
-
DBSEQ = "#{Og::Backend.table(klass)}_oids_seq"
|
|
138
|
-
|
|
139
|
-
def to_i()
|
|
140
|
-
@oid
|
|
141
|
-
end
|
|
142
|
-
}
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# Automatically wrap connection methods.
|
|
146
|
-
|
|
147
|
-
def self.wrap_method(method, args)
|
|
148
|
-
args = args.split(/,/)
|
|
149
|
-
class_eval %{
|
|
150
|
-
def #{method}(#{args.join(", ")})
|
|
151
|
-
# nop
|
|
152
|
-
end
|
|
153
|
-
}
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def self.create_db!(config)
|
|
157
|
-
# nop
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def self.drop_db!(config)
|
|
161
|
-
# nop
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
end
|
data/lib/og/observer.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: observer.rb 271 2005-03-07 17:56:45Z gmosx $
|
|
4
|
-
|
|
5
|
-
module Og
|
|
6
|
-
|
|
7
|
-
# Classes that include this module can be tracked by
|
|
8
|
-
# Observers. The observer mechanism utilizes duck typing
|
|
9
|
-
# so you can attach any class that responds to the
|
|
10
|
-
# Og lifycycle callback methods. However, classes extended
|
|
11
|
-
# from the Observer base class are typically used.
|
|
12
|
-
|
|
13
|
-
module Observable
|
|
14
|
-
def add_observer(*observer)
|
|
15
|
-
for o in observer.flatten
|
|
16
|
-
meta :og_observers, o
|
|
17
|
-
self.og_db.adapter.eval_lifecycle_methods(self, self.og_db)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Observers are attached to managed classes to track their
|
|
23
|
-
# Lifecycle. This way, the 'polution' of the original class
|
|
24
|
-
# with excess responsibility is avoided.
|
|
25
|
-
#
|
|
26
|
-
# An observer can implement the standard Og lifecycle
|
|
27
|
-
# callbacks:
|
|
28
|
-
#
|
|
29
|
-
# * og_pre_read
|
|
30
|
-
# * og_post_read
|
|
31
|
-
# * og_pre_insert
|
|
32
|
-
# * og_post_insert
|
|
33
|
-
# * og_pre_update
|
|
34
|
-
# * og_post_update
|
|
35
|
-
# * og_pre_insert_update
|
|
36
|
-
# * og_post_insert_update
|
|
37
|
-
# * self.og_pre_delete
|
|
38
|
-
#
|
|
39
|
-
# Based on code from ActiveRecord (http://www.rubyonrails.com)
|
|
40
|
-
|
|
41
|
-
class Observer
|
|
42
|
-
include Singleton
|
|
43
|
-
|
|
44
|
-
# Attaches the observer to the supplied classes.
|
|
45
|
-
|
|
46
|
-
def self.observe(*classes)
|
|
47
|
-
for c in classes.flatten
|
|
48
|
-
c.meta :og_observers, self
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
end
|
data/lib/og/typemacros.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# * George Moschovitis <gm@navel.gr>
|
|
2
|
-
# (c) 2004-2005 Navel, all rights reserved.
|
|
3
|
-
# $Id: typemacros.rb 267 2005-02-28 14:52:41Z gmosx $
|
|
4
|
-
|
|
5
|
-
module Og
|
|
6
|
-
|
|
7
|
-
# Some useful type macros to help when defining managed
|
|
8
|
-
# objects. You can easily code your own type macros.
|
|
9
|
-
# Just return the array that should be passed
|
|
10
|
-
#
|
|
11
|
-
# === Example
|
|
12
|
-
#
|
|
13
|
-
# property :name, Og.VarChar(30)
|
|
14
|
-
|
|
15
|
-
def VarChar(size)
|
|
16
|
-
return String, :sql => "VARCHAR(#{size})"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
NotNull = {:sql => "NOT NULL"}.freeze
|
|
20
|
-
|
|
21
|
-
Null = {:sql => "NULL"}.freeze
|
|
22
|
-
|
|
23
|
-
end
|
data/lib/parts/README
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
= Parts
|
|
2
|
-
|
|
3
|
-
Parts are 'modules of functionality'. This is a higher level concept.
|
|
4
|
-
Examples of parts could be a Forum, a Content/User management system,
|
|
5
|
-
etc.
|
|
6
|
-
|
|
7
|
-
Nitro is a low level framework and does not include functionality parts
|
|
8
|
-
in the standard distribution. Libraries of modules will be available from
|
|
9
|
-
Navel and other vendors.
|
data/test/glue/tc_attribute.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
require 'glue/attribute'
|
|
5
|
-
|
|
6
|
-
class TC_Attribute < Test::Unit::TestCase # :nodoc: all
|
|
7
|
-
|
|
8
|
-
class Dummy
|
|
9
|
-
cattr_accessor :value, 'Default'
|
|
10
|
-
cattr_reader :reader, 3
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_attr
|
|
14
|
-
assert_equal 'Default', Dummy.value
|
|
15
|
-
assert_nothing_raised { Dummy.value = 2 }
|
|
16
|
-
assert_equal 2, Dummy.value
|
|
17
|
-
|
|
18
|
-
assert_equal 3, Dummy.reader
|
|
19
|
-
assert_raise(NoMethodError) { Dummy.reader = 19 }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
data/test/glue/tc_cache.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require "test/unit"
|
|
2
|
-
require "glue/cache"
|
|
3
|
-
|
|
4
|
-
class TC_Glue_Cache < Test::Unit::TestCase
|
|
5
|
-
# :nodoc: all
|
|
6
|
-
|
|
7
|
-
class Dummy
|
|
8
|
-
include N::LRUCache::Item
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def setup
|
|
12
|
-
@cache = N::LRUCache.new(maxitems = 3)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def teardown
|
|
16
|
-
@cache = nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_safe_cache
|
|
20
|
-
d1 = Dummy.new
|
|
21
|
-
d2 = Dummy.new
|
|
22
|
-
d3 = Dummy.new
|
|
23
|
-
d4 = Dummy.new
|
|
24
|
-
|
|
25
|
-
@cache[1] = d1
|
|
26
|
-
@cache[2] = d2
|
|
27
|
-
@cache[3] = d3
|
|
28
|
-
|
|
29
|
-
assert_equal(d1, @cache.last)
|
|
30
|
-
assert_equal(d3, @cache.first)
|
|
31
|
-
|
|
32
|
-
val = @cache[2]
|
|
33
|
-
assert_equal(d2, @cache.first)
|
|
34
|
-
|
|
35
|
-
@cache[4] = d4
|
|
36
|
-
assert_equal(3, @cache.size)
|
|
37
|
-
assert_equal(d4, @cache.first)
|
|
38
|
-
|
|
39
|
-
# insert the same key
|
|
40
|
-
@cache[4] = d4
|
|
41
|
-
assert_equal(3, @cache.size)
|
|
42
|
-
assert_equal(d4, @cache.first)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
data/test/glue/tc_hash.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# :nodoc: all
|
|
2
|
-
|
|
3
|
-
require "test/unit"
|
|
4
|
-
require "glue/hash"
|
|
5
|
-
|
|
6
|
-
class TC_N2_Utils_Cache < Test::Unit::TestCase
|
|
7
|
-
# :nodoc: all
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
@safe_cache = N::SafeHash.new(Hash.new)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def teardown
|
|
14
|
-
@safe_cache = nil
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_safe_cache
|
|
18
|
-
assert_equal(nil, @safe_cache["no_item"])
|
|
19
|
-
item1 = "item1"
|
|
20
|
-
@safe_cache["key1"] = item1
|
|
21
|
-
assert_equal(item1, @safe_cache["key1"])
|
|
22
|
-
|
|
23
|
-
@safe_cache["rem1"] = item1
|
|
24
|
-
@safe_cache.delete("rem1")
|
|
25
|
-
assert_equal(nil, @safe_cache["rem1"])
|
|
26
|
-
|
|
27
|
-
@safe_cache.clear()
|
|
28
|
-
assert_equal(0, @safe_cache.size)
|
|
29
|
-
|
|
30
|
-
@safe_cache["i1"] = "i1"
|
|
31
|
-
@safe_cache["i2"] = "i1"
|
|
32
|
-
@safe_cache["i3"] = "i1"
|
|
33
|
-
assert_equal(3, @safe_cache.size)
|
|
34
|
-
|
|
35
|
-
assert_equal(3, @safe_cache.values.size)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
data/test/glue/tc_logger.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'vendor')
|
|
3
|
-
|
|
4
|
-
require 'stringio'
|
|
5
|
-
|
|
6
|
-
require 'test/unit'
|
|
7
|
-
require 'glue/logger'
|
|
8
|
-
|
|
9
|
-
class TC_Logger < Test::Unit::TestCase # :nodoc: all
|
|
10
|
-
|
|
11
|
-
def setup
|
|
12
|
-
@io = StringIO.new('')
|
|
13
|
-
Logger.set(Logger.new(@io))
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_logger
|
|
17
|
-
Logger.info 'hello'
|
|
18
|
-
assert_equal(" INFO: hello\n", @io.string)
|
|
19
|
-
|
|
20
|
-
# bug: Binding.of_caller thinks Logger is the caller.
|
|
21
|
-
a = 14
|
|
22
|
-
b = 13
|
|
23
|
-
Logger.trace 'a * b'
|
|
24
|
-
assert_equal(" INFO: hello\nDEBUG: a * b = 182\n", @io.string)
|
|
25
|
-
|
|
26
|
-
@io.string = ''
|
|
27
|
-
Logger.debug 'hello'
|
|
28
|
-
assert_equal("DEBUG: hello\n", @io.string)
|
|
29
|
-
|
|
30
|
-
# test logging level.
|
|
31
|
-
Logger.get.level = Logger::INFO
|
|
32
|
-
Logger.debug 'world'
|
|
33
|
-
assert_equal("DEBUG: hello\n", @io.string)
|
|
34
|
-
|
|
35
|
-
# bug:
|
|
36
|
-
Logger.error 'Have forgotten that :)'
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
data/test/glue/tc_numbers.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# :nodoc: all
|
|
2
|
-
|
|
3
|
-
require "test/unit"
|
|
4
|
-
require "glue/number"
|
|
5
|
-
|
|
6
|
-
class TC_N_NumberUtils < Test::Unit::TestCase
|
|
7
|
-
# :nodoc: all
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def teardown
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_ceil_multiple
|
|
16
|
-
assert_equal(20, N::NumberUtils.ceil_multiple(15, 10))
|
|
17
|
-
assert_equal(10, N::NumberUtils.ceil_multiple(1, 10))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
data/test/glue/tc_property.rb
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
4
|
-
|
|
5
|
-
require 'og'
|
|
6
|
-
require 'glue/logger'
|
|
7
|
-
require 'glue/property'
|
|
8
|
-
|
|
9
|
-
def VarChar(size)
|
|
10
|
-
return String, :sql => "VARCHAR(#{ size })"
|
|
11
|
-
end
|
|
12
|
-
NotNull = {:sql => "NOT NULL"}.freeze
|
|
13
|
-
Null = {:sql => "NULL"}.freeze
|
|
14
|
-
|
|
15
|
-
Property.type_checking = false
|
|
16
|
-
|
|
17
|
-
module Test # :nodoc: all
|
|
18
|
-
|
|
19
|
-
class Msg
|
|
20
|
-
include Og::Unmanageable
|
|
21
|
-
|
|
22
|
-
prop Fixnum, :owner_oid
|
|
23
|
-
prop_accessor :val1, :val2, :val3, Fixnum, :sql => "smallint"
|
|
24
|
-
prop_accessor :title, :body, String
|
|
25
|
-
prop_accessor :test, String, :sql => "char(10) NOT NULL"
|
|
26
|
-
prop_accessor :count, Fixnum
|
|
27
|
-
prop_accessor :create_time, Time
|
|
28
|
-
|
|
29
|
-
# a marshaled property
|
|
30
|
-
prop_accessor Array, :options
|
|
31
|
-
|
|
32
|
-
# property with macro arguments!
|
|
33
|
-
prop_accessor :address, VarChar(30), NotNull
|
|
34
|
-
|
|
35
|
-
def initialize
|
|
36
|
-
@create_time = Time.now
|
|
37
|
-
@options = []
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class SubMsg < Msg
|
|
43
|
-
# to avoid conflicts with tc_og.rb
|
|
44
|
-
include Og::Unmanageable
|
|
45
|
-
|
|
46
|
-
# duplicate definition with different type!
|
|
47
|
-
prop_accessor :count, Float
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class TC_N_Properties < Test::Unit::TestCase
|
|
51
|
-
|
|
52
|
-
def setup
|
|
53
|
-
@msg1 = Msg.new
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def teardown
|
|
57
|
-
@msg1 = nil
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_props
|
|
61
|
-
|
|
62
|
-
# bug: props for subclasses.
|
|
63
|
-
|
|
64
|
-
assert(SubMsg.__props)
|
|
65
|
-
assert_equal(Msg.__props.size(), SubMsg.__props.size())
|
|
66
|
-
|
|
67
|
-
# bug: duplicate definition
|
|
68
|
-
|
|
69
|
-
assert_equal(Float, SubMsg.__props.find { |p| :count == p.symbol }.klass)
|
|
70
|
-
|
|
71
|
-
# dont force conversion
|
|
72
|
-
|
|
73
|
-
@msg1.count = 2.4
|
|
74
|
-
assert_equal(Float, @msg1.count.class)
|
|
75
|
-
|
|
76
|
-
# force conversion
|
|
77
|
-
|
|
78
|
-
@msg1.__force_count(2.4)
|
|
79
|
-
assert_equal(Fixnum, @msg1.count.class)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def test_macro_params
|
|
83
|
-
sql = Msg.__props.find { |p| :address == p.symbol }.meta[:sql]
|
|
84
|
-
assert_equal 'VARCHAR(30) NOT NULL', sql
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end # module
|