glue 0.41.0 → 1.0.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/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/lib/html/tokenizer.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'strscan'
|
2
|
-
|
3
|
-
module HTML#:nodoc:
|
4
|
-
|
5
|
-
# A simple HTML tokenizer. It simply breaks a stream of text into tokens, where each
|
6
|
-
# token is a string. Each string represents either "text", or an HTML element.
|
7
|
-
#
|
8
|
-
# This currently assumes valid XHTML, which means no free < or > characters.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# tokenizer = HTML::Tokenizer.new(text)
|
13
|
-
# while token = tokenizer.next
|
14
|
-
# p token
|
15
|
-
# end
|
16
|
-
class Tokenizer#:nodoc:
|
17
|
-
|
18
|
-
# The current (byte) position in the text
|
19
|
-
attr_reader :position
|
20
|
-
|
21
|
-
# The current line number
|
22
|
-
attr_reader :line
|
23
|
-
|
24
|
-
# Create a new Tokenizer for the given text.
|
25
|
-
def initialize(text)
|
26
|
-
@scanner = StringScanner.new(text)
|
27
|
-
@position = 0
|
28
|
-
@line = 0
|
29
|
-
@current_line = 1
|
30
|
-
end
|
31
|
-
|
32
|
-
# Return the next token in the sequence, or +nil+ if there are no more tokens in
|
33
|
-
# the stream.
|
34
|
-
def next
|
35
|
-
return nil if @scanner.eos?
|
36
|
-
@position = @scanner.pos
|
37
|
-
@line = @current_line
|
38
|
-
if @scanner.check(/<\S/)
|
39
|
-
update_current_line(scan_tag)
|
40
|
-
else
|
41
|
-
update_current_line(scan_text)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
# Treat the text at the current position as a tag, and scan it. Supports
|
48
|
-
# comments, doctype tags, and regular tags, and ignores less-than and
|
49
|
-
# greater-than characters within quoted strings.
|
50
|
-
def scan_tag
|
51
|
-
tag = @scanner.getch
|
52
|
-
if @scanner.scan(/!--/) # comment
|
53
|
-
tag << @scanner.matched
|
54
|
-
tag << @scanner.scan_until(/--\s*>/)
|
55
|
-
elsif @scanner.scan(/!/) # doctype
|
56
|
-
tag << @scanner.matched
|
57
|
-
tag << consume_quoted_regions
|
58
|
-
else
|
59
|
-
tag << consume_quoted_regions
|
60
|
-
end
|
61
|
-
tag
|
62
|
-
end
|
63
|
-
|
64
|
-
# Scan all text up to the next < character and return it.
|
65
|
-
def scan_text
|
66
|
-
@scanner.getch + (@scanner.scan(/[^<]*/) || "")
|
67
|
-
end
|
68
|
-
|
69
|
-
# Counts the number of newlines in the text and updates the current line
|
70
|
-
# accordingly.
|
71
|
-
def update_current_line(text)
|
72
|
-
@current_line += text.scan(/\r\n|\r|\n/).length
|
73
|
-
text
|
74
|
-
end
|
75
|
-
|
76
|
-
# Skips over quoted strings, so that less-than and greater-than characters
|
77
|
-
# within the strings are ignored.
|
78
|
-
def consume_quoted_regions
|
79
|
-
text = ""
|
80
|
-
loop do
|
81
|
-
match = @scanner.scan_until(/['"<>]/) or break
|
82
|
-
|
83
|
-
delim = @scanner.matched
|
84
|
-
if delim == "<"
|
85
|
-
match = match.chop
|
86
|
-
@scanner.pos -= 1
|
87
|
-
end
|
88
|
-
|
89
|
-
text << match
|
90
|
-
break if delim == "<" || delim == ">"
|
91
|
-
|
92
|
-
# consume the conqued region
|
93
|
-
while match = @scanner.scan_until(/[\\#{delim}]/)
|
94
|
-
text << match
|
95
|
-
break if @scanner.matched == delim
|
96
|
-
text << @scanner.getch # skip the escaped character
|
97
|
-
end
|
98
|
-
end
|
99
|
-
text
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
data/lib/html/version.rb
DELETED
data/test/fixture/article.csv
DELETED
data/test/fixture/article.yml
DELETED
data/test/fixture/user.yml
DELETED
data/test/glue/builder/tc_xml.rb
DELETED
@@ -1,57 +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/builder/xml'
|
6
|
-
|
7
|
-
class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all
|
8
|
-
include Glue
|
9
|
-
|
10
|
-
def test_string
|
11
|
-
x = Glue::XmlBuilder.new
|
12
|
-
|
13
|
-
x.start_tag!('html').
|
14
|
-
start_tag!('title').text!('hello').end_tag!('title').
|
15
|
-
end_tag!('html')
|
16
|
-
|
17
|
-
assert_equal '<html><title>hello</title></html>', x.buffer
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_missing
|
21
|
-
x = Glue::XmlBuilder.new
|
22
|
-
x.b('This is bold')
|
23
|
-
assert_equal '<b>This is bold</b>', x.buffer
|
24
|
-
|
25
|
-
x = Glue::XmlBuilder.new
|
26
|
-
x.a('Nitro', :href => 'http://www.nitroproject.org')
|
27
|
-
assert_equal '<a href="http://www.nitroproject.org">Nitro</a>', x.buffer
|
28
|
-
|
29
|
-
|
30
|
-
x = Glue::XmlBuilder.new
|
31
|
-
x.b {
|
32
|
-
x.i 'Hello', :class =>'new'
|
33
|
-
x.p 'Paragraph'
|
34
|
-
}
|
35
|
-
assert_equal '<b><i class="new">Hello</i><p>Paragraph</p></b>', x.buffer
|
36
|
-
|
37
|
-
x = Glue::XmlBuilder.new
|
38
|
-
x.hr
|
39
|
-
assert_equal '<hr />', x.buffer
|
40
|
-
|
41
|
-
x = Glue::XmlBuilder.new
|
42
|
-
x.hr(:style => 'height: 1px')
|
43
|
-
assert_equal '<hr style="height: 1px" />', x.buffer
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_xml_builder
|
47
|
-
buffer = ''
|
48
|
-
x = Glue::XmlBuilder.new(buffer)
|
49
|
-
|
50
|
-
x.start_tag!('html').
|
51
|
-
start_tag!('title').text!('hello').end_tag!('title').
|
52
|
-
end_tag!('html')
|
53
|
-
|
54
|
-
assert_equal '<html><title>hello</title></html>', buffer
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
data/test/glue/tc_aspects.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'facets/more/aspects'
|
5
|
-
|
6
|
-
class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
7
|
-
|
8
|
-
class Monitor
|
9
|
-
def self.pre(this)
|
10
|
-
this.ma = 2
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.post(this)
|
14
|
-
this.mb = 5
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module Localize
|
19
|
-
def localize
|
20
|
-
@ll = 5
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
module Tester
|
25
|
-
include ::Aspects
|
26
|
-
|
27
|
-
attr_accessor :ta
|
28
|
-
pre { |this| this.ta = 5 }
|
29
|
-
end
|
30
|
-
|
31
|
-
class Dummy
|
32
|
-
include ::Aspects
|
33
|
-
include Tester
|
34
|
-
|
35
|
-
attr_accessor :a, :b, :c
|
36
|
-
attr_accessor :oa, :ob
|
37
|
-
attr_accessor :ma, :mb
|
38
|
-
attr_accessor :ll
|
39
|
-
attr_accessor :pa
|
40
|
-
|
41
|
-
pre :pre_advice
|
42
|
-
wrap Monitor
|
43
|
-
wrap Localize, :pre => :localize
|
44
|
-
post { |this| this.pa = 3 }
|
45
|
-
|
46
|
-
def initialize
|
47
|
-
@a = 0
|
48
|
-
end
|
49
|
-
|
50
|
-
def hello(q)
|
51
|
-
@a += 1 + q
|
52
|
-
end
|
53
|
-
|
54
|
-
def pre_advice
|
55
|
-
@b = 1
|
56
|
-
@a += 1
|
57
|
-
end
|
58
|
-
|
59
|
-
def post_advice
|
60
|
-
@c = 1
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Class aspect.
|
65
|
-
|
66
|
-
class Observer < Aspect
|
67
|
-
def self.pre(this)
|
68
|
-
this.oa = 9
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Instance aspect.
|
73
|
-
|
74
|
-
class Epilogue < Aspect
|
75
|
-
def post(this)
|
76
|
-
this.ob = 9
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_all
|
81
|
-
Observer.wrap(Dummy, :hello)
|
82
|
-
Epilogue.new.wrap(Dummy, :hello)
|
83
|
-
::Aspects.wrap(Dummy, :hello)
|
84
|
-
|
85
|
-
d = Dummy.new
|
86
|
-
d.hello(3)
|
87
|
-
assert_equal 5, d.a
|
88
|
-
assert_equal 1, d.b
|
89
|
-
assert_equal 9, d.oa
|
90
|
-
assert_equal 9, d.ob
|
91
|
-
assert_equal 2, d.ma
|
92
|
-
assert_equal 5, d.mb
|
93
|
-
assert_equal 5, d.ll
|
94
|
-
assert_equal 3, d.pa
|
95
|
-
|
96
|
-
assert_equal 5, d.ta
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
data/test/glue/tc_attribute.rb
DELETED
@@ -1,112 +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
|
-
require 'og'
|
6
|
-
require 'glue/logger'
|
7
|
-
require 'glue/attribute'
|
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
|
-
module Test # :nodoc: all
|
16
|
-
|
17
|
-
class Msg
|
18
|
-
include Og::Unmanageable
|
19
|
-
|
20
|
-
attr_accessor :owner_oid, Fixnum
|
21
|
-
attr_accessor :val1, :val2, :val3, Fixnum, :sql => "smallint"
|
22
|
-
attr_accessor :title, :body, String
|
23
|
-
attr_accessor :test, String, :sql => "char(10) NOT NULL"
|
24
|
-
attr_accessor :count, Fixnum
|
25
|
-
attr_accessor :create_time, Time
|
26
|
-
|
27
|
-
# a marshaled property
|
28
|
-
attr_accessor :options, Array
|
29
|
-
|
30
|
-
# property with macro arguments!
|
31
|
-
attr_accessor :address, VarChar(30), NotNull
|
32
|
-
|
33
|
-
def initialize
|
34
|
-
@create_time = Time.now
|
35
|
-
@options = []
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
class SubMsg < Msg
|
41
|
-
# to avoid conflicts with tc_og.rb
|
42
|
-
include Og::Unmanageable
|
43
|
-
|
44
|
-
# duplicate definition with different type!
|
45
|
-
attr_accessor :count, Float
|
46
|
-
|
47
|
-
# another property
|
48
|
-
attr_accessor :another, Fixnum
|
49
|
-
end
|
50
|
-
|
51
|
-
class C
|
52
|
-
attr_accessor :name
|
53
|
-
attr_accessor :description
|
54
|
-
end
|
55
|
-
|
56
|
-
class C
|
57
|
-
attr_accessor :name, String
|
58
|
-
attr_accessor :description, String
|
59
|
-
end
|
60
|
-
|
61
|
-
class TC_N_Attributes < Test::Unit::TestCase
|
62
|
-
|
63
|
-
def setup
|
64
|
-
Msg.define_force_methods
|
65
|
-
@msg1 = Msg.new
|
66
|
-
end
|
67
|
-
|
68
|
-
def teardown
|
69
|
-
@msg1 = nil
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_props
|
73
|
-
|
74
|
-
# bug: props for subclasses.
|
75
|
-
# bug: props propagated to base classes.
|
76
|
-
|
77
|
-
assert(SubMsg.serializable_attributes)
|
78
|
-
assert_equal(Msg.serializable_attributes.size(), SubMsg.serializable_attributes.size() - 1)
|
79
|
-
|
80
|
-
assert_equal(11, Msg.serializable_attributes.size)
|
81
|
-
assert_equal(12, SubMsg.serializable_attributes.size)
|
82
|
-
|
83
|
-
# bug: duplicate definition
|
84
|
-
|
85
|
-
a = SubMsg.serializable_attributes.find { |p| :count == p }
|
86
|
-
assert_equal(Float, SubMsg.ann[SubMsg.serializable_attributes.find { |p| :count == p }].class)
|
87
|
-
|
88
|
-
# dont force conversion.
|
89
|
-
|
90
|
-
@msg1.count = 2.4
|
91
|
-
assert_equal(Float, @msg1.count.class)
|
92
|
-
|
93
|
-
# force conversion
|
94
|
-
|
95
|
-
@msg1.__force_count(2.4)
|
96
|
-
assert_equal(Fixnum, @msg1.count.class)
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_macro_params
|
100
|
-
sql = Msg.ann[Msg.serializable_attributes.find { |p| :address == p}].sql
|
101
|
-
# FIXME: Temporarily dissabled.
|
102
|
-
# assert_equal 'VARCHAR(30) NOT NULL', sql
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
def test_soc
|
107
|
-
assert_equal String, C.ann.name.class
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
@@ -1,86 +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
|
-
require 'glue/attribute'
|
6
|
-
|
7
|
-
module Mixin
|
8
|
-
attr_accessor :date
|
9
|
-
ann self, :dummy => [123]
|
10
|
-
end
|
11
|
-
|
12
|
-
class MixedOnly
|
13
|
-
include Mixin
|
14
|
-
ann.self.dummy! << 5
|
15
|
-
ann.self.dummy! << 3
|
16
|
-
end
|
17
|
-
|
18
|
-
class MixedOnly2
|
19
|
-
include Mixin
|
20
|
-
end
|
21
|
-
|
22
|
-
class MixedWithProp
|
23
|
-
include Mixin
|
24
|
-
|
25
|
-
attr_accessor :dummy
|
26
|
-
end
|
27
|
-
|
28
|
-
class Pure
|
29
|
-
attr_accessor :dummy
|
30
|
-
end
|
31
|
-
|
32
|
-
class Empty
|
33
|
-
end
|
34
|
-
|
35
|
-
class Base
|
36
|
-
attr_accessor :date
|
37
|
-
ann self, :dummy => [123]
|
38
|
-
end
|
39
|
-
|
40
|
-
class Child1 < Base
|
41
|
-
ann.self.dummy!.first << 5
|
42
|
-
ann.self.dummy!.first << 3
|
43
|
-
end
|
44
|
-
|
45
|
-
class Child2 < Base
|
46
|
-
end
|
47
|
-
|
48
|
-
# Tests auto management.
|
49
|
-
class TC_MixinsTest < ::Test::Unit::TestCase
|
50
|
-
def test_the_unmanaged
|
51
|
-
assert( Empty.respond_to?( :__props ) == false )
|
52
|
-
assert_respond_to( Pure.new, :dummy )
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_manage_entities
|
56
|
-
assert_respond_to( Pure, :serializable_attributes )
|
57
|
-
assert_respond_to( Pure.new, :dummy )
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_managing_mixedonly_classes
|
61
|
-
assert_respond_to( MixedOnly.new, :date )
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_managing_mixins
|
65
|
-
assert_respond_to( Mixin, :serializable_attributes )
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_managing_mixed_classes
|
69
|
-
obj = MixedWithProp.new
|
70
|
-
assert( obj.respond_to?( :date ) )
|
71
|
-
assert( obj.respond_to?( :dummy ) )
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_crosspolination
|
75
|
-
assert_equal 3, MixedOnly.ann.self[:dummy].size
|
76
|
-
# FIXME:
|
77
|
-
# assert_equal 1, MixedOnly2.ann.self[:dummy].size
|
78
|
-
# assert_equal 1, Mixin.ann.self[:dummy].size
|
79
|
-
=begin
|
80
|
-
gmosx: THINK!
|
81
|
-
assert_equal 3, Child1.__meta[:dummy].first.size
|
82
|
-
assert_equal 1, Child2.__meta[:dummy].first.size
|
83
|
-
assert_equal 1, Base.__meta[:dummy].first.size
|
84
|
-
=end
|
85
|
-
end
|
86
|
-
end
|