glue 0.41.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.txt +130 -0
- data/Rakefile +16 -0
- data/lib/glue.rb +49 -72
- data/test/test_glue.rb +218 -0
- metadata +84 -100
- data/doc/AUTHORS +0 -13
- data/doc/CHANGELOG.1 +0 -354
- data/doc/LICENSE +0 -32
- data/doc/RELEASES +0 -207
- data/lib/glue/attribute.rb +0 -113
- data/lib/glue/attributeutils.rb +0 -117
- data/lib/glue/autoreload.rb +0 -60
- data/lib/glue/builder.rb +0 -57
- data/lib/glue/builder/xml.rb +0 -103
- data/lib/glue/cache.rb +0 -22
- data/lib/glue/cache/drb.rb +0 -51
- data/lib/glue/cache/file.rb +0 -78
- data/lib/glue/cache/memcached.rb +0 -68
- data/lib/glue/cache/memory.rb +0 -79
- data/lib/glue/cache/og.rb +0 -61
- data/lib/glue/configuration.rb +0 -305
- data/lib/glue/fixture.rb +0 -154
- data/lib/glue/html.rb +0 -12
- data/lib/glue/localization.rb +0 -129
- data/lib/glue/logger.rb +0 -208
- data/lib/glue/mail.rb +0 -160
- data/lib/glue/mailer.rb +0 -55
- data/lib/glue/mailer/incoming.rb +0 -41
- data/lib/glue/mailer/outgoing.rb +0 -119
- data/lib/glue/settings.rb +0 -3
- data/lib/glue/uri.rb +0 -190
- data/lib/glue/validation.rb +0 -447
- data/lib/html/document.rb +0 -63
- data/lib/html/node.rb +0 -480
- data/lib/html/tokenizer.rb +0 -103
- data/lib/html/version.rb +0 -11
- data/test/fixture/article.csv +0 -3
- data/test/fixture/article.yml +0 -13
- data/test/fixture/user.yml +0 -12
- data/test/glue/builder/tc_xml.rb +0 -57
- data/test/glue/tc_aspects.rb +0 -99
- data/test/glue/tc_attribute.rb +0 -112
- data/test/glue/tc_attribute_mixins.rb +0 -86
- data/test/glue/tc_builder.rb +0 -30
- data/test/glue/tc_configuration.rb +0 -135
- data/test/glue/tc_fixture.rb +0 -98
- data/test/glue/tc_localization.rb +0 -49
- data/test/glue/tc_logger.rb +0 -43
- data/test/glue/tc_mail.rb +0 -99
- data/test/glue/tc_stores.rb +0 -16
- data/test/glue/tc_uri.rb +0 -97
- data/test/glue/tc_validation.rb +0 -217
- data/test/public/dummy_mailer/registration.xhtml +0 -5
data/test/glue/tc_stores.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
require 'glue/cache/memory'
|
6
|
-
|
7
|
-
class TC_CachingStores < Test::Unit::TestCase # :nodoc: all
|
8
|
-
include Glue
|
9
|
-
|
10
|
-
def test_memory
|
11
|
-
s = MemoryCache.new
|
12
|
-
s.write('test', 'hello', { :none => 1})
|
13
|
-
s.read('test')
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/test/glue/tc_uri.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'glue/uri'
|
3
|
-
|
4
|
-
class Dummy # :nodoc: all
|
5
|
-
attr_accessor :test1, :test2
|
6
|
-
end
|
7
|
-
|
8
|
-
class TC_Uri < Test::Unit::TestCase # :nodoc: all
|
9
|
-
include Glue
|
10
|
-
|
11
|
-
def test_query_string_to_hash
|
12
|
-
# bad query string
|
13
|
-
|
14
|
-
assert_equal(0, Glue::UriUtils.query_string_to_hash("").length)
|
15
|
-
assert_equal(0, Glue::UriUtils.query_string_to_hash(nil).length)
|
16
|
-
|
17
|
-
# single valued
|
18
|
-
|
19
|
-
parameters = Glue::UriUtils.query_string_to_hash("koko=2&lala=3")
|
20
|
-
assert_equal("2", parameters["koko"])
|
21
|
-
assert_equal("3", parameters["lala"])
|
22
|
-
|
23
|
-
parameters = Glue::UriUtils.query_string_to_hash("koko=2;lala=3")
|
24
|
-
assert_equal("2", parameters["koko"])
|
25
|
-
assert_equal("3", parameters["lala"])
|
26
|
-
|
27
|
-
# multivalued
|
28
|
-
|
29
|
-
parameters = Glue::UriUtils.query_string_to_hash("koko=2;lala=3&koko=5")
|
30
|
-
assert_equal(2, parameters["koko"].length)
|
31
|
-
assert_equal("2", parameters["koko"][0])
|
32
|
-
assert_equal("3", parameters["lala"])
|
33
|
-
assert_equal("5", parameters["koko"][1])
|
34
|
-
|
35
|
-
# non existing value
|
36
|
-
assert_equal(nil, parameters["non-existing-value"])
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_hash_to_query_string
|
40
|
-
hash = { "koko" => 1, "lala" => 2}
|
41
|
-
qs = "koko=1;lala=2"
|
42
|
-
assert_equal(qs, Glue::UriUtils.hash_to_query_string(hash))
|
43
|
-
|
44
|
-
assert_equal(nil, Glue::UriUtils.hash_to_query_string(nil))
|
45
|
-
|
46
|
-
# bug: dont encode complex objects
|
47
|
-
hash = { "a" => 2, "b" => 3, "c" => Dummy.new }
|
48
|
-
qs = "a=2;b=3"
|
49
|
-
assert_equal(qs, Glue::UriUtils.hash_to_query_string(hash))
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_get_query_string
|
53
|
-
uri = "people/gmosx.sx?koko=1;lala=2"
|
54
|
-
assert_equal("koko=1;lala=2", Glue::UriUtils.get_query_string(uri))
|
55
|
-
|
56
|
-
uri = "http://www.nitroproject.org/people/gmosx.sx?koko=1&lala=2"
|
57
|
-
assert_equal("koko=1&lala=2", Glue::UriUtils.get_query_string(uri))
|
58
|
-
|
59
|
-
uri = "http://www.nitroproject.org:8080/people/gmosx.sx?koko=1;lala=2"
|
60
|
-
assert_equal("koko=1;lala=2", Glue::UriUtils.get_query_string(uri))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_chomp_query_string
|
64
|
-
uri = "people/gmosx.sx"
|
65
|
-
assert_equal("people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
66
|
-
|
67
|
-
uri = "people/gmosx.sx?koko=1;lala=2"
|
68
|
-
assert_equal("people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
69
|
-
|
70
|
-
uri = "http://www.nitroproject.org/people/gmosx.sx?koko=1&lala=2"
|
71
|
-
assert_equal("http://www.nitroproject.org/people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
72
|
-
|
73
|
-
uri = "http://www.nitroproject.org:8080/people/gmosx.sx?koko=1;lala=2"
|
74
|
-
assert_equal("http://www.nitroproject.org:8080/people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
75
|
-
|
76
|
-
assert_equal(nil, Glue::UriUtils.chomp_query_string(nil))
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_update_query_string
|
80
|
-
uri = "ko/index.sx?koko=1"
|
81
|
-
hash = {"lala" => 2, "kaka" => 3}
|
82
|
-
assert_equal("ko/index.sx?koko=1;lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
83
|
-
|
84
|
-
uri = "http://www.nitroproject.org:8080/ko/index.sx?koko=1"
|
85
|
-
hash = {"lala" => 2, "kaka" => 3}
|
86
|
-
assert_equal("http://www.nitroproject.org:8080/ko/index.sx?koko=1;lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
87
|
-
|
88
|
-
uri = "http://www.nitroproject.org"
|
89
|
-
hash = {"lala" => 2, "kaka" => 3}
|
90
|
-
assert_equal("http://www.nitroproject.org?lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
91
|
-
|
92
|
-
# bug: no ? when passed an empty hash
|
93
|
-
uri = "http://www.nitroproject.org"
|
94
|
-
assert_equal("http://www.nitroproject.org", Glue::UriUtils.update_query_string(uri, {}))
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
data/test/glue/tc_validation.rb
DELETED
@@ -1,217 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'og', 'lib')
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
require 'glue'
|
7
|
-
require 'glue/attribute'
|
8
|
-
require 'glue/validation'
|
9
|
-
|
10
|
-
# Glue::Property.type_checking = false
|
11
|
-
|
12
|
-
class TC_Validation < Test::Unit::TestCase # :nodoc: all
|
13
|
-
include Glue
|
14
|
-
|
15
|
-
# Override the default error message
|
16
|
-
Validation::Errors.invalid_format = 'INVALID'
|
17
|
-
|
18
|
-
module Mixin
|
19
|
-
attr_accessor :value, String
|
20
|
-
validate_format :value, :format => /123/, :msg => 'mixin error'
|
21
|
-
end
|
22
|
-
|
23
|
-
class User
|
24
|
-
include Mixin
|
25
|
-
|
26
|
-
attr_accessor :name, String
|
27
|
-
validate_format :name, :format => /L.o/, :msg => 'per class override'
|
28
|
-
end
|
29
|
-
|
30
|
-
class Article
|
31
|
-
attr_accessor :name, String
|
32
|
-
validate_format :name, :format => /news/
|
33
|
-
end
|
34
|
-
|
35
|
-
class Dummy1
|
36
|
-
attr_accessor :test, Fixnum
|
37
|
-
attr_accessor :str, String
|
38
|
-
validate_value :test, :str
|
39
|
-
end
|
40
|
-
|
41
|
-
class Dummy2
|
42
|
-
attr_accessor :password, String
|
43
|
-
validate_confirmation :password
|
44
|
-
end
|
45
|
-
|
46
|
-
class Dummy3
|
47
|
-
attr_accessor :vmin, String
|
48
|
-
validate_length :vmin, :min => 2
|
49
|
-
|
50
|
-
attr_accessor :vmax, String
|
51
|
-
validate_length :vmax, :max => 3, :msg => 'LOOONG'
|
52
|
-
|
53
|
-
attr_accessor :vran, String
|
54
|
-
validate_length :vran, :range => 2..4, :msg_long => 'argh'
|
55
|
-
|
56
|
-
attr_accessor :vlen, String
|
57
|
-
validate_length :vlen, :length => 3, :msg => 'argh'
|
58
|
-
end
|
59
|
-
|
60
|
-
class Dummy4
|
61
|
-
attr_accessor :sex, String
|
62
|
-
validate_inclusion :sex, :in => %w{ Male Female }, :msg => 'huh?'
|
63
|
-
|
64
|
-
attr_accessor :age, Fixnum
|
65
|
-
validate_inclusion :age, :in => 5..99
|
66
|
-
end
|
67
|
-
|
68
|
-
class Dummy5
|
69
|
-
property :age, Fixnum
|
70
|
-
validate_numeric :age, :integer => true
|
71
|
-
|
72
|
-
property :rate, Float
|
73
|
-
validate_numeric :rate
|
74
|
-
end
|
75
|
-
|
76
|
-
# bug
|
77
|
-
|
78
|
-
class NoProp
|
79
|
-
include Mixin
|
80
|
-
validate_length :value, :min => 3
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_validate_value
|
84
|
-
d = Dummy1.new
|
85
|
-
|
86
|
-
assert !d.valid?
|
87
|
-
assert_equal 2, d.errors.count
|
88
|
-
d.test = 1
|
89
|
-
assert !d.valid?
|
90
|
-
assert_equal 1, d.errors.count
|
91
|
-
d.str = 'yeah'
|
92
|
-
assert d.valid?
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_validate_confirmation
|
96
|
-
d = Dummy2.new
|
97
|
-
|
98
|
-
assert_respond_to d, :password_confirmation
|
99
|
-
|
100
|
-
d.password = 'hello'
|
101
|
-
assert !d.valid?
|
102
|
-
d.password_confirmation = 'hel'
|
103
|
-
assert !d.valid?
|
104
|
-
d.password_confirmation = 'hello'
|
105
|
-
assert d.valid?
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_validate_format
|
109
|
-
u = User.new
|
110
|
-
|
111
|
-
u.value = '1234'
|
112
|
-
|
113
|
-
u.name = 'George'
|
114
|
-
assert !u.valid?
|
115
|
-
|
116
|
-
assert_equal 'per class override', u.errors[:name].first
|
117
|
-
|
118
|
-
u.name = 'Leonard'
|
119
|
-
assert u.valid?
|
120
|
-
|
121
|
-
a = Article.new
|
122
|
-
|
123
|
-
a.name = 'In the news'
|
124
|
-
assert a.valid?
|
125
|
-
|
126
|
-
a.name = 'Sports'
|
127
|
-
assert !a.valid?
|
128
|
-
|
129
|
-
assert_equal 1, a.errors.count
|
130
|
-
assert_equal 1, a.errors.on(:name).size
|
131
|
-
assert_kind_of Array, a.errors[:name]
|
132
|
-
|
133
|
-
assert_equal 'INVALID', a.errors[:name].first
|
134
|
-
|
135
|
-
# test mixin
|
136
|
-
|
137
|
-
u.value = '543'
|
138
|
-
assert !u.valid?
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_validate_length
|
142
|
-
d = Dummy3.new
|
143
|
-
|
144
|
-
d.vmin = 'q'
|
145
|
-
d.vmax = '2'
|
146
|
-
d.vlen = '123'
|
147
|
-
d.vran = '123'
|
148
|
-
|
149
|
-
assert !d.valid?
|
150
|
-
assert_equal 'Too short, must be more than 2 characters long', d.errors.on(:vmin).first
|
151
|
-
d.vmin = 'longer'
|
152
|
-
assert d.valid?
|
153
|
-
|
154
|
-
d.vmax = 'loooooooooooong'
|
155
|
-
assert !d.valid?
|
156
|
-
assert_equal 'LOOONG', d.errors.on(:vmax).first
|
157
|
-
|
158
|
-
d.vmax = nil
|
159
|
-
assert !d.valid?
|
160
|
-
assert_equal 'No value provided', d.errors.on(:vmax).first
|
161
|
-
|
162
|
-
d.vlen = '12'
|
163
|
-
assert !d.valid?
|
164
|
-
assert_equal 'argh', d.errors.on(:vlen).first
|
165
|
-
|
166
|
-
d.vlen = '1234565'
|
167
|
-
assert !d.valid?
|
168
|
-
|
169
|
-
d.vran = '1'
|
170
|
-
assert !d.valid?
|
171
|
-
assert_equal 'Too short, must be more than 2 characters long', d.errors.on(:vran).first
|
172
|
-
|
173
|
-
d.vran = '11111111'
|
174
|
-
assert !d.valid?
|
175
|
-
assert_equal 'argh', d.errors.on(:vran).first
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_validate_inclusion
|
179
|
-
d = Dummy4.new
|
180
|
-
|
181
|
-
d.sex = 'Alien'
|
182
|
-
d.age = 1
|
183
|
-
|
184
|
-
assert !d.valid?
|
185
|
-
assert_equal 2, d.errors.count
|
186
|
-
|
187
|
-
d.sex = 'Male'
|
188
|
-
assert !d.valid?
|
189
|
-
assert_equal 1, d.errors.count
|
190
|
-
|
191
|
-
d.age = 110
|
192
|
-
assert !d.valid?
|
193
|
-
assert_equal 1, d.errors.count
|
194
|
-
|
195
|
-
d.age = 90
|
196
|
-
assert d.valid?
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_validate_numeric
|
200
|
-
d = Dummy5.new
|
201
|
-
|
202
|
-
d.rate = 'Alien'
|
203
|
-
d.age = 'World'
|
204
|
-
|
205
|
-
assert !d.valid?
|
206
|
-
assert_equal 2, d.errors.count
|
207
|
-
|
208
|
-
d.rate = 3
|
209
|
-
assert !d.valid?
|
210
|
-
assert_equal 1, d.errors.count
|
211
|
-
|
212
|
-
d.rate = 1.2
|
213
|
-
d.age = 123
|
214
|
-
assert d.valid?
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|