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.
Files changed (193) hide show
  1. data/{ChangeLog → CHANGELOG} +137 -0
  2. data/INSTALL +1 -2
  3. data/README +1 -1
  4. data/Rakefile +10 -61
  5. data/benchmark/{nitro/bench.rb → bench.rb} +1 -1
  6. data/benchmark/{nitro/simple-webrick-n-200.txt → simple-webrick-n-200.txt} +0 -0
  7. data/benchmark/{nitro/static-webrick-n-200.txt → static-webrick-n-200.txt} +0 -0
  8. data/benchmark/{nitro/tiny-lhttpd-n-200-c-5.txt → tiny-lhttpd-n-200-c-5.txt} +0 -0
  9. data/benchmark/{nitro/tiny-webrick-n-200-c-5.txt → tiny-webrick-n-200-c-5.txt} +0 -0
  10. data/benchmark/{nitro/tiny-webrick-n-200.txt → tiny-webrick-n-200.txt} +0 -0
  11. data/benchmark/{nitro/tiny2-webrick-n-200.txt → tiny2-webrick-n-200.txt} +0 -0
  12. data/doc/{ChangeLog.1 → CHANGELOG.1} +0 -0
  13. data/{RELEASES → doc/RELEASES} +46 -0
  14. data/doc/faq.txt +7 -0
  15. data/examples/README.windows +1 -1
  16. data/examples/ajax/controller.rb +21 -0
  17. data/examples/ajax/public/index.xhtml +70 -0
  18. data/examples/ajax/public/js/ajax.js +64 -0
  19. data/examples/ajax/run.rb +16 -0
  20. data/examples/blog/README +6 -3
  21. data/examples/blog/conf/apache.conf +2 -2
  22. data/examples/blog/conf/lhttpd.conf +2 -2
  23. data/examples/blog/log/apache.error_log +777 -0
  24. data/examples/blog/{root → public}/base.xsl +0 -0
  25. data/examples/blog/{root → public}/fcgi.rb +0 -0
  26. data/examples/blog/{root → public}/m/bubbles.gif +0 -0
  27. data/examples/blog/{root → public}/m/comments_curve.gif +0 -0
  28. data/examples/blog/{root → public}/m/down.gif +0 -0
  29. data/examples/blog/{root → public}/m/footer_bg.gif +0 -0
  30. data/examples/blog/{root → public}/m/garrow.gif +0 -0
  31. data/examples/blog/{root → public}/m/gbull.gif +0 -0
  32. data/examples/blog/{root → public}/m/grbull.gif +0 -0
  33. data/examples/blog/{root → public}/m/h1_bg.gif +0 -0
  34. data/examples/blog/{root → public}/m/header_bg.gif +0 -0
  35. data/examples/blog/{root → public}/m/nitro.gif +0 -0
  36. data/examples/blog/{root → public}/m/obull.gif +0 -0
  37. data/examples/blog/{root → public}/m/page_bg.gif +0 -0
  38. data/examples/blog/{root → public}/m/rss.gif +0 -0
  39. data/examples/blog/{root → public}/m/side_title_bg.gif +0 -0
  40. data/examples/blog/{root → public}/m/sidebar_bg.gif +0 -0
  41. data/examples/{no_xsl_blog/root → blog/public}/style.css +6 -0
  42. data/examples/blog/run.rb +10 -12
  43. data/examples/blog/{lib → src}/blog.rb +3 -3
  44. data/examples/blog/{lib/blog → src}/controller.rb +13 -2
  45. data/examples/blog/src/mailer.rb +23 -0
  46. data/examples/blog/{lib/blog/model.rb → src/models/blog.rb} +4 -7
  47. data/examples/blog/src/models/content.rb +52 -0
  48. data/examples/blog/src/views/blog_entry_email.xhtml +16 -0
  49. data/examples/blog/{root → src/views}/comments.xhtml +0 -0
  50. data/examples/blog/{root → src/views}/entry_form.xhtml +0 -0
  51. data/examples/blog/{root → src/views}/error.xhtml +0 -0
  52. data/examples/blog/{root → src/views}/index.xhtml +0 -0
  53. data/examples/blog/{root → src/views}/login.xhtml +0 -0
  54. data/examples/blog/{root → src/views}/recent_posts.xhtml +0 -0
  55. data/examples/blog/{root → src/views}/view_entry.xhtml +8 -0
  56. data/examples/blog/{root → src/views}/view_entry.xml +0 -0
  57. data/examples/blog/src/xsl/base.xsl +153 -0
  58. data/examples/blog/{root → src/xsl}/style.xsl +2 -2
  59. data/examples/no_xsl_blog/README +5 -1
  60. data/examples/no_xsl_blog/conf/apache.conf +2 -2
  61. data/examples/no_xsl_blog/conf/lhttpd.conf +2 -2
  62. data/examples/no_xsl_blog/lib/blog/model.rb +1 -1
  63. data/{lib/parts → examples/no_xsl_blog/lib}/content.rb +1 -11
  64. data/examples/no_xsl_blog/log/apache.error_log +405 -0
  65. data/examples/no_xsl_blog/{root → public}/comments.xhtml +0 -0
  66. data/examples/no_xsl_blog/{root → public}/entry_form.xhtml +0 -0
  67. data/examples/no_xsl_blog/{root → public}/fcgi.rb +0 -0
  68. data/examples/no_xsl_blog/{root → public}/index.xhtml +0 -0
  69. data/examples/no_xsl_blog/{root → public}/login.xhtml +0 -0
  70. data/examples/no_xsl_blog/{root → public}/m/bubbles.gif +0 -0
  71. data/examples/no_xsl_blog/{root → public}/m/comments_curve.gif +0 -0
  72. data/examples/no_xsl_blog/{root → public}/m/down.gif +0 -0
  73. data/examples/no_xsl_blog/{root → public}/m/footer_bg.gif +0 -0
  74. data/examples/no_xsl_blog/{root → public}/m/garrow.gif +0 -0
  75. data/examples/no_xsl_blog/{root → public}/m/gbull.gif +0 -0
  76. data/examples/no_xsl_blog/{root → public}/m/grbull.gif +0 -0
  77. data/examples/no_xsl_blog/{root → public}/m/h1_bg.gif +0 -0
  78. data/examples/no_xsl_blog/{root → public}/m/header_bg.gif +0 -0
  79. data/examples/no_xsl_blog/{root → public}/m/nitro.gif +0 -0
  80. data/examples/no_xsl_blog/{root → public}/m/obull.gif +0 -0
  81. data/examples/no_xsl_blog/{root → public}/m/page_bg.gif +0 -0
  82. data/examples/no_xsl_blog/{root → public}/m/rss.gif +0 -0
  83. data/examples/no_xsl_blog/{root → public}/m/side_title_bg.gif +0 -0
  84. data/examples/no_xsl_blog/{root → public}/m/sidebar_bg.gif +0 -0
  85. data/examples/no_xsl_blog/{root → public}/recent_posts.xhtml +0 -0
  86. data/examples/{blog/root → no_xsl_blog/public}/style.css +0 -0
  87. data/examples/no_xsl_blog/{root → public}/view_entry.xhtml +0 -0
  88. data/examples/no_xsl_blog/{root → public}/view_entry.xml +0 -0
  89. data/examples/tiny/conf/apache.conf +2 -2
  90. data/examples/tiny/log/apache.error_log +100 -0
  91. data/examples/tiny/{root → public}/fcgi.rb +0 -0
  92. data/examples/tiny/{root → public}/include.xhtml +0 -0
  93. data/examples/tiny/{root → public}/index.xhtml +0 -0
  94. data/{bin/proto/root/m → examples/tiny/public}/nitro.png +0 -0
  95. data/examples/tiny/{root → public}/upload.xhtml +0 -0
  96. data/examples/tiny/run.rb +1 -2
  97. data/examples/why_wiki/wiki.yml +1 -0
  98. data/install.rb +5 -2
  99. data/lib/nitro.rb +2 -6
  100. data/lib/nitro/adapters/fastcgi.rb +2 -2
  101. data/lib/nitro/adapters/webrick.rb +4 -4
  102. data/lib/nitro/conf.rb +5 -2
  103. data/lib/nitro/controller.rb +2 -2
  104. data/lib/nitro/dispatcher.rb +19 -8
  105. data/lib/nitro/mail.rb +252 -8
  106. data/lib/nitro/render.rb +24 -21
  107. data/lib/nitro/runner.rb +1 -1
  108. data/lib/nitro/scaffold.rb +2 -5
  109. data/lib/nitro/simple.rb +2 -1
  110. data/lib/nitro/template.rb +42 -2
  111. data/test/nitro/tc_controller.rb +9 -4
  112. data/test/nitro/tc_dispatcher.rb +4 -6
  113. data/test/nitro/tc_mail.rb +95 -0
  114. data/test/{root → public}/blog/list.xhtml +0 -0
  115. data/test/public/dummy_mailer/registration.xhtml +5 -0
  116. data/vendor/README +0 -1
  117. metadata +136 -181
  118. data/benchmark/og/bench.rb +0 -75
  119. data/benchmark/og/sqlite-no-prepare.1.txt +0 -13
  120. data/benchmark/og/sqlite-no-prepare.2.txt +0 -13
  121. data/benchmark/og/sqlite-prepare.1.txt +0 -13
  122. data/benchmark/og/sqlite-prepare.2.txt +0 -13
  123. data/bin/proto/README +0 -34
  124. data/bin/proto/conf/apache.conf +0 -1
  125. data/bin/proto/conf/app.conf.rb +0 -14
  126. data/bin/proto/conf/lhttpd.conf +0 -236
  127. data/bin/proto/ctl +0 -4
  128. data/bin/proto/lib/README +0 -5
  129. data/bin/proto/log/README +0 -3
  130. data/bin/proto/root/fcgi.rb +0 -6
  131. data/bin/proto/root/index.xhtml +0 -69
  132. data/bin/proto/root/style.css +0 -152
  133. data/bin/proto/root/style.xsl +0 -99
  134. data/doc/og_config.txt +0 -35
  135. data/doc/og_tutorial.txt +0 -595
  136. data/examples/og/README +0 -11
  137. data/examples/og/mock_example.rb +0 -50
  138. data/examples/og/mysql_to_psql.rb +0 -96
  139. data/examples/og/run.rb +0 -286
  140. data/examples/tiny/root/nitro.png +0 -0
  141. data/lib/glue.rb +0 -55
  142. data/lib/glue/array.rb +0 -61
  143. data/lib/glue/attribute.rb +0 -83
  144. data/lib/glue/cache.rb +0 -138
  145. data/lib/glue/flexob.rb +0 -12
  146. data/lib/glue/hash.rb +0 -122
  147. data/lib/glue/inflector.rb +0 -91
  148. data/lib/glue/logger.rb +0 -147
  149. data/lib/glue/misc.rb +0 -14
  150. data/lib/glue/mixins.rb +0 -36
  151. data/lib/glue/number.rb +0 -24
  152. data/lib/glue/object.rb +0 -32
  153. data/lib/glue/pool.rb +0 -60
  154. data/lib/glue/property.rb +0 -408
  155. data/lib/glue/string.rb +0 -162
  156. data/lib/glue/time.rb +0 -85
  157. data/lib/glue/validation.rb +0 -394
  158. data/lib/og.rb +0 -185
  159. data/lib/og/adapter.rb +0 -513
  160. data/lib/og/adapters/filesys.rb +0 -121
  161. data/lib/og/adapters/mysql.rb +0 -347
  162. data/lib/og/adapters/oracle.rb +0 -375
  163. data/lib/og/adapters/psql.rb +0 -273
  164. data/lib/og/adapters/sqlite.rb +0 -262
  165. data/lib/og/backend.rb +0 -297
  166. data/lib/og/connection.rb +0 -304
  167. data/lib/og/database.rb +0 -282
  168. data/lib/og/enchant.rb +0 -125
  169. data/lib/og/meta.rb +0 -373
  170. data/lib/og/mock.rb +0 -165
  171. data/lib/og/observer.rb +0 -53
  172. data/lib/og/typemacros.rb +0 -23
  173. data/lib/parts/README +0 -9
  174. data/test/glue/tc_attribute.rb +0 -22
  175. data/test/glue/tc_cache.rb +0 -45
  176. data/test/glue/tc_hash.rb +0 -38
  177. data/test/glue/tc_logger.rb +0 -39
  178. data/test/glue/tc_numbers.rb +0 -20
  179. data/test/glue/tc_property.rb +0 -89
  180. data/test/glue/tc_property_mixins.rb +0 -93
  181. data/test/glue/tc_property_type_checking.rb +0 -35
  182. data/test/glue/tc_strings.rb +0 -103
  183. data/test/glue/tc_validation.rb +0 -188
  184. data/test/og/tc_filesys.rb +0 -83
  185. data/test/og/tc_lifecycle.rb +0 -104
  186. data/test/og/tc_many_to_many.rb +0 -62
  187. data/test/og/tc_meta.rb +0 -55
  188. data/test/og/tc_observer.rb +0 -85
  189. data/test/og/tc_sqlite.rb +0 -87
  190. data/test/tc_og.rb +0 -355
  191. data/vendor/composite_sexp_processor.rb +0 -43
  192. data/vendor/parse_tree.rb +0 -745
  193. 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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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