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_builder.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'glue/builder'
|
5
|
-
|
6
|
-
class TC_Builder < Test::Unit::TestCase # :nodoc: all
|
7
|
-
include Glue
|
8
|
-
|
9
|
-
module TestMixin
|
10
|
-
def hello
|
11
|
-
'hello'
|
12
|
-
end
|
13
|
-
def world
|
14
|
-
'world'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class TestBuilder < Builder
|
19
|
-
include_builder TestMixin
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_all
|
23
|
-
t = TestBuilder.new(doc = '')
|
24
|
-
t.hello
|
25
|
-
t.world
|
26
|
-
assert_equal 'helloworld', doc
|
27
|
-
t.hello
|
28
|
-
assert_equal 'helloworldhello', doc
|
29
|
-
end
|
30
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'glue/configuration'
|
5
|
-
|
6
|
-
# Hack: To make compatible with rake test.
|
7
|
-
|
8
|
-
class Dummy
|
9
|
-
setting :root_dir, :default => '/home/gmosx', :doc => 'The root directory for the app'
|
10
|
-
setting :conn_count, :default => 5, :type => Fixnum
|
11
|
-
end
|
12
|
-
|
13
|
-
class Another
|
14
|
-
setting :max_age, :default => 4, :doc => 'Maximum allowed age'
|
15
|
-
end
|
16
|
-
|
17
|
-
class Glue::Configuration
|
18
|
-
def self.clear_all_settings
|
19
|
-
@@owners = Hash.new
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class TC_Configuration < Test::Unit::TestCase # :nodoc: all
|
24
|
-
include Glue
|
25
|
-
|
26
|
-
class Internal
|
27
|
-
setting :radius, :default => 4
|
28
|
-
end
|
29
|
-
|
30
|
-
def setup
|
31
|
-
# gmosx: A hack to make compatible with rake. All code in this
|
32
|
-
# method is not needed if you only run this test (or in your
|
33
|
-
# real aplications of course).
|
34
|
-
|
35
|
-
# Running the next line breaks later tests when running the test suite.
|
36
|
-
|
37
|
-
# Configuration.clear_all_settings
|
38
|
-
|
39
|
-
Dummy.class_eval do
|
40
|
-
setting :root_dir, :default => '/home/gmosx', :doc => 'The root directory for the app'
|
41
|
-
setting :conn_count, :default => 5, :type => Fixnum
|
42
|
-
end
|
43
|
-
|
44
|
-
Another.class_eval do
|
45
|
-
setting :max_age, :default => 4, :doc => 'Maximum allowed age'
|
46
|
-
end
|
47
|
-
|
48
|
-
Internal.class_eval do
|
49
|
-
setting :radius, :default => 4
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_all
|
54
|
-
# The following asserts are _not_ true when running the test suite.
|
55
|
-
# assert_equal 4, Configuration.settings.size
|
56
|
-
# assert_equal 4, Configuration.all.size
|
57
|
-
|
58
|
-
assert_equal 2, Configuration.settings(Dummy).size
|
59
|
-
assert_equal 1, Configuration.settings(Another).size
|
60
|
-
|
61
|
-
assert_equal Fixnum, Configuration.settings(Dummy)[:conn_count].type
|
62
|
-
assert_equal String, Configuration[Dummy][:root_dir].type
|
63
|
-
|
64
|
-
assert_equal '/home/gmosx', Dummy.root_dir
|
65
|
-
assert_equal 4, Another.max_age
|
66
|
-
|
67
|
-
Dummy.root_dir = '/changed/dir'
|
68
|
-
assert_equal '/changed/dir', Dummy.root_dir
|
69
|
-
assert_equal '/changed/dir', Configuration[Dummy][:root_dir].value
|
70
|
-
|
71
|
-
Another.max_age = 99
|
72
|
-
assert_equal 99, Configuration[Another][:max_age].value
|
73
|
-
|
74
|
-
# test reverse setting.
|
75
|
-
|
76
|
-
Configuration[Another][:max_age].value = 69
|
77
|
-
assert_equal 69, Configuration[Another][:max_age].value
|
78
|
-
assert_equal 69, Another.max_age
|
79
|
-
|
80
|
-
# setup
|
81
|
-
|
82
|
-
Configuration.setup(
|
83
|
-
Dummy => {
|
84
|
-
:root_dir => '/gmosx/2',
|
85
|
-
:conn_count => 12
|
86
|
-
},
|
87
|
-
Another => {
|
88
|
-
:max_age => 2
|
89
|
-
},
|
90
|
-
TC_Configuration::Internal => {
|
91
|
-
:radius => 99
|
92
|
-
}
|
93
|
-
)
|
94
|
-
|
95
|
-
assert_equal '/gmosx/2', Dummy.root_dir
|
96
|
-
assert_equal '/gmosx/2', Configuration[Dummy][:root_dir].value
|
97
|
-
assert_equal 2, Another.max_age
|
98
|
-
|
99
|
-
Configuration.parse_yaml <<-end_val
|
100
|
-
Another:
|
101
|
-
max_age: 5
|
102
|
-
TC_Configuration.Internal:
|
103
|
-
radius: 99
|
104
|
-
Dummy:
|
105
|
-
root_dir: /gmosx/99
|
106
|
-
conn_count: 33
|
107
|
-
end_val
|
108
|
-
|
109
|
-
assert_equal '/gmosx/99', Dummy.root_dir
|
110
|
-
assert_equal '/gmosx/99', Configuration[Dummy][:root_dir].value
|
111
|
-
assert_equal 5, Another.max_age
|
112
|
-
|
113
|
-
# cooler ;-)
|
114
|
-
|
115
|
-
assert_equal String, Configuration.Dummy[:root_dir].type
|
116
|
-
assert_equal String, Configuration.Dummy.root_dir.type
|
117
|
-
|
118
|
-
# alias
|
119
|
-
|
120
|
-
assert_equal String, Settings.Dummy.root_dir.type
|
121
|
-
assert_equal 5, Settings.Another.max_age.value
|
122
|
-
|
123
|
-
# Handle namespace
|
124
|
-
|
125
|
-
assert_equal 99, Internal.radius
|
126
|
-
assert_equal 99, TC_Configuration::Internal.radius
|
127
|
-
|
128
|
-
# Intuitive setting
|
129
|
-
|
130
|
-
Configuration.Dummy.root_dir = 'wow'
|
131
|
-
assert_equal 'wow', Dummy.root_dir
|
132
|
-
assert_equal 'wow', Configuration.Dummy.root_dir.value
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
data/test/glue/tc_fixture.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'nitro', 'lib')
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'glue/fixture'
|
6
|
-
|
7
|
-
RootDir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixture'))
|
8
|
-
|
9
|
-
class TestFixtureExplicitRootDir < Test::Unit::TestCase # :nodoc: all
|
10
|
-
include Glue
|
11
|
-
|
12
|
-
class User
|
13
|
-
attr_accessor :name
|
14
|
-
attr_accessor :age
|
15
|
-
end
|
16
|
-
|
17
|
-
class Article
|
18
|
-
attr_accessor :title
|
19
|
-
attr_accessor :body
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_all
|
23
|
-
users = Fixture.new(User, :root_dir => RootDir)
|
24
|
-
|
25
|
-
assert_equal 3, users.size
|
26
|
-
george = users['george']
|
27
|
-
assert_equal 30, george.age
|
28
|
-
assert_equal 'Renos', users['renos'].name
|
29
|
-
|
30
|
-
articles = Fixture.new(Article, :root_dir => RootDir)
|
31
|
-
|
32
|
-
assert_equal 10, articles.size
|
33
|
-
assert_equal 'This is cool', articles['article_1'].title
|
34
|
-
assert_equal 'Another', articles['article_2'].title
|
35
|
-
assert_equal 'I love this', articles['Test'].title
|
36
|
-
|
37
|
-
assert_equal 'title 3', articles['Auto3'].title
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_global
|
41
|
-
"This is not supported with explicit root directory setting"
|
42
|
-
=begin
|
43
|
-
assert_raises(RuntimeError, "This test will fail when running via rake") do
|
44
|
-
Fixtures.load User, Article
|
45
|
-
end # Fixtures.load _only_ uses Fixtures.root_dir setting.
|
46
|
-
=end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
class TestFixtureRootDirSetting < Test::Unit::TestCase # :nodoc: all
|
52
|
-
include Glue
|
53
|
-
|
54
|
-
class User
|
55
|
-
attr_accessor :name
|
56
|
-
attr_accessor :age
|
57
|
-
end
|
58
|
-
|
59
|
-
class Article
|
60
|
-
attr_accessor :title
|
61
|
-
attr_accessor :body
|
62
|
-
end
|
63
|
-
|
64
|
-
def setup
|
65
|
-
@old_rootdir = Fixtures.root_dir
|
66
|
-
Fixtures.root_dir = RootDir
|
67
|
-
end
|
68
|
-
|
69
|
-
def teardown
|
70
|
-
Fixtures.root_dir = @old_rootdir
|
71
|
-
@old_rootdir = nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_all
|
75
|
-
users = Fixture.new(User)
|
76
|
-
|
77
|
-
assert_equal 3, users.size
|
78
|
-
george = users['george']
|
79
|
-
assert_equal 30, george.age
|
80
|
-
assert_equal 'Renos', users['renos'].name
|
81
|
-
|
82
|
-
articles = Fixture.new(Article)
|
83
|
-
|
84
|
-
assert_equal 10, articles.size
|
85
|
-
assert_equal 'This is cool', articles['article_1'].title
|
86
|
-
assert_equal 'Another', articles['article_2'].title
|
87
|
-
assert_equal 'I love this', articles['Test'].title
|
88
|
-
|
89
|
-
assert_equal 'title 3', articles['Auto3'].title
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_global
|
93
|
-
Fixtures.load User, Article
|
94
|
-
assert_equal 3, Fixtures.user.size
|
95
|
-
assert_equal 'This is cool', Fixtures.article['article_1'].title
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
require 'glue/localization'
|
7
|
-
|
8
|
-
class TestCaseLocalization < Test::Unit::TestCase # :nodoc: all
|
9
|
-
include Glue
|
10
|
-
|
11
|
-
def setup
|
12
|
-
locale_en = {
|
13
|
-
'See you' => 'See you',
|
14
|
-
:long_paragraph => 'The best new books, up to 30% reduced price',
|
15
|
-
:price => 'Price: %d %s',
|
16
|
-
:proc_price => proc { |value, cur| "Price: #{value} #{cur}" }
|
17
|
-
}
|
18
|
-
|
19
|
-
locale_de = {
|
20
|
-
'See you' => 'Auf wieder sehen',
|
21
|
-
:long_paragraph => 'Die besten neuer buecher, bis zu 30% reduziert',
|
22
|
-
:price => 'Preis: %d %s',
|
23
|
-
:proc_price => proc { |value, cur| "Preis: #{value} #{cur}" }
|
24
|
-
}
|
25
|
-
|
26
|
-
Localization.add(
|
27
|
-
:en => locale_en,
|
28
|
-
:de => locale_de
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_all
|
33
|
-
lc = Localization.get
|
34
|
-
assert_equal 'See you', lc['See you']
|
35
|
-
assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
|
36
|
-
|
37
|
-
lc = Localization.get(:en)
|
38
|
-
assert_equal 'See you', lc['See you']
|
39
|
-
assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
|
40
|
-
assert_equal 'Price: 100 euro', lc[:price, 100, 'euro']
|
41
|
-
assert_equal 'Price: 100 euro', lc[:proc_price, 100, 'euro']
|
42
|
-
|
43
|
-
lc = Localization.get(:de)
|
44
|
-
assert_equal 'Auf wieder sehen', lc['See you']
|
45
|
-
assert_equal 'Die besten neuer buecher, bis zu 30% reduziert', lc[:long_paragraph]
|
46
|
-
assert_equal 'Preis: 100 euro', lc.translate(:price, 100, 'euro')
|
47
|
-
assert_equal 'Preis: 100 euro', lc[:proc_price, 100, 'euro']
|
48
|
-
end
|
49
|
-
end
|
data/test/glue/tc_logger.rb
DELETED
@@ -1,43 +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
|
-
|
38
|
-
#
|
39
|
-
Logger.set('hello.log')
|
40
|
-
assert_instance_of(Logger, Logger.get)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/test/glue/tc_mail.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'nitro', 'lib')
|
3
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'og', 'lib')
|
4
|
-
|
5
|
-
$NITRO_NO_ENVIRONMENT = true
|
6
|
-
|
7
|
-
require 'test/unit'
|
8
|
-
require 'ostruct'
|
9
|
-
require 'nitro'
|
10
|
-
require 'glue/configuration'
|
11
|
-
require 'glue/mailer'
|
12
|
-
|
13
|
-
class TestCaseMail < Test::Unit::TestCase # :nodoc: all
|
14
|
-
include Glue
|
15
|
-
|
16
|
-
class DummyMailer < Mailer
|
17
|
-
def initialize
|
18
|
-
super
|
19
|
-
@bcc = 'george.moschovitis@gmail.com'
|
20
|
-
@template_root = 'test/public/dummy_mailer'
|
21
|
-
end
|
22
|
-
|
23
|
-
def registration(to, username, token)
|
24
|
-
@to = to
|
25
|
-
@from = 'system@nitroproject.org'
|
26
|
-
@subject = 'Nitro.com registration'
|
27
|
-
@cc = 'george.moschovitis@gmail.com'
|
28
|
-
@body.username = username
|
29
|
-
@body.token = token
|
30
|
-
end
|
31
|
-
|
32
|
-
def greek(to)
|
33
|
-
@to = to
|
34
|
-
@from = 'system@nitroproject.org'
|
35
|
-
@subject = 'Ελληνικός Τίτλος'
|
36
|
-
@cc = 'george.moschovitis@gmail.com'
|
37
|
-
@body = 'Τί έγινε ρε παιδιά;'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
=begin
|
41
|
-
class DummyController < Controller
|
42
|
-
# mailer DummyMailer
|
43
|
-
|
44
|
-
def register
|
45
|
-
token = 999
|
46
|
-
deliver_registration('gmosx@nitroproject.org', 'gmosx', token)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
=end
|
50
|
-
def test_mail
|
51
|
-
m = Glue::Mail.new 'gmosx@nitroproject.org', 'drak@nitroproject.org', 'A simple test', 'This is the body of the message'
|
52
|
-
expected = %{From: gmosx@nitroproject.org
|
53
|
-
To: drak@nitroproject.org
|
54
|
-
Subject: A simple test
|
55
|
-
|
56
|
-
This is the body of the message}
|
57
|
-
assert_equal expected, m.encoded
|
58
|
-
|
59
|
-
m.to = %w{ renos@nitroproject.org stella@nitroproject.org }
|
60
|
-
expected = %{From: gmosx@nitroproject.org
|
61
|
-
To: renos@nitroproject.org, stella@nitroproject.org
|
62
|
-
Subject: A simple test
|
63
|
-
|
64
|
-
This is the body of the message}
|
65
|
-
assert_equal expected, m.encoded
|
66
|
-
|
67
|
-
end
|
68
|
-
=begin
|
69
|
-
def test_mailer
|
70
|
-
assert_equal 0, DummyMailer.deliveries.size
|
71
|
-
|
72
|
-
Mailer.server[:address] = 'mail.nitroproject.org'
|
73
|
-
# assert_equal 'mail.nitroproject.org', DummyMailer.server[:address]
|
74
|
-
|
75
|
-
Mailer.delivery_method = :test
|
76
|
-
Mailer.template_root = File.join(File.dirname(__FILE__), '..', 'root', 'dummy_mailer')
|
77
|
-
token = 999
|
78
|
-
DummyMailer.deliver_registration('george.moschovitis@gmail.com', 'gmosx', token)
|
79
|
-
assert_equal 1, DummyMailer.deliveries.size
|
80
|
-
|
81
|
-
expected = %{From: system@nitroproject.org
|
82
|
-
To: george.moschovitis@gmail.com
|
83
|
-
Cc: george.moschovitis@gmail.com
|
84
|
-
Bcc: george.moschovitis@gmail.com
|
85
|
-
Subject: =?utf-8?Q?Nitro=2ecom_registration?=
|
86
|
-
|
87
|
-
Hello gmosx
|
88
|
-
|
89
|
-
how do you feel?
|
90
|
-
|
91
|
-
Here is your <b>Token</b>: 999
|
92
|
-
}
|
93
|
-
assert_equal expected, DummyMailer.deliveries[0].encoded
|
94
|
-
|
95
|
-
DummyMailer.deliver_greek('george.moschovitis@gmail.com')
|
96
|
-
assert_equal 2, DummyMailer.deliveries.size
|
97
|
-
end
|
98
|
-
=end
|
99
|
-
end
|