glue 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +1 -1
- data/ProjectInfo +8 -1
- data/README +3 -3
- data/Rakefile +5 -1
- data/doc/RELEASES +7 -0
- data/lib/glue.rb +16 -2
- data/lib/glue/autoreload.rb +56 -0
- data/lib/glue/builder/xml.rb +1 -1
- data/lib/glue/configuration.rb +7 -3
- data/lib/glue/flexob.rb +5 -0
- data/lib/glue/mailer/outgoing.rb +1 -1
- data/lib/glue/property.rb +53 -32
- data/lib/glue/template.rb +9 -1
- data/setup.rb +1585 -0
- data/test/glue/tc_configuration.rb +2 -1
- metadata +108 -105
- data/install.rb +0 -37
- data/test/glue/tc_multi_validations.rb +0 -19
- data/test/glue/tc_validation2.rb +0 -208
- data/test/glue/tc_validation_loop.rb +0 -36
@@ -14,13 +14,14 @@ class Another
|
|
14
14
|
setting :max_age, :default => 4, :doc => 'Maximum allowed age'
|
15
15
|
end
|
16
16
|
|
17
|
-
class Configuration
|
17
|
+
class Glue::Configuration
|
18
18
|
def self.clear_all_settings
|
19
19
|
@@owners = Hash.new
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class TC_Configuration < Test::Unit::TestCase # :nodoc: all
|
24
|
+
include Glue
|
24
25
|
|
25
26
|
class Internal
|
26
27
|
setting :radius, :default => 4
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: glue
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.27.0
|
7
|
+
date: 2006-01-16 00:00:00 +02:00
|
8
8
|
summary: Utility methods and classes for Nitro.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: gm@navel.gr
|
12
12
|
homepage: http://www.nitrohq.com
|
13
13
|
rubyforge_project: nitro
|
@@ -15,117 +15,120 @@ description:
|
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
|
-
has_rdoc:
|
18
|
+
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
27
28
|
authors:
|
28
|
-
|
29
|
+
- George Moschovitis
|
29
30
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
- test/public/dummy_mailer
|
104
|
-
- test/public/dummy_mailer/registration.xhtml
|
31
|
+
- doc
|
32
|
+
- lib
|
33
|
+
- test
|
34
|
+
- ProjectInfo
|
35
|
+
- Rakefile
|
36
|
+
- README
|
37
|
+
- setup.rb
|
38
|
+
- INSTALL
|
39
|
+
- doc/CHANGELOG.1
|
40
|
+
- doc/RELEASES
|
41
|
+
- doc/LICENSE
|
42
|
+
- doc/AUTHORS
|
43
|
+
- lib/glue
|
44
|
+
- lib/html
|
45
|
+
- lib/glue.rb
|
46
|
+
- lib/glue/builder
|
47
|
+
- lib/glue/mailer
|
48
|
+
- lib/glue/localization.rb
|
49
|
+
- lib/glue/validation.rb
|
50
|
+
- lib/glue/uri.rb
|
51
|
+
- lib/glue/template.rb
|
52
|
+
- lib/glue/settings.rb
|
53
|
+
- lib/glue/sanitize.rb
|
54
|
+
- lib/glue/property.rb
|
55
|
+
- lib/glue/on_included.rb
|
56
|
+
- lib/glue/html.rb
|
57
|
+
- lib/glue/mailer.rb
|
58
|
+
- lib/glue/mail.rb
|
59
|
+
- lib/glue/logger.rb
|
60
|
+
- lib/glue/attribute.rb
|
61
|
+
- lib/glue/flexob.rb
|
62
|
+
- lib/glue/fixture.rb
|
63
|
+
- lib/glue/builder.rb
|
64
|
+
- lib/glue/configuration.rb
|
65
|
+
- lib/glue/expirable.rb
|
66
|
+
- lib/glue/aspects.rb
|
67
|
+
- lib/glue/markup.rb
|
68
|
+
- lib/glue/accumulate.rb
|
69
|
+
- lib/glue/autoreload.rb
|
70
|
+
- lib/glue/builder/xml.rb
|
71
|
+
- lib/glue/mailer/outgoing.rb
|
72
|
+
- lib/glue/mailer/incoming.rb
|
73
|
+
- lib/html/tokenizer.rb
|
74
|
+
- lib/html/version.rb
|
75
|
+
- lib/html/document.rb
|
76
|
+
- lib/html/node.rb
|
77
|
+
- test/fixture
|
78
|
+
- test/glue
|
79
|
+
- test/public
|
80
|
+
- test/fixture/article.yml
|
81
|
+
- test/fixture/user.yml
|
82
|
+
- test/fixture/article.csv
|
83
|
+
- test/glue/builder
|
84
|
+
- test/glue/tc_configuration.rb
|
85
|
+
- test/glue/tc_validation.rb
|
86
|
+
- test/glue/tc_uri.rb
|
87
|
+
- test/glue/tc_template.rb
|
88
|
+
- test/glue/tc_property.rb
|
89
|
+
- test/glue/tc_property_type_checking.rb
|
90
|
+
- test/glue/tc_property_mixins.rb
|
91
|
+
- test/glue/tc_mail.rb
|
92
|
+
- test/glue/tc_logger.rb
|
93
|
+
- test/glue/tc_localization.rb
|
94
|
+
- test/glue/tc_flexob.rb
|
95
|
+
- test/glue/tc_fixture.rb
|
96
|
+
- test/glue/tc_attribute.rb
|
97
|
+
- test/glue/tc_builder.rb
|
98
|
+
- test/glue/tc_accumulate.rb
|
99
|
+
- test/glue/tc_aspects.rb
|
100
|
+
- test/glue/multi_validations_model.rb
|
101
|
+
- test/glue/builder/tc_xml.rb
|
102
|
+
- test/public/dummy_mailer
|
103
|
+
- test/public/dummy_mailer/registration.xhtml
|
105
104
|
test_files: []
|
105
|
+
|
106
106
|
rdoc_options: []
|
107
|
+
|
107
108
|
extra_rdoc_files: []
|
109
|
+
|
108
110
|
executables: []
|
111
|
+
|
109
112
|
extensions: []
|
113
|
+
|
110
114
|
requirements: []
|
115
|
+
|
111
116
|
dependencies:
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
version: 2.0.0
|
131
|
-
version:
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: facets
|
119
|
+
version_requirement:
|
120
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2005.10.30
|
125
|
+
version:
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: cmdparse
|
128
|
+
version_requirement:
|
129
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 2.0.0
|
134
|
+
version:
|
data/install.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'ftools'
|
5
|
-
|
6
|
-
dst_dir = Config::CONFIG['sitelibdir']
|
7
|
-
|
8
|
-
Dir.chdir('lib') do
|
9
|
-
Dir['**/*.rb'].each do |file|
|
10
|
-
File.mkpath File.join(dst_dir, File.dirname(file)), true
|
11
|
-
File.install file, File.join(dst_dir, file), 0644, true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
puts %{
|
16
|
-
|
17
|
-
|
18
|
-
---
|
19
|
-
Congratulations, you have successfully installed Og!
|
20
|
-
The libraries where installed in '#{dst_dir}'.
|
21
|
-
|
22
|
-
You probably need to install the Glue library
|
23
|
-
as well. (http://nitro.rubyforge.org)
|
24
|
-
|
25
|
-
To verify that everything works correctly, try to run an
|
26
|
-
example by issuing:
|
27
|
-
|
28
|
-
$ cd examples
|
29
|
-
$ ruby run.rb
|
30
|
-
|
31
|
-
at the command line.
|
32
|
-
|
33
|
-
Enjoy the magic of Og!
|
34
|
-
}
|
35
|
-
|
36
|
-
# * George Moschovitis <gm@navel.gr>
|
37
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
require 'glue'
|
6
|
-
require 'glue/property'
|
7
|
-
require 'glue/validation'
|
8
|
-
|
9
|
-
class TC_MultiValidation < Test::Unit::TestCase # :nodoc: all
|
10
|
-
|
11
|
-
def test_all
|
12
|
-
file = File.join(File.dirname($0), 'multi_validations_model.rb')
|
13
|
-
load file
|
14
|
-
assert_equal 2, User.validations.size
|
15
|
-
load file
|
16
|
-
assert_equal 2, User.validations.size
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
data/test/glue/tc_validation2.rb
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
path = File.expand_path(File.dirname($0))
|
2
|
-
$: << path + '/og/lib'
|
3
|
-
$: << path + '/glue/lib'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'og'
|
6
|
-
|
7
|
-
module UnitTestClasses
|
8
|
-
class NoValidation
|
9
|
-
property :prop, String
|
10
|
-
|
11
|
-
def initialize(prop)
|
12
|
-
@prop = prop
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class UniqueValidation < NoValidation
|
17
|
-
property :slop, String
|
18
|
-
validate_unique :prop, :slop
|
19
|
-
end
|
20
|
-
|
21
|
-
class ValueValidation < NoValidation
|
22
|
-
validate_value :prop
|
23
|
-
end
|
24
|
-
|
25
|
-
class ConfirmValidation < NoValidation
|
26
|
-
validate_confirmation :prop
|
27
|
-
end
|
28
|
-
|
29
|
-
class FormatValidation < NoValidation
|
30
|
-
validate_format :prop, :format => /^\w\d\w-\d\w\d$/
|
31
|
-
end
|
32
|
-
|
33
|
-
class MinValidation < NoValidation
|
34
|
-
validate_length :prop, :min => 4
|
35
|
-
end
|
36
|
-
|
37
|
-
class MaxValidation < NoValidation
|
38
|
-
validate_length :prop, :max => 8
|
39
|
-
end
|
40
|
-
|
41
|
-
class RangeValidation < NoValidation
|
42
|
-
validate_length :prop, :range => 10..20
|
43
|
-
end
|
44
|
-
|
45
|
-
class LengthValidation < NoValidation
|
46
|
-
validate_length :prop, :length => 8
|
47
|
-
end
|
48
|
-
|
49
|
-
class InclusionValidation < NoValidation
|
50
|
-
validate_inclusion :prop, :in => %w{ Male Female }
|
51
|
-
end
|
52
|
-
|
53
|
-
class NumericValidation < NoValidation
|
54
|
-
property :prop, Fixnum
|
55
|
-
validate_numeric :prop, :integer => true
|
56
|
-
|
57
|
-
prop_accessor :prop2, Float
|
58
|
-
validate_numeric :prop2
|
59
|
-
end
|
60
|
-
|
61
|
-
class RelatedClass
|
62
|
-
prop_accessor :test, String
|
63
|
-
belongs_to :relation_validation, RelationValidation
|
64
|
-
end
|
65
|
-
|
66
|
-
class RelationValidation < NoValidation
|
67
|
-
has_many :relations, RelatedClass
|
68
|
-
validate_related :relations
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
config = {
|
73
|
-
:destroy => true,
|
74
|
-
:store => :sqlite,
|
75
|
-
:prop => 'dbtest_additions'
|
76
|
-
}
|
77
|
-
|
78
|
-
db = Og.setup(config)
|
79
|
-
|
80
|
-
require 'breakpoint'
|
81
|
-
module Test::Unit::Assertions
|
82
|
-
# Assert than an Og object is successfully saved and is error free.
|
83
|
-
def assert_saved_without_errors(obj)
|
84
|
-
assert_block(obj.class.to_s + ' was expected to save, but failed.') do
|
85
|
-
obj.save
|
86
|
-
obj.saved? && obj.errors.size == 0
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Assert that an Og object did not save and has errors.
|
91
|
-
def assert_save_failed(obj)
|
92
|
-
assert_block(obj.class.to_s + ' saving was expected to fail, but it succeeded.') do
|
93
|
-
obj.save
|
94
|
-
!obj.saved? && obj.errors.size > 0
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Unit tests for the Og validation system
|
100
|
-
class TestFixes < Test::Unit::TestCase
|
101
|
-
include UnitTestClasses
|
102
|
-
|
103
|
-
def test_no_validation
|
104
|
-
t = NoValidation.new('nochecking')
|
105
|
-
assert_saved_without_errors t
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_validation_unique
|
109
|
-
assert_saved_without_errors UniqueValidation.new('test')
|
110
|
-
assert_save_failed UniqueValidation.new('test')
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_value_validation
|
114
|
-
assert_saved_without_errors ValueValidation.new('value')
|
115
|
-
assert_save_failed ValueValidation.new(nil)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_confirmation
|
119
|
-
prop = 'confirm'
|
120
|
-
c = ConfirmValidation.new(prop)
|
121
|
-
c.prop_confirmation = prop
|
122
|
-
assert_saved_without_errors c
|
123
|
-
|
124
|
-
assert_save_failed ConfirmValidation.new(prop)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_format
|
128
|
-
assert_saved_without_errors FormatValidation.new('a1b-2c3')
|
129
|
-
assert_save_failed FormatValidation.new('banana_pudding')
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_length_min
|
133
|
-
assert_saved_without_errors MinValidation.new('12345')
|
134
|
-
assert_save_failed MinValidation.new('1')
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_length_max
|
138
|
-
assert_saved_without_errors MaxValidation.new('12345')
|
139
|
-
assert_save_failed MaxValidation.new('123456789012345')
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_length_range
|
143
|
-
l = RangeValidation.new('12345678901234')
|
144
|
-
assert_saved_without_errors l
|
145
|
-
|
146
|
-
l = RangeValidation.new('12')
|
147
|
-
assert_save_failed l
|
148
|
-
|
149
|
-
l = RangeValidation.new('1234567890123456789012345')
|
150
|
-
assert_save_failed l
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_length_length
|
154
|
-
assert_saved_without_errors LengthValidation.new('12345678')
|
155
|
-
assert_save_failed LengthValidation.new('1')
|
156
|
-
assert_save_failed LengthValidation.new('123456789012345')
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_inclusion
|
160
|
-
assert_saved_without_errors InclusionValidation.new('Male')
|
161
|
-
assert_save_failed InclusionValidation.new('Shemale')
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_numeric
|
165
|
-
# Both valid
|
166
|
-
n = NumericValidation.new(100)
|
167
|
-
n.prop2 = 1.52
|
168
|
-
assert_saved_without_errors n
|
169
|
-
|
170
|
-
# float for required integer
|
171
|
-
n = NumericValidation.new(1.52)
|
172
|
-
n.prop2 = 1.52
|
173
|
-
assert_save_failed n
|
174
|
-
assert_equal 1, n.errors.count
|
175
|
-
|
176
|
-
# string for required integer
|
177
|
-
n = NumericValidation.new('sausage')
|
178
|
-
n.prop2 = 1.52
|
179
|
-
assert_save_failed n
|
180
|
-
assert_equal 1, n.errors.count
|
181
|
-
|
182
|
-
# string for required integer and float
|
183
|
-
n = NumericValidation.new('sausage')
|
184
|
-
n.prop2 = 'cheese'
|
185
|
-
assert_save_failed n
|
186
|
-
assert_equal 2, n.errors.count
|
187
|
-
|
188
|
-
# string for float
|
189
|
-
n = NumericValidation.new(15)
|
190
|
-
n.prop2 = 'cheese'
|
191
|
-
assert_save_failed n
|
192
|
-
assert_equal 1, n.errors.count
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_related
|
196
|
-
r = RelatedClass.new
|
197
|
-
test_prop = 'example string'
|
198
|
-
r.test = test_prop
|
199
|
-
rv = RelationValidation.new('relation')
|
200
|
-
rv.relations << r
|
201
|
-
|
202
|
-
assert_saved_without_errors rv
|
203
|
-
assert_equal test_prop, rv.relations.members[0].test
|
204
|
-
|
205
|
-
# Test bad
|
206
|
-
assert_save_failed RelationValidation.new('relation')
|
207
|
-
end
|
208
|
-
end
|